From d8140aad76787702070ed8f00944ac417c90a525 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 11 Jun 2020 16:06:35 +0300 Subject: Use ad hoc recipe for database mapping code generating --- bdep/buildfile | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) 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 '" \ + --hxx-prologue "'#include '" \ + --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 '" +} + # Unit tests. # exe{*.test}: -- cgit v1.1