aboutsummaryrefslogtreecommitdiff
path: root/common/changelog
diff options
context:
space:
mode:
Diffstat (limited to 'common/changelog')
-rw-r--r--common/changelog/.gitignore3
-rw-r--r--common/changelog/buildfile30
-rw-r--r--common/changelog/makefile101
-rw-r--r--common/changelog/testscript66
4 files changed, 99 insertions, 101 deletions
diff --git a/common/changelog/.gitignore b/common/changelog/.gitignore
new file mode 100644
index 0000000..5352a2b
--- /dev/null
+++ b/common/changelog/.gitignore
@@ -0,0 +1,3 @@
+# Generate ODB options file.
+#
+odb.options
diff --git a/common/changelog/buildfile b/common/changelog/buildfile
new file mode 100644
index 0000000..04e0685
--- /dev/null
+++ b/common/changelog/buildfile
@@ -0,0 +1,30 @@
+# file : common/changelog/buildfile
+# license : GNU GPL v2; see accompanying LICENSE file
+
+import libodb = libodb%lib{odb}
+
+./: file{odb.options} xml{*} testscript
+
+# Introduce the metadata library target to make sure the libodb library is
+# resolved for the below ad hoc recipe.
+#
+libue{test-meta}: $libodb
+
+file{odb.options}: libue{test-meta}
+{{
+ pops = $cxx.lib_poptions($<[0])
+ depdb hash $pops
+
+ f = $path($>[0])
+ rm -f $f
+
+ for o: $pops
+ echo $o >+$f
+ end
+}}
+
+# Testscript's run-time prerequisites.
+#
+testscript@./: test = $odb
+
+./: $odb: clean = false
diff --git a/common/changelog/makefile b/common/changelog/makefile
deleted file mode 100644
index 99f6333..0000000
--- a/common/changelog/makefile
+++ /dev/null
@@ -1,101 +0,0 @@
-# file : common/changelog/makefile
-# license : GNU GPL v2; see accompanying LICENSE file
-
-include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
-
-odb_hdr := \
-model.hxx \
-add-table.hxx \
-drop-table.hxx \
-add-column.hxx \
-drop-column.hxx \
-alter-column.hxx \
-add-index.hxx \
-drop-index.hxx \
-add-foreign-key.hxx \
-drop-foreign-key.hxx
-genf := $(call odb-gen,$(odb_hdr))
-gen := $(addprefix $(out_base)/,$(genf))
-
-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.
-#
-$(default):
-
-$(gen): $(odb) FORCE # Force regeneration even if up to date.
-$(gen): odb := $(odb)
-$(gen): export odb_options += --database $(db_id) --generate-schema-only \
---schema-format sql --suppress-migration --changelog-dir $(out_base)
-$(gen): cpp_options := -I$(src_base)
-$(gen): $(common.l.cpp-options)
-
-ifdef STEP
-
-ifeq ($(STEP),1)
-$(gen): cpp_options += -DBVER=1 -DCVER=1 # Initialize.
-$(gen): odb_options += --init-changelog # Suppress notice.
-else ifeq ($(STEP),2)
-$(gen): cpp_options += -DBVER=1 -DCVER=2 # Diff.
-else ifeq ($(STEP),3)
-$(gen): cpp_options += -DBVER=2 -DCVER=3 # Patch (via rewind).
-else
-$(error unexpected STEP value $(STEP)
-endif
-
-$(default): $(gen)
-else
-$(default):
-endif
-
-# Dist: not supported.
-#
-$(dist):
-
-# Test.
-#
-$(test): tests := $(odb_hdr:.hxx=)
-$(test): diff = $(call message,,diff -u $(src_base)/$1-$(db_id)-$2.xml \
-$(out_base)/$1.xml)$(literal_newline)$(literal_tab)
-$(test): | $(out_base)/.
- $(call message,,rm -f $(addprefix $(out_base)/,$(addsuffix .xml,$(tests))))
- $(call message,,$(MAKE) --no-print-directory -C $(out_base) -f $(src_base)/makefile STEP=1)
- $(call message,,$(MAKE) --no-print-directory -C $(out_base) -f $(src_base)/makefile STEP=2)
- $(foreach t,$(tests),$(call diff,$t,diff))
- $(call message,,$(MAKE) --no-print-directory -C $(out_base) -f $(src_base)/makefile STEP=3)
- $(foreach t,$(tests),$(call diff,$t,patch))
-
-# Clean.
-#
-$(clean): changelogs := $(addprefix $(out_base)/,$(odb_hdr:.hxx=.xml))
-$(clean): $(addsuffix .hxx.clean,$(filter %.cxx,$(gen)))
- $(call message,,rm -f $(changelogs))
-
-# Generated .gitignore.
-#
-ifeq ($(out_base),$(src_base))
-$(default) $(test): | $(out_base)/.gitignore
-
-$(out_base)/.gitignore: files := $(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
-
-# Dependencies.
-#
-$(call import,$(src_root)/libcommon/makefile)
diff --git a/common/changelog/testscript b/common/changelog/testscript
new file mode 100644
index 0000000..9368938
--- /dev/null
+++ b/common/changelog/testscript
@@ -0,0 +1,66 @@
+# file : common/changelog/testscript
+# license : GNU GPL v2; see accompanying LICENSE file
+
+headers = [paths] $path_search($src_base/*.hxx)
+
+odb_options = --generate-schema-only \
+ --schema-format sql \
+ --suppress-migration \
+ --options-file $out_base/odb.options
+
+: mysql
+:
+if $mysql
+{
+ odb_options += --database 'mysql' --changelog-dir $~
+
+ for h: $headers
+ n = $base($leaf($h))
+
+ $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql
+
+ $* $odb_options -DBVER=1 -DCVER=2 $h
+ diff $src_base/$n-mysql-diff.xml $(n).xml
+
+ $* $odb_options -DBVER=2 -DCVER=3 $h
+ diff $src_base/$n-mysql-patch.xml $(n).xml
+ end
+}
+
+: sqlite
+:
+if $sqlite
+{
+ odb_options += --database 'sqlite' --changelog-dir $~
+
+ for h: $headers
+ n = $base($leaf($h))
+
+ $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql
+
+ $* $odb_options -DBVER=1 -DCVER=2 $h
+ diff $src_base/$n-sqlite-diff.xml $(n).xml
+
+ $* $odb_options -DBVER=2 -DCVER=3 $h
+ diff $src_base/$n-sqlite-patch.xml $(n).xml
+ end
+}
+
+: pgsql
+:
+if $pgsql
+{
+ odb_options += --database 'pgsql' --changelog-dir $~
+
+ for h: $headers
+ n = $base($leaf($h))
+
+ $* $odb_options -DBVER=1 -DCVER=1 --init-changelog $h &$(n).xml &$(n).sql
+
+ $* $odb_options -DBVER=1 -DCVER=2 $h
+ diff $src_base/$n-pgsql-diff.xml $(n).xml
+
+ $* $odb_options -DBVER=2 -DCVER=3 $h
+ diff $src_base/$n-pgsql-patch.xml $(n).xml
+ end
+}