blob: d4e7af5bacdfda1dac9e087ec43eff5949d57e22 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# file : xsd/buildfile
# license : GNU GPL v2 + exceptions; see accompanying LICENSE file
import libs = libxsd-frontend%lib{xsd-frontend}
import libs += libcutl%lib{cutl}
import libs += libxerces-c%lib{xerces-c}
ops = options cxx/options cxx/parser/options cxx/tree/options
./: 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 = [string] $version
xsd.checksum = [string] $version
}
hxx{version}: in{version} $src_root/manifest
## Consumption build ($develop == false).
#
# Use pregenerated versions in the consumption build.
#
exe{xsd}: pregenerated/{hxx ixx cxx}{**}: include = (!$develop)
if! $develop
cxx.poptions =+ "-I($src_base/pregenerated)" # Note: must come first.
# Distribute pregenerated versions only in the consumption build.
#
pregenerated/{hxx ixx cxx}{*}: dist = (!$develop)
#
##
## Development build ($develop == true).
#
exe{xsd}: {hxx ixx cxx}{$ops}: include = $develop
if $develop
import! [metadata] cli = cli%exe{cli}
# 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.
<{hxx ixx cxx}{$f}>: cli{$f}
{
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\"
|