aboutsummaryrefslogtreecommitdiff
path: root/bpkg/buildfile
blob: dc900d8e0875ddf69994d731ef593e90ca4e0e40 (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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# file      : bpkg/buildfile
# license   : MIT; see accompanying LICENSE file

# @@ ODB: these are ODB changelogs that are both generated and stored in the
#         repository (what if src != out?). Will need to think how to handle
#         them properly (always generate in src_base?).
#
define xml: file
xml{*}: extension = xml

import libs  = libbpkg%lib{bpkg}
import libs += libbutl%lib{butl}
import libs += libodb%lib{odb}
import libs += libodb-sqlite%lib{odb-sqlite}

options_topics =           \
bpkg-options               \
cfg-create-options         \
common-options             \
configuration-options      \
help-options               \
pkg-build-options          \
pkg-checkout-options       \
pkg-clean-options          \
pkg-configure-options      \
pkg-disfigure-options      \
pkg-drop-options           \
pkg-fetch-options          \
pkg-install-options        \
pkg-purge-options          \
pkg-test-options           \
pkg-status-options         \
pkg-uninstall-options      \
pkg-unpack-options         \
pkg-update-options         \
pkg-verify-options         \
rep-add-options            \
rep-create-options         \
rep-fetch-options          \
rep-info-options           \
rep-list-options           \
rep-remove-options

help_topics = repository-signing    \
              repository-types      \
              argument-grouping     \
              default-options-files

./: exe{bpkg}: {hxx ixx txx cxx}{+bpkg} libue{bpkg}

libue{bpkg}: {hxx ixx txx cxx}{** -bpkg              \
                                  -{$options_topics} \
                                  -{$help_topics}    \
                                  -*-odb             \
                                  -version           \
                                  -**.test...}       \
             {hxx ixx cxx}{$options_topics}          \
             {hxx cxx}{$help_topics}                 \
             {hxx ixx cxx}{package-odb}              \
             {hxx}{version}                          \
             $libs                                   \
             xml{*}

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

# 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{bpkg}: bin.whole = false
}

# Build options.
#
obj{utility}: cxx.poptions += -DBPKG_EXE_SUFFIX='"'$bin.exe.suffix'"'

# Pass the copyright notice extracted from the COPYRIGHT file.
#
copyright = $process.run_regex(cat $src_root/COPYRIGHT,  \
                               'Copyright \(c\) (.+)\.', \
                               '\1')

obj{bpkg}: cxx.poptions += -DBPKG_COPYRIGHT=\"$copyright\"

# Disable "unknown pragma" warnings.
#
switch $cxx.class
{
  case 'msvc'
    cxx.coptions += /wd4068

  case 'gcc'
    cxx.coptions += -Wno-unknown-pragmas
}

# VC14 has issues with decorating long names.
#
if ($cxx.id == 'msvc' && $cxx.version.major == 19 && $cxx.version.minor < 10)
  cxx.coptions += /wd4503

# Make sure backtrace includes function names.
#
if ($cxx.target.class == 'linux')
  cxx.loptions += -rdynamic

# Generated options parser.
#
if $cli.configured
{
  # General topics and common options.
  #
  cli.cxx{common-options}:        cli{common}
  cli.cxx{configuration-options}: cli{configuration}
  cli.cxx{bpkg-options}:          cli{bpkg}

  # Help command.
  #
  cli.cxx{help-options}: cli{help}

  # pkg-* command.
  #
  cli.cxx{pkg-build-options}:     cli{pkg-build}
  cli.cxx{pkg-checkout-options}:  cli{pkg-checkout}
  cli.cxx{pkg-clean-options}:     cli{pkg-clean}
  cli.cxx{pkg-configure-options}: cli{pkg-configure}
  cli.cxx{pkg-disfigure-options}: cli{pkg-disfigure}
  cli.cxx{pkg-drop-options}:      cli{pkg-drop}
  cli.cxx{pkg-fetch-options}:     cli{pkg-fetch}
  cli.cxx{pkg-install-options}:   cli{pkg-install}
  cli.cxx{pkg-purge-options}:     cli{pkg-purge}
  cli.cxx{pkg-test-options}:      cli{pkg-test}
  cli.cxx{pkg-status-options}:    cli{pkg-status}
  cli.cxx{pkg-uninstall-options}: cli{pkg-uninstall}
  cli.cxx{pkg-unpack-options}:    cli{pkg-unpack}
  cli.cxx{pkg-update-options}:    cli{pkg-update}
  cli.cxx{pkg-verify-options}:    cli{pkg-verify}

  # cfg-* command.
  #
  cli.cxx{cfg-create-options}: cli{cfg-create}

  # rep-* command.
  #
  cli.cxx{rep-add-options}:    cli{rep-add}
  cli.cxx{rep-create-options}: cli{rep-create}
  cli.cxx{rep-fetch-options}:  cli{rep-fetch}
  cli.cxx{rep-info-options}:   cli{rep-info}
  cli.cxx{rep-list-options}:   cli{rep-list}
  cli.cxx{rep-remove-options}: cli{rep-remove}

  # Help topics.
  #
  cli.cxx{repository-signing}:    cli{repository-signing}
  cli.cxx{repository-types}:      cli{repository-types}
  cli.cxx{argument-grouping}:     cli{argument-grouping}
  cli.cxx{default-options-files}: cli{default-options-files}

  # Option length must be the same to get commands/topics/options aligned.
  #
  cli.options += --std c++11 -I $src_root --include-with-brackets \
--include-prefix bpkg --guard-prefix BPKG \
--cxx-prologue "#include <bpkg/types-parsers.hxx>" --cli-namespace bpkg::cli \
--generate-vector-scanner --generate-file-scanner --generate-group-scanner \
--keep-separator --generate-specifier --generate-parse --generate-merge \
--page-usage 'bpkg::print_$name$_' --ansi-color --include-base-last \
--option-length 24

  cli.cxx{common-options}: cli.options += --short-usage --long-usage # Both.
  cli.cxx{bpkg-options}: cli.options += --short-usage --suppress-undocumented

  cli.options += --long-usage # All other pages -- long usage.

  cli.cxx{pkg-build-options}: cli.options += --class-doc \
bpkg::pkg_build_pkg_options=exclude-base --generate-modifier

  # Avoid generating CLI runtime and empty inline file for help topics.
  #
  cli.cxx{repository-signing repository-types argument-grouping \
          default-options-files}:                               \
    cli.options += --suppress-cli --suppress-inline

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