From fc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 13 Dec 2023 21:57:53 +0300 Subject: Switch to build2 --- common/query/basics/buildfile | 42 ++++++++++++ common/query/basics/driver.cxx | 28 ++++---- common/query/basics/makefile | 117 -------------------------------- common/query/basics/test.hxx | 6 -- common/query/basics/test.std | 112 ------------------------------ common/query/basics/testscript | 150 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 207 insertions(+), 248 deletions(-) create mode 100644 common/query/basics/buildfile delete mode 100644 common/query/basics/makefile delete mode 100644 common/query/basics/test.std create mode 100644 common/query/basics/testscript (limited to 'common/query/basics') diff --git a/common/query/basics/buildfile b/common/query/basics/buildfile new file mode 100644 index 0000000..e38e6fe --- /dev/null +++ b/common/query/basics/buildfile @@ -0,0 +1,42 @@ +# file : common/query/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_query_basics_ \ + --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/query/basics/driver.cxx b/common/query/basics/driver.cxx index 86bae4b..73b81d2 100644 --- a/common/query/basics/driver.cxx +++ b/common/query/basics/driver.cxx @@ -4,19 +4,21 @@ // Test basic query support. // -#include // std::auto_ptr -#include +#include // std::unique_ptr #include #include #include -#include // DATABASE_XXX -#include +#include // DATABASE_XXX +#include #include "test.hxx" #include "test-odb.hxx" +#undef NDEBUG +#include + using namespace std; using namespace odb::core; @@ -25,7 +27,7 @@ print (result& r) { for (result::iterator i (r.begin ()); i != r.end (); ++i) { - auto_ptr o (i.load ()); + unique_ptr o (i.load ()); cout << *o << endl; } cout << endl; @@ -46,7 +48,7 @@ main (int argc, char* argv[]) try { - auto_ptr db (create_database (argc, argv)); + unique_ptr db (create_database (argc, argv)); odb::database_id db_id (db->id ()); typedef odb::query query; @@ -76,7 +78,7 @@ main (int argc, char* argv[]) // Compilation tests. // -#ifndef DATABASE_COMMON +#ifndef MULTI_DATABASE if (false) { string name; @@ -164,7 +166,7 @@ main (int argc, char* argv[]) const char* name = "Doe"; -#if defined(DATABASE_COMMON) +#if defined(MULTI_DATABASE) result r ( db->query ( query::age >= query::_val (30) && @@ -195,7 +197,7 @@ main (int argc, char* argv[]) string name; unsigned short age; -#if defined(DATABASE_COMMON) +#if defined(MULTI_DATABASE) query q (query::age >= query::_ref (age) && query::last_name == query::_ref (name)); #elif defined(DATABASE_ORACLE) @@ -249,7 +251,7 @@ main (int argc, char* argv[]) //db->query (query::age == query::_ref (name)); db->query (query::last_name == "Doe"); db->query (query::last_name == name); -#ifndef DATABASE_COMMON +#ifndef MULTI_DATABASE db->query (query::last_name == query::_val ("Doe")); #endif db->query (query::last_name == query::_val (name)); @@ -450,7 +452,7 @@ main (int argc, char* argv[]) assert (i != r.end ()); { - auto_ptr joe (db->load (3)); + unique_ptr joe (db->load (3)); } { @@ -467,7 +469,7 @@ main (int argc, char* argv[]) // Overwrite object image again. // - auto_ptr joe (db->load (3)); + unique_ptr joe (db->load (3)); person p; i.load (p); assert (p.last_name_ == "Doe"); @@ -499,7 +501,7 @@ main (int argc, char* argv[]) // Oracle does not support LOB comparisons. // -#ifndef DATABASE_ORACLE +#if defined(MULTI_DATABASE) || !defined(DATABASE_ORACLE) if (db_id != odb::id_oracle) { r = db->query (query::public_key == key2); diff --git a/common/query/basics/makefile b/common/query/basics/makefile deleted file mode 100644 index b1749e7..0000000 --- a/common/query/basics/makefile +++ /dev/null @@ -1,117 +0,0 @@ -# file : common/query/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_query_basics_ -$(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/query/basics/test.hxx b/common/query/basics/test.hxx index 22a8d32..239f6d6 100644 --- a/common/query/basics/test.hxx +++ b/common/query/basics/test.hxx @@ -4,8 +4,6 @@ #ifndef TEST_HXX #define TEST_HXX -#include // HAVE_CXX11 - #include #include #include @@ -56,11 +54,7 @@ struct person std::string first_name_; #pragma db column ("middle") null -#ifdef HAVE_CXX11 std::unique_ptr middle_name_; -#else - std::auto_ptr middle_name_; -#endif #pragma db column ("last") std::string last_name_; diff --git a/common/query/basics/test.std b/common/query/basics/test.std deleted file mode 100644 index d420dc4..0000000 --- a/common/query/basics/test.std +++ /dev/null @@ -1,112 +0,0 @@ -test 001 -John Doe 30 married -Jane Doe 29 married -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single -test 002 -Jane Doe 29 married -John Doe 30 married -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -test 003 -John Doe 30 married - -test 004 -John Doe 30 married - -test 005 -John Doe 30 married - -Joe Squeaky Dirt 31 single - -test 006 -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -test 007 -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -test 008 -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single - -John Doe 30 married -Jane Doe 29 married - -test 009 -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -John Doe 30 married -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -test 010 -Jane Doe 29 married - -John Doe 30 married -Jane Doe 29 married -Joe Squeaky Dirt 31 single - -Jane Doe 29 married - -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -Jane Doe 29 married -John Doe 30 married - -test 011 -John Doe 30 married -Jane Doe 29 married - -John Doe 30 married -Jane Doe 29 married -Joe Squeaky Dirt 31 single - -test 012 -Johansen J Johansen 32 single - -test 013 -Joe Squeaky Dirt 31 single - -test 014 -test 015 -John Doe 30 married -Jane Doe 29 married - -test 016 -test 017 -test 018 -test 019 -test 020 -John Doe 30 married -Joe Squeaky Dirt 31 single -Johansen J Johansen 32 single - -Jane Doe 29 married - - -Jane Doe 29 married - diff --git a/common/query/basics/testscript b/common/query/basics/testscript new file mode 100644 index 0000000..9086b66 --- /dev/null +++ b/common/query/basics/testscript @@ -0,0 +1,150 @@ +# file : common/query/basics/testscript +# license : GNU GPL v2; see accompanying LICENSE file + +.include ../../../database-options.testscript + ++cat <=output + test 001 + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + test 002 + Jane Doe 29 married + John Doe 30 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 003 + John Doe 30 married + + test 004 + John Doe 30 married + + test 005 + John Doe 30 married + + Joe Squeaky Dirt 31 single + + test 006 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 007 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 008 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + + John Doe 30 married + Jane Doe 29 married + + test 009 + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + John Doe 30 married + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + test 010 + Jane Doe 29 married + + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + + Jane Doe 29 married + + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + Jane Doe 29 married + John Doe 30 married + + test 011 + John Doe 30 married + Jane Doe 29 married + + John Doe 30 married + Jane Doe 29 married + Joe Squeaky Dirt 31 single + + test 012 + Johansen J Johansen 32 single + + test 013 + Joe Squeaky Dirt 31 single + + test 014 + test 015 + John Doe 30 married + Jane Doe 29 married + + test 016 + test 017 + test 018 + test 019 + test 020 + John Doe 30 married + Joe Squeaky Dirt 31 single + Johansen J Johansen 32 single + + Jane Doe 29 married + + + Jane Doe 29 married + + EOI + +test.redirects += >>>../output + +: mysql +: +if $mysql +{ + .include ../../../mysql.testscript + + $create_schema; + $* +} + +: sqlite +: +if $sqlite +{ + .include ../../../sqlite.testscript + + $* +} + +: pgsql +: +if $pgsql +{ + .include ../../../pgsql.testscript + + $create_schema; + $* +} -- cgit v1.1