diff options
-rw-r--r-- | build/bootstrap.make | 7 | ||||
-rw-r--r-- | common/circular/multiple/driver.cxx | 51 | ||||
-rw-r--r-- | common/circular/multiple/makefile | 116 | ||||
-rw-r--r-- | common/circular/multiple/test.std | 0 | ||||
-rw-r--r-- | common/circular/multiple/test1.hxx | 28 | ||||
-rw-r--r-- | common/circular/multiple/test2.hxx | 18 | ||||
-rw-r--r-- | common/circular/single/driver.cxx | 39 | ||||
-rw-r--r-- | common/circular/single/makefile | 113 | ||||
-rw-r--r-- | common/circular/single/test.hxx | 29 | ||||
-rw-r--r-- | common/circular/single/test.std | 0 | ||||
-rw-r--r-- | common/makefile | 2 | ||||
-rw-r--r-- | oracle/custom/makefile | 2 |
12 files changed, 400 insertions, 5 deletions
diff --git a/build/bootstrap.make b/build/bootstrap.make index aba7532..d4e5049 100644 --- a/build/bootstrap.make +++ b/build/bootstrap.make @@ -47,11 +47,10 @@ endif # Database schema creation. # ifeq ($(filter $(db_id),sqlite),) -$(out_base)/.test: schema-extra = \ -$(call message,sql $$1,$(dcf_root)/db-driver $$1,$(src_base)/$1)$(literal_newline)$(literal_tab) +$(out_base)/.test: schema-body = \ +$(call message,sql $$1,$(dcf_root)/db-driver $$1,$1)$(literal_newline)$(literal_tab) $(out_base)/.test: schema = \ -$(foreach s,$1,$(call schema-extra,$s))$(call \ -message,sql $$1,$(dcf_root)/db-driver $$1,$(out_base)/test.sql) +$(foreach s,$(if $1,$1,$(out_base)/test.sql),$(call schema-body,$s))@: endif # Dist setup. diff --git a/common/circular/multiple/driver.cxx b/common/circular/multiple/driver.cxx new file mode 100644 index 0000000..2f28911 --- /dev/null +++ b/common/circular/multiple/driver.cxx @@ -0,0 +1,51 @@ +// file : common/circular/multiple/driver.cxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// Test cases of circular dependencies between persistent classes, multiple +// files version. +// + +#include <memory> // std::auto_ptr +#include <cassert> +#include <iostream> + +#include <odb/database.hxx> +#include <odb/transaction.hxx> +#include <odb/schema-catalog.hxx> + +#include <common/common.hxx> + +#include "test1.hxx" +#include "test2.hxx" + +#include "test2-odb.hxx" +#include "test1-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr<database> db (create_database (argc, argv, false)); + + // Create the database schema. + // + { + transaction t (db->begin ()); + schema_catalog::create_schema (*db); + t.commit (); + } + + query<base> bq (query<base>::d->id != 0); + query<derived> dq (query<derived>::b->id != 0); + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/common/circular/multiple/makefile b/common/circular/multiple/makefile new file mode 100644 index 0000000..82a0bae --- /dev/null +++ b/common/circular/multiple/makefile @@ -0,0 +1,116 @@ +# file : common/circular/multiple/makefile +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +cxx_tun := driver.cxx +odb_hdr := test1.hxx test2.hxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options + +driver := $(out_base)/driver +dist := $(out_base)/.dist +test := $(out_base)/.test +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/odb/stub.make,\ + odb: odb,odb-rules: odb_rules) + +# Build. +# +$(driver): $(cxx_obj) $(common.l) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) +$(cxx_obj) $(cxx_od): $(common.l.cpp-options) + +genf := $(foreach f,$(odb_hdr:.hxx=),$(addprefix $f,-odb.hxx -odb.ixx -odb.cxx .sql)) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(odb) +$(gen): odb := $(odb) +$(gen) $(dist): export odb_options += --database $(db_id) --generate-schema \ +--schema-format embedded --generate-query --table-prefix circular_m_ +$(gen): cpp_options := -I$(src_base) +$(gen): $(common.l.cpp-options) + +# Extra dependecy for the ODB-generated code. +# +$(gen): $(src_base)/test1.hxx $(src_base)/test2.hxx + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +# Alias for default target. +# +$(out_base)/: $(driver) + +# Dist +# +name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) + +$(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) +$(dist): + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) + +# Test. +# +$(test): $(driver) $(src_base)/test.std + $(call message,test $<,$< --options-file $(dcf_root)/db.options \ +>$(out_base)/test.out) + $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) + $(call message,,rm -f $(out_base)/test.out) + +# Clean. +# +$(clean): \ + $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) + $(call message,,rm -f $(out_base)/test.out) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + +# How to. +# +$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) +$(call include,$(bld_root)/meta/automake.make) + +$(call include,$(bld_root)/cxx/standard.make) # cxx_standard +ifdef cxx_standard +$(gen): odb_options += --std $(cxx_standard) +$(call include,$(odb_rules)) +endif + +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/o-e.make) + +# Dependencies. +# +$(call import,$(src_root)/libcommon/makefile) diff --git a/common/circular/multiple/test.std b/common/circular/multiple/test.std new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/common/circular/multiple/test.std diff --git a/common/circular/multiple/test1.hxx b/common/circular/multiple/test1.hxx new file mode 100644 index 0000000..5ba4b92 --- /dev/null +++ b/common/circular/multiple/test1.hxx @@ -0,0 +1,28 @@ +// file : common/circular/multiple/test1.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST1_HXX +#define TEST1_HXX + +#include <odb/core.hxx> + +#pragma db object +struct derived; + +#pragma db object polymorphic +struct base +{ + virtual ~base () {} + + #pragma db id + unsigned long id_; + + derived* d_; +}; + +#ifdef ODB_COMPILER +# include "test2.hxx" +#endif + +#endif // TEST1_HXX diff --git a/common/circular/multiple/test2.hxx b/common/circular/multiple/test2.hxx new file mode 100644 index 0000000..8f6ae5e --- /dev/null +++ b/common/circular/multiple/test2.hxx @@ -0,0 +1,18 @@ +// file : common/circular/multiple/test2.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST2_HXX +#define TEST2_HXX + +#include <odb/core.hxx> + +#include "test1.hxx" + +#pragma db object +struct derived: base +{ + base* b_; +}; + +#endif // TEST2_HXX diff --git a/common/circular/single/driver.cxx b/common/circular/single/driver.cxx new file mode 100644 index 0000000..e4b0be6 --- /dev/null +++ b/common/circular/single/driver.cxx @@ -0,0 +1,39 @@ +// file : common/circular/single/driver.cxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +// Test cases of circular dependencies between persistent classes, single +// file version. +// + +#include <memory> // std::auto_ptr +#include <cassert> +#include <iostream> + +#include <odb/database.hxx> +#include <odb/transaction.hxx> + +#include <common/common.hxx> + +#include "test.hxx" +#include "test-odb.hxx" + +using namespace std; +using namespace odb::core; + +int +main (int argc, char* argv[]) +{ + try + { + auto_ptr<database> db (create_database (argc, argv)); + + query<base> bq (query<base>::d->id != 0); + query<derived> dq (query<derived>::b->id != 0); + } + catch (const odb::exception& e) + { + cerr << e.what () << endl; + return 1; + } +} diff --git a/common/circular/single/makefile b/common/circular/single/makefile new file mode 100644 index 0000000..e1677d4 --- /dev/null +++ b/common/circular/single/makefile @@ -0,0 +1,113 @@ +# file : common/circular/single/makefile +# copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +# license : GNU GPL v2; see accompanying LICENSE file + +include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make + +cxx_tun := driver.cxx +odb_hdr := test.hxx +cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o)) +cxx_od := $(cxx_obj:.o=.o.d) + +common.l := $(out_root)/libcommon/common/common.l +common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options + +driver := $(out_base)/driver +dist := $(out_base)/.dist +test := $(out_base)/.test +clean := $(out_base)/.clean + +# Import. +# +$(call import,\ + $(scf_root)/import/odb/stub.make,\ + odb: odb,odb-rules: odb_rules) + +# Build. +# +$(driver): $(cxx_obj) $(common.l) +$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base) +$(cxx_obj) $(cxx_od): $(common.l.cpp-options) + +genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql) +gen := $(addprefix $(out_base)/,$(genf)) + +$(gen): $(odb) +$(gen): odb := $(odb) +$(gen) $(dist): export odb_options += --database $(db_id) --generate-schema \ +--generate-query --table-prefix circular_s_ +$(gen): cpp_options := -I$(src_base) +$(gen): $(common.l.cpp-options) + +$(call include-dep,$(cxx_od),$(cxx_obj),$(gen)) + +# Alias for default target. +# +$(out_base)/: $(driver) + +# Dist +# +name := $(subst /,-,$(subst $(src_root)/common/,,$(src_base))) + +$(dist): db_id := @database@ +$(dist): sources := $(cxx_tun) +$(dist): headers := $(odb_hdr) +$(dist): data_dist := test.std +$(dist): export name := $(name) +$(dist): export extra_dist := $(data_dist) $(call vc9projs,$(name)) \ +$(call vc10projs,$(name)) +$(dist): + $(call dist-data,$(sources) $(headers) $(data_dist)) + $(call meta-automake,../template/Makefile.am) + $(call meta-vc9projs,../template/template,$(name)) + $(call meta-vc10projs,../template/template,$(name)) + +# Test. +# +$(test): $(driver) $(src_base)/test.std + $(call schema) + $(call message,test $<,$< --options-file $(dcf_root)/db.options \ +>$(out_base)/test.out) + $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) + $(call message,,rm -f $(out_base)/test.out) + +# Clean. +# +$(clean): \ + $(driver).o.clean \ + $(addsuffix .cxx.clean,$(cxx_obj)) \ + $(addsuffix .cxx.clean,$(cxx_od)) \ + $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean)) + $(call message,,rm -f $(out_base)/test.out) + +# Generated .gitignore. +# +ifeq ($(out_base),$(src_base)) +$(driver): | $(out_base)/.gitignore + +$(out_base)/.gitignore: files := driver $(genf) +$(clean): $(out_base)/.gitignore.clean + +$(call include,$(bld_root)/git/gitignore.make) +endif + +# How to. +# +$(call include,$(bld_root)/dist.make) +$(call include,$(bld_root)/meta/vc9proj.make) +$(call include,$(bld_root)/meta/vc10proj.make) +$(call include,$(bld_root)/meta/automake.make) + +$(call include,$(bld_root)/cxx/standard.make) # cxx_standard +ifdef cxx_standard +$(gen): odb_options += --std $(cxx_standard) +$(call include,$(odb_rules)) +endif + +$(call include,$(bld_root)/cxx/cxx-d.make) +$(call include,$(bld_root)/cxx/cxx-o.make) +$(call include,$(bld_root)/cxx/o-e.make) + +# Dependencies. +# +$(call import,$(src_root)/libcommon/makefile) diff --git a/common/circular/single/test.hxx b/common/circular/single/test.hxx new file mode 100644 index 0000000..8dd39fe --- /dev/null +++ b/common/circular/single/test.hxx @@ -0,0 +1,29 @@ +// file : common/circular/single/test.hxx +// copyright : Copyright (c) 2009-2012 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef TEST_HXX +#define TEST_HXX + +#include <odb/core.hxx> + +struct derived; + +#pragma db object polymorphic +struct base +{ + virtual ~base () {} + + #pragma db id + unsigned long id_; + + derived* d_; +}; + +#pragma db object +struct derived: base +{ + base* b_; +}; + +#endif // TEST_HXX diff --git a/common/circular/single/test.std b/common/circular/single/test.std new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/common/circular/single/test.std diff --git a/common/makefile b/common/makefile index 3ec0aa2..cb033a8 100644 --- a/common/makefile +++ b/common/makefile @@ -8,6 +8,8 @@ tests := \ auto \ blob \ callback \ +circular/single \ +circular/multiple \ composite \ composite-id \ const-object \ diff --git a/oracle/custom/makefile b/oracle/custom/makefile index 97cdb2c..66a0273 100644 --- a/oracle/custom/makefile +++ b/oracle/custom/makefile @@ -64,7 +64,7 @@ $(dist): # Test. # $(test): $(driver) $(src_base)/test.std - $(call schema, custom.sql) + $(call schema,$(src_base)/custom.sql $(out_base)/test.sql) $(call message,test $<,$< --options-file $(dcf_root)/db.options \ >$(out_base)/test.out) $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out) |