From 77f0b35782edcfad2c73cc75784b926c1e8b9a74 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 2 Sep 2022 21:22:18 +0300 Subject: Add odb and cli conditional build-time dependencies --- mod/buildfile | 79 ++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 57 insertions(+), 22 deletions(-) (limited to 'mod/buildfile') diff --git a/mod/buildfile b/mod/buildfile index 58a3caf..b5865cd 100644 --- a/mod/buildfile +++ b/mod/buildfile @@ -31,38 +31,73 @@ mod{brep}: {hxx ixx txx cxx}{* -module-options -{$libu_src}} \ libus{mod} ../libbrep/lib{brep} ../web/server/libus{web-server} \ $libs -{libue libus}{mod}: {hxx ixx cxx}{module-options} \ - {hxx ixx txx cxx}{+{$libu_src} } \ - $libs +{libue libus}{mod}: {hxx ixx txx cxx}{+{$libu_src}} $libs libus{mod}: ../web/xhtml/libus{xhtml} libue{mod}: ../web/xhtml/libue{xhtml} -# Generated options parser. +## Consumption build ($develop == false). +# + +# Use pregenerated versions in the consumption build. +# +{libue libus}{mod}: pregenerated/{hxx ixx cxx}{**}: include = (!$develop) + +if! $develop + cxx.poptions =+ "-I($src_base/pregenerated)" + +# Distribute pregenerated versions only in the consumption build. +# +pregenerated/{hxx ixx cxx}{*}: dist = (!$develop) + +# +## + +## Development build ($develop == true). # -if $cli.configured -{ - cli.cxx{module-options}: cli{module} +{libue libus}{mod}: {hxx ixx cxx}{module-options}: include = $develop + +if $develop + import! [metadata] cli = cli%exe{cli} + +# In the development build distribute regenerated +# {hxx ixx cxx}{module-options}, remapping their locations to the paths of the +# pregenerated versions (which are only distributed in the consumption build; +# see above). This way we make sure that the distributed files are always +# up-to-date. +# +<{hxx ixx cxx}{module-options}>: cli{module} $cli +{ # Set option prefix to the empty value to handle all unknown request # parameters uniformly with a single catch block. # - cli.options += --std c++11 -I $src_root --include-with-brackets \ ---include-prefix mod --guard-prefix MOD --generate-specifier \ ---cxx-prologue "#include " \ ---cli-namespace brep::cli --generate-file-scanner --option-length 46 \ ---generate-modifier --generate-description --option-prefix "" - - # Include the generated cli files into the distribution and don't remove - # them when cleaning in src (so that clean results in a state identical to - # distributed). - # - cli.cxx{*}: - { - dist = true - clean = ($src_root != $out_root) - } + options = --std c++11 -I $src_root --include-with-brackets \ + --include-prefix mod --guard-prefix MOD --generate-specifier \ + --cxx-prologue "#include " \ + --cli-namespace brep::cli --generate-file-scanner \ + --option-length 46 --generate-modifier --generate-description \ + --option-prefix "" --output-suffix "-options" } +% +if $develop +{{ + diag cli ($<[0]) + ($<[1]) $options -o $out_base/ $path($<[0]) + + if diff $src_base/pregenerated/mod/module-options.hxx $path($>[0]) >- && \ + diff $src_base/pregenerated/mod/module-options.ixx $path($>[1]) >- && \ + diff $src_base/pregenerated/mod/module-options.cxx $path($>[2]) >- + exit + end + + cp $path($>[0]) $src_base/pregenerated/mod/module-options.hxx + cp $path($>[1]) $src_base/pregenerated/mod/module-options.ixx + cp $path($>[2]) $src_base/pregenerated/mod/module-options.cxx +}} + +# +## # Don't install any of the module's headers. # -- cgit v1.1