aboutsummaryrefslogtreecommitdiff
path: root/common/include
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2023-12-13 21:57:53 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2024-01-23 21:20:44 +0300
commitfc3fb39c90ab7fe5fccbe3f3bc0eb2645157bb96 (patch)
tree6c8c1bfb5fe89f7378b92ac066b4ca8ecfd25228 /common/include
parent02367faedb16b6186e8852de47e5b749dc48c2df (diff)
Switch to build2
Diffstat (limited to 'common/include')
-rw-r--r--common/include/.gitignore17
-rw-r--r--common/include/buildfile51
-rw-r--r--common/include/driver.cxx6
-rw-r--r--common/include/makefile83
-rw-r--r--common/include/test.std0
-rw-r--r--common/include/testscript31
6 files changed, 103 insertions, 85 deletions
diff --git a/common/include/.gitignore b/common/include/.gitignore
new file mode 100644
index 0000000..d52f166
--- /dev/null
+++ b/common/include/.gitignore
@@ -0,0 +1,17 @@
+# ODB-generated files.
+#
+obj1-odb.?xx
+obj1-odb-*.?xx
+obj2-odb.?xx
+obj2-odb-*.?xx
+obj3-odb.?xx
+obj3-odb-*.?xx
+
+test1-odb.?xx
+test1-odb-*.?xx
+test2-odb.?xx
+test2-odb-*.?xx
+test3-odb.?xx
+test3-odb-*.?xx
+test4-odb.?xx
+test4-odb-*.?xx
diff --git a/common/include/buildfile b/common/include/buildfile
new file mode 100644
index 0000000..6db878c
--- /dev/null
+++ b/common/include/buildfile
@@ -0,0 +1,51 @@
+# file : common/include/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}
+
+hs = obj1 obj2 obj3 test1 test2 test3 test4
+
+exe{driver}: {hxx cxx}{* -*-odb -*-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
+
+for h: $hs
+{
+ exe{driver}: {hxx ixx cxx}{$h-odb}
+
+ <{hxx ixx cxx}{$h-odb}>: hxx{$h} libue{test-meta}
+
+ for db: $databases
+ {
+ exe{driver}: {hxx ixx cxx}{$h-odb-$db}: include = $multi
+ <{hxx ixx cxx}{$h-odb-$db}>: hxx{$h} 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). Also see driver.cxx for the details on
+# the -I options usage.
+#
+odb_options = --table-prefix include_ \
+ "-I$out_base" \
+ "-I$src_base/.." \
+ "-I$src_base/../.."
+
+cxx.poptions =+ "-I$out_base" "-I$src_base" \
+ "-I$out_base/../.." "-I$src_base/../.."
+
+# Testscript's run-time prerequisites.
+#
+exe{driver}: ../../alias{database-client}: include = adhoc
diff --git a/common/include/driver.cxx b/common/include/driver.cxx
index 935d285..561746a 100644
--- a/common/include/driver.cxx
+++ b/common/include/driver.cxx
@@ -11,13 +11,12 @@
//
#include <memory>
-#include <cassert>
#include <iostream>
#include <odb/exceptions.hxx>
#include <odb/transaction.hxx>
-#include <common/common.hxx>
+#include <libcommon/common.hxx>
#include "test1.hxx"
#include "test1-odb.hxx"
@@ -31,6 +30,9 @@
#include "test4.hxx"
#include "test4-odb.hxx"
+#undef NDEBUG
+#include <cassert>
+
using namespace std;
using namespace odb::core;
diff --git a/common/include/makefile b/common/include/makefile
deleted file mode 100644
index 2ee3f38..0000000
--- a/common/include/makefile
+++ /dev/null
@@ -1,83 +0,0 @@
-# file : common/include/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
-
-cxx_tun := driver.cxx
-odb_hdr := obj1.hxx obj2.hxx obj3.hxx test1.hxx test2.hxx test3.hxx test4.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) \
--I$(out_base)/../.. -I$(src_base)/../..
-$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
-
-$(gen): $(odb)
-$(gen): odb := $(odb)
-$(gen): odb_options += --database $(db_id) --table-prefix include_
-$(gen): cpp_options := -I$(out_base) -I$(src_base)/.. -I$(src_base)/../..
-$(gen): $(common.l.cpp-options)
-
-$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
-
-# Alias for default target.
-#
-$(out_base)/: $(driver)
-
-# Dist: not supported.
-#
-$(dist):
-
-# Test.
-#
-$(eval $(call test-schemaless-rule))
-
-# 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)/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/include/test.std b/common/include/test.std
deleted file mode 100644
index e69de29..0000000
--- a/common/include/test.std
+++ /dev/null
diff --git a/common/include/testscript b/common/include/testscript
new file mode 100644
index 0000000..089f7a1
--- /dev/null
+++ b/common/include/testscript
@@ -0,0 +1,31 @@
+# file : common/include/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+.include ../../database-options.testscript
+
+: mysql
+:
+if $mysql
+{
+ .include ../../mysql.testscript
+
+ $*
+}
+
+: sqlite
+:
+if $sqlite
+{
+ .include ../../sqlite.testscript
+
+ $* &!odb-test.db
+}
+
+: pgsql
+:
+if $pgsql
+{
+ .include ../../pgsql.testscript
+
+ $*
+}