test support of group having multiple .cpp files
authorJens Thiele <jens.thiele@intra2net.com>
Mon, 27 Nov 2006 16:44:20 +0000 (16:44 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Mon, 27 Nov 2006 16:44:20 +0000 (16:44 +0000)
example-codegen/Makefile.am
example-codegen/other-1.cpp [moved from example-codegen/other.cpp with 88% similarity]
example-codegen/other-2.cpp [new file with mode: 0644]

index 4318ca6..b8c4c1c 100644 (file)
@@ -4,6 +4,9 @@ LDADD = $(top_builddir)/src/libt2n.la @BOOST_SERIALIZATION_LIB@ @BOOST_LDFLAGS@
 
 CMDGROUPS = default other
 
+default_GROUP = default.cpp
+other_GROUP = other-1.cpp other-2.cpp
+
 # unfortunately we can't set those from variables
 # because they are parsed by automake
 
@@ -15,8 +18,8 @@ client_SOURCES = client.cpp
 client_LDADD = $(LDADD) libdefault.la libother.la
 
 server_SOURCES = server.cpp \
-       other.cpp other_server.cpp \
-       default.cpp default_server.cpp \
+       $(other_GROUP) other_server.cpp \
+       $(default_GROUP) default_server.cpp \
        foo.hxx
 
 noinst_PROGRAMS = client server
@@ -24,27 +27,28 @@ noinst_PROGRAMS = client server
 
 # always the same:
 
-codegen.stamp: $(CMDGROUPS:%=%.cpp) $(top_builddir)/codegen/codegen
-# assuming we have some unix like shell
+IFILES=$(foreach i, $(CMDGROUPS), $(foreach j, $($(i)_GROUP), $(j)))
+STAMPS=$(CMDGROUPS:=.stamp)
+$(STAMPS): %.stamp : $(IFILES) $(top_builddir)/codegen/codegen Makefile.am
+# assuming we have some unix like shell (maybe even bash)
+       echo IFILES: $(IFILES)
        echo BUILT_SOURCES: $(BUILT_SOURCES)
-       for i in $(CMDGROUPS); do \
-               cp -v $(top_srcdir)/codegen/codegen-stubhead.hxx $${i}_common.hxx; \
-               cp -v $(top_srcdir)/codegen/codegen-stubhead.hxx $${i}_server.hxx; \
-       done
+       cp -v $(top_srcdir)/codegen/codegen-stubhead.hxx $*_common.hxx;
+       cp -v $(top_srcdir)/codegen/codegen-stubhead.hxx $*_server.hxx;
 # todo use tmp file for xml file
-       for i in $(CMDGROUPS); do \
-               gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $${i}.cpp -fxml=$${i}.xml; \
-               $(top_builddir)/codegen/codegen $${i}.cpp $${i} $${i}.xml; \
-       done; touch $@
+       for i in $($*_GROUP); do \
+               gccxml $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) $${i} -fxml=$${i%*.cpp}.xml; \
+       done; \
+       $(top_builddir)/codegen/codegen $*.cpp $* $($*_GROUP:.cpp=.xml) && touch $@
 
 # assuming we have gnu make?
 BUILT_SOURCES = $(foreach i, $(CMDGROUPS), $(foreach j, _common.hxx _common.cpp _client.hxx _client.cpp _server.hxx _server.cpp, $(i)$(j)) )
 
-$(BUILT_SOURCES) : codegen.stamp
+$(BUILT_SOURCES) : $(STAMPS)
 
 TESTS = test
 
-CLEANFILES = $(BUILT_SOURCES) codegen.stamp
+CLEANFILES = $(BUILT_SOURCES) $(STAMPS)
 
 # TODO:
 # howto generate Makefile(.in) from something like this:
similarity index 88%
rename from example-codegen/other.cpp
rename to example-codegen/other-1.cpp
index c84fcdc..568082d 100644 (file)
@@ -31,9 +31,3 @@ LIBT2N_EXPORT bool t3(const std::vector<int> &i)
 {
     return (i.size()==1) && (i[0]==10);
 }
-
-//! test own type
-LIBT2N_EXPORT bool t3(const Foo &foo)
-{
-    return (foo.i==foo.j);
-}
diff --git a/example-codegen/other-2.cpp b/example-codegen/other-2.cpp
new file mode 100644 (file)
index 0000000..05ccc4b
--- /dev/null
@@ -0,0 +1,21 @@
+#include <string>
+// serialization of string
+#include <boost/serialization/string.hpp>
+// serialization of pair
+#include <boost/serialization/utility.hpp>
+
+// std::vector
+#include <vector>
+#include <boost/serialization/vector.hpp>
+
+#include "foo.hxx"
+
+#include "other_common.hxx"
+
+using namespace std;
+
+//! test own type
+LIBT2N_EXPORT bool t3(const Foo &foo)
+{
+    return (foo.i==foo.j);
+}