-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Jamroot.jam
260 lines (230 loc) · 7.32 KB
/
Jamroot.jam
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# Copyright 2019-2024 Rene Rivera
# Copyright 2017 Steven Watanabe
# Copyright 2016 Vladimir Prus
# Copyright 2017 Edward Diener
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)
require-b2 5 ;
import "class" : new ;
import bison ;
import errors ;
import feature ;
import indirect ;
import os ;
import path ;
import set ;
import stage : add-install-dir ;
import toolset ;
import type ;
import virtual-target ;
path-constant SELF : . ;
project /bfgroup/b2
: build-dir .build
: requirements
<cxxstd>11
<threading>multi
<toolset>msvc:<define>_CRT_SECURE_NO_WARNINGS=1
<toolset>msvc:<define>_CRT_NONSTDC_NO_DEPRECATE=1
<variant>debug:<define>B2_DEBUG=1
<toolset>clang-win:<define>_CRT_SECURE_NO_WARNINGS=1
<toolset>clang-win:<define>_CRT_NONSTDC_NO_DEPRECATE=1
<toolset>clang:<cxxflags>-Wno-deprecated-declarations
<toolset>gcc,<variant>debug,<target-os>linux:<linkflags>-rdynamic
# Don't warn on ignored/unknown attributes.
<toolset>gcc:<cxxflags>-Wno-attributes
<toolset>clang:<cxxflags>-Wno-attributes
<toolset>clang:<cxxflags>-Wno-c++14-extensions
;
#|
Build the engine and its dependencies outside of the simple core build scripts.
This allows us to keep the core build scripts as simple as possible. And lets
us support more functionality for development of the engine core.
|#
#|
Define custom yyacc tool.
|#
feature.feature yyacc : : dependency free ;
toolset.flags yyacc TOOL <yyacc> ;
exe yyacc
: src/engine/yyacc.cpp
: ;
explicit yyacc ;
rule yyacc-gen ( project name : property-set : sources * )
{
local relevant = [ toolset.relevant $(__name__).yyacc ] ;
local a = [ new action $(sources[1]) : $(__name__).yyacc : [ $(property-set).add $(relevant) ] ] ;
local targets ;
for local n in $(name:S=).y $(name:S=)tab.h
{
targets += [ virtual-target.register
[ new file-target $(n) exact : [ type.type $(n) ]
: $(project) : $(a)
] ] ;
}
return $(targets) ;
}
actions yyacc bind TOOL
{
"$(TOOL)" "$(<)" "$(>)"
}
generate jamgram.y
: src/engine/jamgram.yy
: <generating-rule>@yyacc-gen
<location>src/engine
<yyacc>yyacc <dependency>yyacc
;
explicit jamgram.y ;
#|
Define grammar translation with Bison.
|#
BISON = [ os.environ BISON ] ;
BISON ?= bison ;
local BISON_IN_PATH = [ path.glob [ os.executable-path ] : $(BISON[1]) $(BISON[1]).* ] ;
rule grammar ( target : source : properties * )
{
# LOCATE on $(target) = $(source:D) ;
BISON on $(target) = $(BISON) ;
}
actions grammar
{
"$(BISON)" --yacc --defines -o "$(<[1])" "$(>)"
}
if $(BISON_IN_PATH)
{
make jamgram.cpp
: src/engine/jamgram.y
: @grammar
: <dependency>jamgram.y
<location>src/engine ;
}
else
{
errors.warning "Bison generator program '$(BISON:J= )' not found. Skipping grammar build." ;
alias jamgram.cpp
: src/engine/jamgram.cpp ;
}
explicit jamgram.cpp ;
#|
Define the b2 executable. Sources are based on platform.
TODO: Make platform specific source be no-ops when not needed.
|#
obj jamgram.obj
: jamgram.cpp
: <toolset>gcc:<cxxflags>-Wno-free-nonheap-object
;
explicit jamgram.obj ;
local b2_src =
[ glob src/engine/*.cpp :
src/engine/*nt.cpp src/engine/*unix.cpp src/engine/*vms.cpp
src/engine/yyacc.cpp src/engine/mkjambase.cpp
src/engine/check_*.cpp
src/engine/jamgram.cpp
] ;
local b2_src_nt = [ glob src/engine/*nt.cpp ] ;
local b2_src_unix = [ glob src/engine/*unix.cpp ] ;
local b2_src_vms = [ glob src/engine/*vms.cpp ] ;
local unix_os = [ set.difference [ feature.values <target-os> ] : windows vms ] ;
exe b2
: $(b2_src)
jamgram.obj
: <target-os>windows:<source>$(b2_src_nt)
<target-os>vms:<source>$(b2_src_vms)
<target-os>$(unix_os):<source>$(b2_src_unix)
<toolset>msvc:<find-static-library>kernel32
<toolset>msvc:<find-static-library>advapi32
<toolset>msvc:<find-static-library>user32
<toolset>clang-win:<find-static-library>kernel32
<toolset>clang-win:<find-static-library>advapi32
<toolset>clang-win:<find-static-library>user32
<target-os>windows,<toolset>gcc:<source>src/engine/res.rc
<target-os>windows,<toolset>clang-linux:<source>src/engine/res.rc
<toolset>msvc:<embed-manifest-file>src/engine/b2.exe.manifest
<toolset>clang-win:<embed-manifest-file>src/engine/b2.exe.manifest
;
explicit b2 ;
#|
Installation of the engine, build, and example files.
|#
feature.feature b2-install-layout : standard portable : incidental propagated ;
if [ os.on-windows ]
{
feature.set-default b2-install-layout : portable ;
}
add-install-dir b2prefix-standard : : prefix ;
add-install-dir b2bindir-standard : : bindir ;
add-install-dir b2coredir-standard : b2/src : datarootdir ;
add-install-dir b2examplesdir-standard : b2/examples : datarootdir ;
add-install-dir b2prefix-portable : : prefix ;
add-install-dir b2bindir-portable : : b2prefix-portable ;
add-install-dir b2coredir-portable : .b2 : b2prefix-portable ;
add-install-dir b2examplesdir-portable : .b2/examples : b2prefix-portable ;
rule b2-exe ( props * )
{
local target-os = [ feature.get-values <target-os> : $(props) ] ;
local host-os = [ feature.get-values <host-os> : $(props) ] ;
if $(target-os) != $(host-os)
{
return <source>b2 ;
}
else if $(target-os) in windows vms
{
return <source>src/engine/b2.exe ;
}
return <source>src/engine/b2 ;
}
install b2-engine
:
: <conditional>@b2-exe
<b2-install-layout>standard:<location>(b2bindir-standard)
<b2-install-layout>portable:<location>(b2bindir-portable)
;
explicit b2-engine ;
local examples ;
for local e in [ glob-tree-ex $(SELF)/example : * : . .svn ]
{
if [ CHECK_IF_FILE [ path.native $(e) ] ]
{
examples += $(e) ;
}
}
install b2-examples
: # What to install
$(examples)
: # What is the root of the directory
<install-source-root>example
# Which subdir of $prefix/share
<b2-install-layout>standard:<location>(b2examplesdir-standard)
<b2-install-layout>portable:<location>(b2examplesdir-portable)
;
explicit b2-examples ;
local .core-sources =
$(SELF)/src/build-system.jam
[ path.glob-tree $(SELF)/src/build : *.jam ]
[ path.glob-tree $(SELF)/src/contrib : *.jam ]
[ path.glob-tree $(SELF)/src/kernel : *.jam ]
[ path.glob-tree $(SELF)/src/options : *.jam ]
[ path.glob-tree $(SELF)/src/util : *.jam ]
[ path.glob-tree $(SELF)/src/tools : *.jam *.xml *.xsl *.doxyfile *.hpp doxproc.py ]
;
install b2-core
: # What to install
$(.core-sources)
: # What is the root of the directory
<install-source-root>src
# Which subdir of $prefix/share
<b2-install-layout>standard:<location>(b2coredir-standard)
<b2-install-layout>portable:<location>(b2coredir-portable)
;
explicit b2-core ;
#|
Only install example files when requested to avoid bloating install footprint.
|#
if --with-examples in [ modules.peek : ARGV ]
{
alias install : b2-engine b2-core b2-examples ;
}
else
{
alias install : b2-engine b2-core ;
}
explicit install ;