summaryrefslogtreecommitdiff
path: root/xsd/xsd/buildfile
diff options
context:
space:
mode:
Diffstat (limited to 'xsd/xsd/buildfile')
-rw-r--r--xsd/xsd/buildfile123
1 files changed, 88 insertions, 35 deletions
diff --git a/xsd/xsd/buildfile b/xsd/xsd/buildfile
index 49fbf2c..d4e7af5 100644
--- a/xsd/xsd/buildfile
+++ b/xsd/xsd/buildfile
@@ -5,64 +5,117 @@ import libs = libxsd-frontend%lib{xsd-frontend}
import libs += libcutl%lib{cutl}
import libs += libxerces-c%lib{xerces-c}
-options_topics = options cxx/options cxx/parser/options cxx/tree/options
+ops = options cxx/options cxx/parser/options cxx/tree/options
-./: exe{xsd}: {hxx ixx txx cxx}{** -{$options_topics} -version} \
- {hxx ixx cxx}{$options_topics} \
- {hxx}{version} \
+./: exe{xsd}: {hxx ixx txx cxx}{** -version -{$ops} -pregenerated/**} \
+ {hxx}{version} \
$libs
# Target metadata, see also --build2-metadata in xsd.cxx.
#
+# Note that xsd does not query any environment variables.
+#
exe{xsd}:
{
export.metadata = 1 xsd
xsd.name = [string] xsd
- xsd.version = $version
- xsd.checksum = $version
+ xsd.version = [string] $version
+ xsd.checksum = [string] $version
}
hxx{version}: in{version} $src_root/manifest
-# Build options.
+## Consumption build ($develop == false).
#
-# Pass the copyright notice extracted from the LICENSE file.
+
+# Use pregenerated versions in the consumption build.
#
-obj{xsd cxx/parser/generator cxx/tree/generator}: \
- cxx.poptions += -DXSD_COPYRIGHT=\"$copyright\"
+exe{xsd}: pregenerated/{hxx ixx cxx}{**}: include = (!$develop)
+
+if! $develop
+ cxx.poptions =+ "-I($src_base/pregenerated)" # Note: must come first.
-# Generated options parser.
+# Distribute pregenerated versions only in the consumption build.
#
-if $cli.configured
-{
- cli.cxx{options}: cli{options}
- cxx/cli.cxx{options}: cxx/cli{options}
- cxx/parser/cli.cxx{options}: cxx/parser/cli{options}
- cxx/tree/cli.cxx{options}: cxx/tree/cli{options}
+pregenerated/{hxx ixx cxx}{*}: dist = (!$develop)
- cli.options += --std c++11 -I $src_root --generate-specifier \
---ostream-type ::std::wostream --exclude-base --suppress-undocumented \
---generate-file-scanner --include-with-brackets --option-length 28 \
---cxx-prologue '#include <xsd/options-parser.hxx>'
+#
+##
- cli.cxx{options}: cli.options += --include-prefix xsd --guard-prefix XSD
+## Development build ($develop == true).
+#
- cxx/cli.cxx{options}: cli.options += --include-prefix xsd/cxx \
- --guard-prefix XSD_CXX
+exe{xsd}: {hxx ixx cxx}{$ops}: include = $develop
- cxx/parser/cli.cxx{options}: cli.options += --include-prefix xsd/cxx/parser \
- --guard-prefix XSD_CXX_PARSER
+if $develop
+ import! [metadata] cli = cli%exe{cli}
- cxx/tree/cli.cxx{options}: cli.options += --include-prefix xsd/cxx/tree \
- --guard-prefix XSD_CXX_TREE
+# In the development build distribute regenerated {hxx ixx cxx}{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.
+#
+for f: $ops
+{
+ d = $directory($f) # empty, cxx/, etc.
- # 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{*}:
+ <{hxx ixx cxx}{$f}>: cli{$f}
{
- dist = true
- clean = ($src_root != $out_root)
+ dist = ($develop ? $relative([dir_path] "pregenerated/xsd/$d", $d) : false)
+
+ # Symlink the generated code in src for convenience of development.
+ #
+ backlink = true
}
}
+
+<hxx{~'/(.*)/'} ixx{~'/\1/'} cxx{~'/\1/'}>: cli{~'/\1/'} $cli
+%
+if $develop
+{{
+ t = $path($>[0]).t
+
+ depdb dyndep --byproduct --file $t
+
+ h = $path($>[0])
+ i = $path($>[1])
+ c = $path($>[2])
+
+ d = $directory($h)
+ p = $string($leaf($d, $out_root)) # xsd, xsd/cxx, etc
+
+ options = --std c++11 -I $src_root --include-prefix $p \
+ --guard-prefix $regex.replace($ucase($p), '[/\\]', '_') \
+ --generate-specifier --generate-file-scanner \
+ --suppress-undocumented --ostream-type ::std::wostream \
+ --exclude-base --include-with-brackets --option-length 28 \
+ --cxx-prologue '#include <xsd/options-parser.hxx>'
+
+ $cli $options --generate-dep --dep-file $t -o $d $path($<[0])
+
+ # If the result differs from the pregenerated version, copy it over.
+ #
+ d = [dir_path] $src_base/pregenerated/$p
+
+ dh = $d/$leaf($h)
+ di = $d/$leaf($i)
+ dc = $d/$leaf($c)
+
+ if diff $dh $h >- && \
+ diff $di $i >- && \
+ diff $dc $c >-
+ exit
+ end
+
+ cp $h $dh
+ cp $i $di
+ cp $c $dc
+}}
+
+#
+##
+
+# Pass the copyright notice extracted from the LICENSE file.
+#
+obj{xsd cxx/parser/generator cxx/tree/generator}: \
+ cxx.poptions += -DXSD_COPYRIGHT=\"$copyright\"