Browse Source

external patched static anttweakbar, example fun and libigl makefile

Former-commit-id: 1ab2a2fbd668dd7e3ecb0d00cf8f97a13e7ce14d
jalec 13 years ago
parent
commit
3a8bbc8ed6
6 changed files with 132 additions and 4 deletions
  1. 32 0
      Makefile
  2. 19 0
      example_fun.cpp
  3. 28 0
      example_fun.h
  4. 31 0
      examples/example_fun/Makefile
  5. 10 0
      examples/example_fun/README
  6. 12 4
      readme.txt

+ 32 - 0
Makefile

@@ -0,0 +1,32 @@
+.PHONY: all
+
+all: obj libigl.a
+
+debug: obj libigl.a
+
+CPP_FILES=$(wildcard ./*.cpp)
+OBJ_FILES=$(addprefix obj/,$(notdir $(CPP_FILES:.cpp=.o)))
+
+# optimized default settings
+all: LFLAGS +=
+all: CFLAGS += -O3 -DNDEBUG
+debug: CFLAGS += -g
+
+#LIB+=-framework OpenGL
+#LIB+=-framework GLUT
+#LIB+=-framework AppKit
+
+
+obj: 
+	mkdir -p obj
+
+libigl.a: $(OBJ_FILES)
+	rm -f $@
+	ar cqs $@ $(OBJ_FILES)
+
+obj/%.o: %.cpp
+	g++ $(CFLAGS) -c -o $@ $< $(INC)
+
+clean:
+	rm -f obj/*.o
+	rm -f libigl.a

+ 19 - 0
example_fun.cpp

@@ -0,0 +1,19 @@
+#include "example_fun.h"
+#include <iostream>
+
+template <typename Printable>
+IGL_INLINE bool igl::example_fun(const Printable & input)
+{
+  using namespace std;
+  cout<<"example_fun: "<<input<<endl;
+  return true;
+}
+
+#ifndef IGL_HEADER_ONLY
+// List all useful instanciations here
+namespace igl_explicit_instanciations
+{
+  bool (*example_fun_A)(const double &) = &igl::example_fun<double>;
+  bool (*example_fun_B)(const int &) = &igl::example_fun<int>;
+}
+#endif

+ 28 - 0
example_fun.h

@@ -0,0 +1,28 @@
+#ifndef IGL_EXAMPLE_FUN_H
+#define IGL_EXAMPLE_FUN_H
+
+#ifdef IGL_HEADER_ONLY
+#  define IGL_INLINE inline
+#else
+#  define IGL_INLINE
+#endif
+
+namespace igl
+{
+  // This is an example of a function, it takes a templated parameter and
+  // shovels it into cout
+  //
+  // Templates:
+  //   T  type that supports
+  // Input:
+  //   input  some input of a Printable type
+  // Returns true for the sake of returning something
+  template <typename Printable>
+  IGL_INLINE bool example_fun(const Printable & input);
+}
+
+#ifdef IGL_HEADER_ONLY
+#  include "example_fun.cpp"
+#endif
+
+#endif

+ 31 - 0
examples/example_fun/Makefile

@@ -0,0 +1,31 @@
+.PHONY: all
+
+all: example_static example_header_only
+
+igl_lib=../../
+
+CFLAGS=-g
+inc=-I$(igl_lib)
+lib=
+
+STATIC_LIB=-ligl -L../../
+HEADER_ONLY_DEF=-DIGL_HEADER_ONLY
+
+example_static: example_static.o
+	#g++ $(CFLAGS) -o example_static example_static.o $(lib) $(STATIC_LIB) ../../obj/example_fun.o
+	g++ $(CFLAGS) -o example_static example_static.o ../../obj/example_fun.o
+
+example_static.o: example.cpp
+	g++ $(CFLAGS) -c example.cpp -o example_static.o $(inc)
+
+example_header_only: example_header_only.o
+	g++ $(CFLAGS) -o example_header_only example_header_only.o $(lib)
+
+example_header_only.o: example.cpp
+	g++ $(CFLAGS) -c example.cpp -o example_header_only.o $(inc) $(HEADER_ONLY_DEF)
+
+clean:
+	rm -f example_static.o
+	rm -f example_static
+	rm -f example_header_only.o
+	rm -f example_header_only

+ 10 - 0
examples/example_fun/README

@@ -0,0 +1,10 @@
+This is a simple example program that shows how to link against the igl static
+library or use the igl library as a headers only library.
+
+
+To Build:
+  make
+
+To Run:
+  ./example_static
+  ./example_header_only

+ 12 - 4
readme.txt

@@ -32,14 +32,17 @@ This library is shared by many people. Each function prototype should be
 well documented.  Write a summary of what the function does and a
 description of each template, input and output in each prototype. 
 
-  - All functions must be inlined, otherwise there is trouble when
+  X- All functions must be inlined, otherwise there is trouble when
     linking included headers used in multiple .cpp files
-  - Use a single .h file with the same name as the function
-  - Do *not* use any .cpp files (this is *header only* library)
+  - Use a single .h/.cpp pair with the same name as the function
+  X- Do *not* use any .cpp files (this is *header only* library)
   - At least one version of the function should use references for all
     outputs
+  - Functions with external dependencies should be a single .h file (no
+    .cpp file) so it won't appear in libigl.a
   - Use wrappers and additional prototypes for returning single-output
-    functions' outputs
+    functions' outputs, but the default is to only use outputs
+  - All inputs should be const when appropriate
   - Use c++ references for inputs and outputs rather than pointers or
     pass-by-copy
   - Take the time to write multiple prototypes if you'd like to have
@@ -55,6 +58,11 @@ description of each template, input and output in each prototype.
      or 
     "using namespace igl;"
     etc.
+  - Function names should either be the same as the corresponding MATLAB
+    function or should use all lowercase separated by underscores: e.g.
+    my_function_name
+  - Classes should be in CamelCase
+  - No tabs, only two spaces per indentation level
 
   = Specific style conventions =