From c5e54ff222d1174d0c99265f2812cd84fa320986 Mon Sep 17 00:00:00 2001 From: Jens Thiele Date: Mon, 27 Nov 2006 16:44:20 +0000 Subject: [PATCH 1/1] test support of group having multiple .cpp files --- example-codegen/Makefile.am | 32 ++++++++++++++++++-------------- example-codegen/other-1.cpp | 33 +++++++++++++++++++++++++++++++++ example-codegen/other-2.cpp | 21 +++++++++++++++++++++ example-codegen/other.cpp | 39 --------------------------------------- 4 files changed, 72 insertions(+), 53 deletions(-) create mode 100644 example-codegen/other-1.cpp create mode 100644 example-codegen/other-2.cpp delete mode 100644 example-codegen/other.cpp diff --git a/example-codegen/Makefile.am b/example-codegen/Makefile.am index 4318ca6..b8c4c1c 100644 --- a/example-codegen/Makefile.am +++ b/example-codegen/Makefile.am @@ -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: diff --git a/example-codegen/other-1.cpp b/example-codegen/other-1.cpp new file mode 100644 index 0000000..568082d --- /dev/null +++ b/example-codegen/other-1.cpp @@ -0,0 +1,33 @@ +#include +// serialization of string +#include +// serialization of pair +#include + +// std::vector +#include +#include + +#include "foo.hxx" + +#include "other_common.hxx" + +using namespace std; + +//! test function overload +LIBT2N_EXPORT int t3(int i) +{ + return i; +} + +//! test pair, multiple arguments and namespace +LIBT2N_EXPORT bool t3(int i, float f, const string &s, const pair &p) +{ + return (i==p.first) && (f==p.second) && (s=="hello"); +} + +//! test std::vector +LIBT2N_EXPORT bool t3(const std::vector &i) +{ + return (i.size()==1) && (i[0]==10); +} diff --git a/example-codegen/other-2.cpp b/example-codegen/other-2.cpp new file mode 100644 index 0000000..05ccc4b --- /dev/null +++ b/example-codegen/other-2.cpp @@ -0,0 +1,21 @@ +#include +// serialization of string +#include +// serialization of pair +#include + +// std::vector +#include +#include + +#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); +} diff --git a/example-codegen/other.cpp b/example-codegen/other.cpp deleted file mode 100644 index c84fcdc..0000000 --- a/example-codegen/other.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -// serialization of string -#include -// serialization of pair -#include - -// std::vector -#include -#include - -#include "foo.hxx" - -#include "other_common.hxx" - -using namespace std; - -//! test function overload -LIBT2N_EXPORT int t3(int i) -{ - return i; -} - -//! test pair, multiple arguments and namespace -LIBT2N_EXPORT bool t3(int i, float f, const string &s, const pair &p) -{ - return (i==p.first) && (f==p.second) && (s=="hello"); -} - -//! test std::vector -LIBT2N_EXPORT bool t3(const std::vector &i) -{ - return (i.size()==1) && (i[0]==10); -} - -//! test own type -LIBT2N_EXPORT bool t3(const Foo &foo) -{ - return (foo.i==foo.j); -} -- 1.7.1