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

define mod: libs

mod{*}:
{
  bin.lib.prefix = mod_
  backlink = true        # Backlink in forwarded configurations.
  install = libexec/
}

import libs  = libcmark-gfm%lib{cmark-gfm}
import libs += libcmark-gfm-extensions%lib{cmark-gfm-extensions}
import libs += libodb%lib{odb}
import libs += libodb-pgsql%lib{odb-pgsql}
import libs += libbutl%lib{butl}
import libs += libbpkg%lib{bpkg}
import libs += libbbot%lib{bbot}

include ../libbrep/

include ../web/xhtml/
include ../web/server/

./: mod{brep} {libue libus}{mod}

libu_src = options-types types-parsers build-config

mod{brep}: {hxx ixx txx cxx}{* -module-options -{$libu_src}}               \
           libus{mod} ../libbrep/lib{brep} ../web/server/libus{web-server} \
           $libs

{libue libus}{mod}: {hxx ixx txx cxx}{+{$libu_src}} $libs

libus{mod}: ../web/xhtml/libus{xhtml}
libue{mod}: ../web/xhtml/libue{xhtml}

## Consumption build ($develop == false).
#

# Use pregenerated versions in the consumption build.
#
{libue libus}{mod}: pregenerated/{hxx ixx cxx}{**}: include = (!$develop)

if! $develop
  cxx.poptions =+ "-I($src_base/pregenerated)"

# Distribute pregenerated versions only in the consumption build.
#
pregenerated/{hxx ixx cxx}{*}: dist = (!$develop)

#
##

## Development build ($develop == true).
#

{libue libus}{mod}: {hxx ixx cxx}{module-options}: include = $develop

if $develop
  import! [metadata] cli = cli%exe{cli}

# In the development build distribute regenerated
# {hxx ixx cxx}{module-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.
#
<{hxx ixx cxx}{module-options}>: cli{module} $cli
{
  # Set option prefix to the empty value to handle all unknown request
  # parameters uniformly with a single catch block.
  #
  options = --std c++11 -I $src_root --include-with-brackets              \
            --include-prefix mod --guard-prefix MOD --generate-specifier  \
            --cxx-prologue "#include <mod/types-parsers.hxx>"             \
            --cli-namespace brep::cli --generate-file-scanner             \
            --option-length 46 --generate-modifier --generate-description \
            --option-prefix "" --output-suffix "-options"
}
%
if $develop
{{
  diag cli ($<[0])
  ($<[1]) $options -o $out_base/ $path($<[0])

  if diff $src_base/pregenerated/mod/module-options.hxx $path($>[0]) >- && \
     diff $src_base/pregenerated/mod/module-options.ixx $path($>[1]) >- && \
     diff $src_base/pregenerated/mod/module-options.cxx $path($>[2]) >-
    exit
  end

  cp $path($>[0]) $src_base/pregenerated/mod/module-options.hxx
  cp $path($>[1]) $src_base/pregenerated/mod/module-options.ixx
  cp $path($>[2]) $src_base/pregenerated/mod/module-options.cxx
}}

#
##

# Don't install any of the module's headers.
#
{hxx ixx txx}{*}: install = false