summaryrefslogtreecommitdiff
path: root/cli/cli/buildfile
blob: 0b072654bf5ec5b6df2a3f8d1f65dbdac1b3dc63 (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
# file      : cli/buildfile
# license   : MIT; see accompanying LICENSE file

import libs = libcutl%lib{cutl}

# Import the cli program only if explicitly requested. This way a distribution
# that includes pre-generated files can be built without installing cli.
#
if ($config.cli != [null] && $config.cli != false)
  import! [metadata] cli = cli%exe{cli}

./: exe{cli}: cxx{cli} libue{cli}

# Target metadata, see also --build2-metadata in cli.cxx.
#
exe{cli}:
{
  export.metadata = 1 cli
  cli.name = [string] cli
  cli.version  = $version
  cli.checksum = $version
}

libue{cli}: {hxx ixx txx cxx}{** -cli -version -options -**.test...} \
            {hxx}{version} {hxx ixx cxx}{options}                    \
            $libs

hxx{version}: in{version} $src_root/manifest

# Regenerate the options parsing code if the cli program is imported.
#
if ($cli != [null])
{
  <{hxx ixx 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

    # 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)

    # We keep the generated code in the repository so copy it back to src
    # in case of a forwarded configuration.
    #
    backlink = overwrite

    # @@ The headers are installed by default. Needs to be fixed in build2.
    #    Another workaround is making options.cxx a primary ad hoc group
    #    member.
    #
    install = false
  }
  {{
    # @@ Change this to `diag cli ($<[0])` if/when it results with the same
    #    diagnostics.
    #
    diag cli $directory($<[0])/cli{options}

    $cli $options -o $out_base $path($<)
  }}
}

# Unit tests.
#
exe{*.test}:
{
  test = true
  install = false
}

for t: cxx{**.test...}
{
  d = $directory($t)
  n = $name($t)...

  ./: $d/exe{$n}: $t $d/{hxx ixx txx}{+$n} $d/testscript{+$n}
  $d/exe{$n}: libue{cli}: bin.whole = false
}

# Build options.
#
# Pass the copyright notice extracted from the LICENSE file.
#
obj{cli}: cxx.poptions += -DCLI_COPYRIGHT=\"$copyright\"