diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2023-12-13 21:57:53 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-01-23 21:20:44 +0300 |
commit | fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 (patch) | |
tree | 6c8c1bfb5fe89f7378b92ac066b4ca8ecfd25228 /common/view/basics | |
parent | 02367faedb16b6186e8852de47e5b749dc48c2df (diff) |
Switch to build2
Diffstat (limited to 'common/view/basics')
-rw-r--r-- | common/view/basics/buildfile | 42 | ||||
-rw-r--r-- | common/view/basics/driver.cxx | 42 | ||||
-rw-r--r-- | common/view/basics/makefile | 117 | ||||
-rw-r--r-- | common/view/basics/test.hxx | 26 | ||||
-rw-r--r-- | common/view/basics/test.std | 0 | ||||
-rw-r--r-- | common/view/basics/testscript | 33 |
6 files changed, 126 insertions, 134 deletions
diff --git a/common/view/basics/buildfile b/common/view/basics/buildfile new file mode 100644 index 0000000..d9738a4 --- /dev/null +++ b/common/view/basics/buildfile @@ -0,0 +1,42 @@ +# file : common/view/basics/buildfile +# license : GNU GPL v2; see accompanying LICENSE file + +import libodb = libodb%lib{odb} + +libs = + +for db: $databases + import libs += libodb-$db%lib{odb-$db} + +import libs += lib{common} + +exe{driver}: {hxx cxx}{* -*-odb -*-odb-*} {hxx ixx cxx}{test-odb} testscript + +# Introduce the metadata library target to make sure the libodb library is +# resolved for the odb_compile ad hoc rule (see build/root.build for details). +# +libue{test-meta}: $libodb + +<{hxx ixx cxx}{test-odb}>: hxx{test} libue{test-meta} + +for db: $databases +{ + exe{driver}: {hxx ixx cxx}{test-odb-$db}: include = $multi + <{hxx ixx cxx}{test-odb-$db}>: hxx{test} libue{test-meta} +} + +exe{driver}: libue{test-meta} $libs + +# Specify the ODB custom options to be used by the odb_compile ad hoc rule +# (see build/root.build for details). +# +odb_options = --table-prefix t_view_b_ \ + --generate-schema \ + --generate-query \ + --generate-prepared + +cxx.poptions =+ "-I$out_base" "-I$src_base" + +# Testscript's run-time prerequisites. +# +exe{driver}: ../../../alias{database-client}: include = adhoc diff --git a/common/view/basics/driver.cxx b/common/view/basics/driver.cxx index d55e7c5..e2f611a 100644 --- a/common/view/basics/driver.cxx +++ b/common/view/basics/driver.cxx @@ -4,19 +4,21 @@ // Test view basics. // -#include <memory> // std::auto_ptr -#include <cassert> +#include <memory> // std::unique_ptr #include <iostream> #include <odb/database.hxx> #include <odb/transaction.hxx> -#include <common/common.hxx> -#include <common/config.hxx> // DATABASE_XXX +#include <libcommon/common.hxx> +#include <libcommon/config.hxx> // DATABASE_XXX #include "test.hxx" #include "test-odb.hxx" +#undef NDEBUG +#include <cassert> + using namespace std; using namespace odb::core; @@ -41,7 +43,7 @@ view1_check (odb::result<V>& r) template <typename V> void -view2_test (const auto_ptr<database>& db) +view2_test (const unique_ptr<database>& db) { typedef odb::query<V> query; typedef odb::result<V> result; @@ -76,12 +78,12 @@ view2_test (const auto_ptr<database>& db) } { - auto_ptr<V> v (db->query_one<V> ()); + unique_ptr<V> v (db->query_one<V> ()); assert (v->count == 4); } { - auto_ptr<V> v; + unique_ptr<V> v; if (db->id () != odb::id_oracle) v.reset (db->query_one<V> ("age < 31")); else @@ -90,7 +92,7 @@ view2_test (const auto_ptr<database>& db) } { - auto_ptr<V> v (db->query_one<V> (query::age < 31)); + unique_ptr<V> v (db->query_one<V> (query::age < 31)); assert (v->count == 2); } @@ -99,7 +101,7 @@ view2_test (const auto_ptr<database>& db) template <typename V> void -view4_test (const auto_ptr<database>& db) +view4_test (const unique_ptr<database>& db) { typedef odb::query<V> query; typedef odb::result<V> result; @@ -162,7 +164,7 @@ view4_test (const auto_ptr<database>& db) template <typename V> void -view6_test (const auto_ptr<database>& db, const odb::query<V>& q) +view6_test (const unique_ptr<database>& db, const odb::query<V>& q) { typedef odb::result<V> result; typedef typename result::iterator iterator; @@ -193,7 +195,7 @@ main (int argc, char* argv[]) { try { - auto_ptr<database> db (create_database (argc, argv)); + unique_ptr<database> db (create_database (argc, argv)); // // @@ -309,7 +311,7 @@ main (int argc, char* argv[]) // No native parameter support in dynamic multi-database mode. // -#ifndef DATABASE_COMMON +#ifndef MULTI_DATABASE { typedef odb::query<view1b> query; @@ -487,7 +489,7 @@ main (int argc, char* argv[]) // No native parameter support in dynamic multi-database mode. // -#ifndef DATABASE_COMMON +#ifndef MULTI_DATABASE view6_test<view6c> ( #ifndef DATABASE_ORACLE db, "e.name = " + odb::query<view6c>::_val ("Simple Tech, Inc")); @@ -719,7 +721,12 @@ main (int argc, char* argv[]) t.commit (); } -#if !defined(DATABASE_SQLITE) && !defined(DATABASE_COMMON) + // @@ BUILD2 Also disable for DATABASE_MYSQL and DATABASE_PGSQL (see + // vright definition for details). + // +#if !defined(DATABASE_MYSQL) && \ + !defined(DATABASE_SQLITE) && \ + !defined(DATABASE_PGSQL) { typedef odb::query<vright> query; typedef odb::result<vright> result; @@ -736,9 +743,12 @@ main (int argc, char* argv[]) } #endif -#if !defined(DATABASE_MYSQL) && \ + // @@ BUILD2 Also disable for DATABASE_PGSQL (see vfull definition for + // details). + // +#if !defined(DATABASE_MYSQL) && \ !defined(DATABASE_SQLITE) && \ - !defined(DATABASE_COMMON) + !defined(DATABASE_PGSQL) { typedef odb::query<vfull> query; typedef odb::result<vfull> result; diff --git a/common/view/basics/makefile b/common/view/basics/makefile deleted file mode 100644 index eafe550..0000000 --- a/common/view/basics/makefile +++ /dev/null @@ -1,117 +0,0 @@ -# file : common/view/basics/makefile -# license : GNU GPL v2; see accompanying LICENSE file - -include $(dir $(lastword $(MAKEFILE_LIST)))../../../build/bootstrap.make - -cxx_tun := driver.cxx -odb_hdr := test.hxx -genf := $(call odb-gen,$(odb_hdr)) -gen := $(addprefix $(out_base)/,$(genf)) -cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o)) $(filter %.o,$(gen:.cxx=.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 - -# 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) - -$(gen): $(odb) -$(gen): odb := $(odb) -$(gen) $(dist): export odb_options += --generate-schema --generate-query \ ---generate-prepared --table-prefix t_view_b_ -$(gen): cpp_options := -I$(src_base) -$(gen): $(common.l.cpp-options) - -ifneq ($(db_id),common) -$(gen): odb_options += --database $(db_id) -else -$(gen): odb_options += --multi-database dynamic -endif - -$(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): sources := $(cxx_tun) -$(dist): headers := $(odb_hdr) -$(dist): data_dist := test.std -$(dist): export name := $(name) -$(dist): export extra_dist := $(data_dist) $(call vc8projs,$(name)) \ -$(call vc9projs,$(name)) $(call vc10projs,$(name)) $(call vc11projs,$(name)) \ -$(call vc12projs,$(name)) -$(dist): - $(call dist-data,$(sources) $(headers) $(data_dist)) - $(call meta-automake,../../template/Makefile.am) - $(call meta-vc8projs,../../template/template,$(name)) - $(call meta-vc9projs,../../template/template,$(name)) - $(call meta-vc10projs,../../template/template,$(name)) - $(call meta-vc11projs,../../template/template,$(name)) - $(call meta-vc12projs,../../template/template,$(name)) - -# Test. -# -ifneq ($(db_id),common) -$(eval $(call test-rule)) -else -$(foreach d,$(databases),$(eval $(call test-rule,$d))) -endif - -# Clean. -# -$(clean): \ - $(driver).o.clean \ - $(addsuffix .cxx.clean,$(cxx_obj)) \ - $(addsuffix .cxx.clean,$(cxx_od)) \ - $(addsuffix .hxx.clean,$(filter %.cxx,$(gen))) - $(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/vc8proj.make) -$(call include,$(bld_root)/meta/vc9proj.make) -$(call include,$(bld_root)/meta/vc10proj.make) -$(call include,$(bld_root)/meta/vc11proj.make) -$(call include,$(bld_root)/meta/vc12proj.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/view/basics/test.hxx b/common/view/basics/test.hxx index 66bf86c..130bcd4 100644 --- a/common/view/basics/test.hxx +++ b/common/view/basics/test.hxx @@ -543,7 +543,18 @@ namespace test2 odb::nullable<int> id2; }; -#if !defined(ODB_DATABASE_SQLITE) && !defined(ODB_DATABASE_COMMON) + // @@ BUILD2 Also disable for ODB_DATABASE_MYSQL and ODB_DATABASE_PGSQL, + // otherwise we end up with the following error: + // + // test-odb-mysql.hxx:3202:20: error: invalid use of incomplete type ‘class odb::access::view_traits<test2::vright>’ + // 3202 | public access::view_traits< ::test2::vright > + // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // +//#if !defined(ODB_DATABASE_SQLITE) && !defined(ODB_DATABASE_COMMON) +#if !defined(ODB_DATABASE_MYSQL) && \ + !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_PGSQL) && \ + !defined(ODB_DATABASE_COMMON) #pragma db view object(obj2 = o2) object(obj1 = o1 right: o2::n == o1::n) struct vright @@ -554,8 +565,21 @@ namespace test2 #endif + // @@ BUILD2 Also disable for ODB_DATABASE_PGSQL, otherwise we end up with the + // following error: + // + // test-odb-pgsql.hxx:3325:20: error: invalid use of incomplete type ‘class odb::access::view_traits<test2::vfull>’ + // 3325 | public access::view_traits< ::test2::vfull > + // | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + // +/* +#if !defined(ODB_DATABASE_MYSQL) && \ + !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_COMMON) +*/ #if !defined(ODB_DATABASE_MYSQL) && \ !defined(ODB_DATABASE_SQLITE) && \ + !defined(ODB_DATABASE_PGSQL) && \ !defined(ODB_DATABASE_COMMON) #pragma db view object(obj1 = o1) object(obj2 = o2 full: o1::n == o2::n) diff --git a/common/view/basics/test.std b/common/view/basics/test.std deleted file mode 100644 index e69de29..0000000 --- a/common/view/basics/test.std +++ /dev/null diff --git a/common/view/basics/testscript b/common/view/basics/testscript new file mode 100644 index 0000000..faa8408 --- /dev/null +++ b/common/view/basics/testscript @@ -0,0 +1,33 @@ +# file : common/view/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} |