aboutsummaryrefslogtreecommitdiff
path: root/bbot/buildfile
blob: bbca81064180a15ed25127c5d4226e8d9a61bf4c (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
# file      : bbot/buildfile
# license   : MIT; see accompanying LICENSE file

# Systemd .service file.
#
# @@ Currently the executable path is hardcoded as /usr/bin/bbot-agent. To
#    handle this properly would need to generate/pre-process it (and detect
#    update for install).
#
define service: file

service{*}:
{
  extension = service
  install = lib/systemd/system/
  install.mode = 644
}

import libs  = libbutl%lib{butl}
import libs += libbbot%lib{bbot}

# Agent is a systemd service.
#
./: exe{bbot-agent} \
    service{'bbot-agent@'}: include = ($cxx.target.class == 'linux')

exe{bbot-agent}: agent/{hxx ixx txx cxx}{+agent} agent/libue{bbot}

agent/
{
  libue{bbot}: {hxx ixx txx cxx}{* -agent -agent-options -*.test...} \
               {hxx ixx cxx}{agent-options}                          \
               ../libue{bbot}
}

./: exe{bbot-worker}: worker/{hxx ixx txx cxx}{+worker} worker/libue{bbot}

worker/
{
  libue{bbot}: {hxx ixx txx cxx}{* -worker -worker-options -*.test...} \
               {hxx ixx cxx}{worker-options}                           \
               ../libue{bbot}
}

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

if ($cxx.target.class == 'linux')
  cxx.libs += -ldl

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}: $d/libue{bbot}: bin.whole = false
}

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

obj{agent/agent worker/worker}: cxx.poptions += -DBBOT_COPYRIGHT=\"$copyright\"

# Generated options parser.
#
if $cli.configured
{
  cli.cxx{common-options}: cli{common}
  agent/cli.cxx{agent-options}: cli{agent/agent}
  worker/cli.cxx{worker-options}: cli{worker/worker}

  cli.options += --std c++11 -I $src_root --include-with-brackets \
--cxx-prologue "#include <bbot/types-parsers.hxx>" \
--cli-namespace bbot::cli --generate-specifier --generate-parse

  # No usage.
  #
  cli.cxx{common-options}: cli.options += --include-prefix bbot \
--guard-prefix BBOT --generate-vector-scanner --generate-group-scanner

  # Usage options.
  #
  cli.options += --suppress-undocumented --long-usage --ansi-color \
--page-usage 'bbot::print_$name$_' --option-length 25

  agent/cli.cxx{agent-options}: cli.options += --include-prefix bbot/agent \
--guard-prefix BBOT_AGENT

  worker/cli.cxx{worker-options}: cli.options += --include-prefix bbot/worker \
--guard-prefix BBOT_WORKER

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