aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-06-11 16:06:35 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-06-11 16:06:35 +0300
commitd8140aad76787702070ed8f00944ac417c90a525 (patch)
tree3b79f4ead049d2e3cee80abf1a5023f089b7566b
parenta78d499bd30d8d18e6170e959c66754aee8c544b (diff)
Use ad hoc recipe for database mapping code generatingadhoc-recipe
-rw-r--r--bdep/buildfile44
1 files changed, 43 insertions, 1 deletions
diff --git a/bdep/buildfile b/bdep/buildfile
index 605ebcd..dfae70e 100644
--- a/bdep/buildfile
+++ b/bdep/buildfile
@@ -8,11 +8,19 @@
define xml: file
xml{*}: extension = xml
+import libodb = libodb%lib{odb}
+
import libs = libbpkg%lib{bpkg}
import libs += libbutl%lib{butl}
-import libs += libodb%lib{odb}
+libs += $libodb
import libs += libodb-sqlite%lib{odb-sqlite}
+# Import the odb program only if it is present as a project or in the
+# system. This way a distribution that includes pre-generated files can be
+# built without installing odb.
+#
+import? [metadata] odb = odb%exe{odb}
+
# @@ Why don't we generate these with wildcard patterns (and rules below with
# a for-loop)?
#
@@ -54,6 +62,40 @@ libue{bdep}: {hxx ixx txx cxx}{** -bdep \
hxx{version}: in{version} $src_root/manifest
+# Generate the database mapping source files if the odb program is imported
+# and assume they are present in the source directory otherwise (the package
+# distribution case).
+#
+# Note that we include all the generated files into the distribution and don't
+# remove them when cleaning in src (so that clean results in a state identical
+# to distributed).
+#
+# "-I$out_root"
+if ($odb != [null])
+{
+ print AAAAAAAAAAAA $($libodb:cxx.export.poptions)
+
+ odb_options = \
+ -DLIBODB_BUILD2 -DLIBODB_SQLITE_BUILD2 \
+ -d sqlite --std c++14 --generate-query \
+ --odb-epilogue "'#include <bdep/wrapper-traits.hxx>'" \
+ --hxx-prologue "'#include <bdep/wrapper-traits.hxx>'" \
+ --include-with-brackets --include-prefix bdep --guard-prefix BDEP \
+ --sqlite-override-null
+
+ <{hxx ixx cxx}{project-odb}>: hxx{project} $odb
+ {
+ odb_options += --generate-schema
+
+ dist = true
+ clean = ($src_root != $out_root)
+ }
+ {{
+ $odb $odb_options $path($<[0])
+ }}
+# --hxx-prologue "'#include <bdep/value-traits.hxx>'"
+}
+
# Unit tests.
#
exe{*.test}: