From 2181ec73117f2e18cc622ead6256c8104b631214 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 6 Jun 2020 22:42:16 +0300 Subject: Use ad hoc recipe for parsing code and documentation generating The overall approach is to store pre-generated bootstrap options.?xx and cli.{1,xhtml} and automatically update them in the development build (config.cli.develop=true). See README.md in the root of the repository for details. --- cli/cli/buildfile | 136 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 96 insertions(+), 40 deletions(-) (limited to 'cli/cli/buildfile') diff --git a/cli/cli/buildfile b/cli/cli/buildfile index 2385a7d..dc5d75b 100644 --- a/cli/cli/buildfile +++ b/cli/cli/buildfile @@ -15,63 +15,119 @@ exe{cli}: cli.checksum = $version } -libue{cli}: {hxx ixx txx cxx}{** -cli -version -options -**.test...} \ - {hxx}{version} {hxx ixx cxx}{options} \ - $libs +hdr = {hxx ixx txx}{* -cli -version -options -*.test...} +src = cxx{* -cli -version -options -*.test...} + +all_s = semantics/{hxx ixx txx cxx}{*} +all_t = traversal/{hxx ixx txx cxx}{*} + +libue{cli}: $hdr $src $all_s $all_t {hxx}{version} $libs hxx{version}: in{version} $src_root/manifest -# Unit tests. +# Build options (both bootstrap and final version). # -exe{*.test}: +cxx.poptions =+ "-I$out_root" "-I$src_root" + +# Bootstrap. +# +# The plan is as follows: +# +# 1. Build the bootstrap version of cli using a copy of options.?xx saved in +# bootstrap/cli/. +# +# 2. Use that to re-generate options.?xx. If the result differs from the +# saved version, copy it over and fail the build, asking for a restart. +# +# 3. Otherwise, proceed to build the final version of cli. +# +if $config.cli.develop { - test = true - install = false -} + libue{cli}: {hxx ixx cxx}{options} -for t: cxx{**.test...} + bootstrap/ + { + # This should only apply to the bootstrap build. + # + cxx.poptions =+ "-I$src_base" # Note: must come first. + + cli/ + { + # Note: semantics/ and traversal/ do not include options.hxx so we can + # share their object files. + # + exe{cli}: obj{cli $name($src) options} ../../{$all_s $all_t} $libs + + for s: cli $name($src) + obj{$s}: ../../cxx{$s} $libs + + obj{options}: {hxx ixx cxx}{options} + + obj{cli}: cxx.poptions += -DCLI_BOOTSTRAP + } + } + + <{hxx ixx cxx}{options}>: cli{options} bootstrap/cli/exe{cli} + { + options = --include-with-brackets --include-prefix cli \ + --guard-prefix CLI --generate-file-scanner \ + --generate-specifier --generate-modifier \ + --suppress-undocumented --reserved-name stdout + + # Symlink the generated code in src for convenience of development. + # + backlink = true + } + {{ + diag cli ($<[0]) + ($<[1]) $options -o $out_base $path($<[0]) + + # If the result differs from the bootstrap version, copy it over and + # request the build restart. + # + if diff $src_base/bootstrap/cli/options.hxx $path($>[0]) >- && \ + diff $src_base/bootstrap/cli/options.ixx $path($>[1]) >- && \ + diff $src_base/bootstrap/cli/options.cxx $path($>[2]) >- + exit + end + + cp $path($>[0]) $src_base/bootstrap/cli/options.hxx + cp $path($>[1]) $src_base/bootstrap/cli/options.ixx + cp $path($>[2]) $src_base/bootstrap/cli/options.cxx + + exit "bootstrap options.?xx have changed, restart the build" + }} +} +else { - d = $directory($t) - n = $name($t)... + # Use bootstrap options.?xx to build the final version of cli. + # + libue{cli}: bootstrap/cli/{hxx ixx cxx}{options} + cxx.poptions =+ "-I($src_base/bootstrap)" # Note: must come first. - ./: $d/exe{$n}: $t $d/{hxx ixx txx}{+$n} $d/testscript{+$n} - $d/exe{$n}: libue{cli}: bin.whole = false + ./: cli{options} # Keep in distribution. } -# Build options. +# Build options (final version only). # + # Pass the copyright notice extracted from the LICENSE file. # -copyright = $process.run_regex(cat $src_root/LICENSE, \ - 'Copyright \(c\) (.+)\.', \ - '\1') - obj{cli}: cxx.poptions += -DCLI_COPYRIGHT=\"$copyright\" -# Generated options parsing code. -# -# @@ This will eventually be replaced with an ah hoc recipe. +# Unit tests. # -if ($config.cli != [null] && $config.cli != false) +exe{*.test}: { - cli.cxx{options}: cli{options} - - cli.options += --include-with-brackets --include-prefix cli \ ---guard-prefix CLI --generate-file-scanner --generate-specifier \ ---generate-modifier --suppress-undocumented --reserved-name stdout + test = true + install = false +} - cli.cxx{*}: - { - # 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). - # - dist = true - clean = ($src_root != $out_root) +for t: cxx{**.test...} +{ + d = $directory($t) + n = $name($t)... - # We keep the generated code in the repository so copy it back to src - # in case of a forwarded configuration. - # - backlink = overwrite - } + ./: $d/exe{$n}: $t $d/{hxx ixx txx}{+$n} $d/testscript{+$n} + $d/exe{$n}: libue{cli}: bin.whole = false } -- cgit v1.1