aboutsummaryrefslogtreecommitdiff
path: root/build/bootstrap.make
diff options
context:
space:
mode:
Diffstat (limited to 'build/bootstrap.make')
-rw-r--r--build/bootstrap.make107
1 files changed, 92 insertions, 15 deletions
diff --git a/build/bootstrap.make b/build/bootstrap.make
index 178f2aa..7d5b84e 100644
--- a/build/bootstrap.make
+++ b/build/bootstrap.make
@@ -27,21 +27,64 @@ def_goal := $(.DEFAULT_GOAL)
#
$(call include,$(bld_root)/cxx/configuration.make)
+# Databases.
+#
+databases := mysql sqlite pgsql oracle mssql
+$(dist): databases := $(databases)
+
# Aliases
#
-.PHONY: $(out_base)/ \
- $(out_base)/.test \
- $(out_base)/.dist \
- $(out_base)/.clean
+default := $(out_base)/
+driver := $(out_base)/driver
+test := $(out_base)/.test
+dist := $(out_base)/.dist
+clean := $(out_base)/.clean
+
+.PHONY: $(default) \
+ $(test) \
+ $(dist) \
+ $(clean)
+
+ifeq ($(db_id),common)
+define db-test-target
+test_$1 := $$(out_base)/.test-$1
+.PHONY: $$(test_$1)
+$$(test): $$(test_$1)
-ifdef %interactive%
+endef
+$(foreach d,$(databases),$(eval $(call db-test-target,$d)))
+
+define db-test-dir
+$$(test_$1): $$(addprefix $$(out_base)/,$$(addsuffix /.test-$1,$2))
+
+endef
+endif
+ifdef %interactive%
.PHONY: test dist clean
+test: $(test)
+dist: $(dist)
+clean: $(clean)
-test: $(out_base)/.test
-dist: $(out_base)/.dist
-clean: $(out_base)/.clean
+ifeq ($(db_id),common)
+define db-test-alias
+.PHONY: test-$1
+test-$1: $$(test_$1)
+endef
+$(foreach d,$(databases),$(eval $(call db-test-alias,$d)))
+endif
+endif
+
+# Return the list of ODB-generated files given a list of header files.
+#
+ifdef db_id
+ifneq ($(db_id),common)
+odb-gen = $(foreach f,$(1:.hxx=),$(addprefix $f,-odb.hxx -odb.ixx -odb.cxx .sql))
+else
+odb-gen = $(foreach f,$(1:.hxx=),$(addprefix $f, -odb.hxx -odb.ixx -odb.cxx \
+$(foreach d,$(databases),-odb-$d.hxx -odb-$d.ixx -odb-$d.cxx -$d.sql)))
+endif
endif
# By default the ODB header is called test.hxx.
@@ -50,13 +93,50 @@ $(out_base)/.dist: export odb_header_stem := test
# Database schema creation.
#
-ifeq ($(filter $(db_id),sqlite),)
-$(out_base)/.test: schema-body = \
-$(call message,sql $$1,$(dcf_root)/$(db_id)-driver $$1,$1)$(literal_newline)$(literal_tab)
+ifneq ($(db_id),sqlite)
+$(out_base)/.test $(addprefix $(out_base)/.test-,$(databases)): schema-body = \
+$(call message,sql $$1,$(dcf_root)/$1-driver $$1,$2)$(literal_newline)$(literal_tab)
+
+ifneq ($(db_id),common)
$(out_base)/.test: schema = \
-$(foreach s,$(if $1,$1,$(out_base)/test.sql),$(call schema-body,$s))@:
+$(foreach s,$(if $1,$1,$(out_base)/test.sql),$(call schema-body,$(db_id),$s))@:
+else
+define db-schema
+$$(out_base)/.test-$1: schema-$1 = \
+$$(foreach s,$$(if $$1,$$(filter %-$1.sql,$$1),$$(out_base)/test-$1.sql),$$(call schema-body,$1,$$s))@:
+
+endef
+$(foreach d,$(filter-out sqlite,$(databases)),$(eval $(call db-schema,$d)))
+endif
endif
+# Test rule templates.
+#
+
+# $1 database name in the multi-database mode and empty otherwise
+#
+define test-schemaless-rule
+$$(test$(if $1,_$1)): $$(driver) $$(src_base)/test.std
+ $$(call message,test$(if $1, [$1]) $$<,$$< $1 --options-file \
+$$(dcf_root)/$(if $1,$1,$(db_id)).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)
+
+endef
+
+# $1 database name in the multi-database mode and empty otherwise
+# $2 optional list of schema files, by default test.sql
+#
+define test-rule
+$$(test$(if $1,_$1)): $$(driver) $$(src_base)/test.std
+ $$(call schema$(if $1,-$1),$2)
+ $$(call message,test$(if $1, [$1]) $$<,$$< $1 --options-file \
+$$(dcf_root)/$(if $1,$1,$(db_id)).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)
+
+endef
+
# Dist setup.
#
ifneq ($(filter $(MAKECMDGOALS),dist),)
@@ -67,9 +147,6 @@ ifeq ($(dist_prefix),)
$(error dist_prefix is not set)
endif
-databases := mysql sqlite pgsql oracle mssql
-$(dist): databases := $(databases)
-
# $1 project template without the -vcN.vc[x]proj suffix.
# $2 project name without the -vcN.vc[x]proj suffix.
#