-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Jamroot
485 lines (434 loc) · 16.9 KB
/
Jamroot
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
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
# Copyright Vladimir Prus 2002-2006.
# Copyright Dave Abrahams 2005-2006.
# Copyright René Ferdinand Rivera Morell 2005-2024.
# Copyright Douglas Gregor 2005.
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
# Usage:
#
# b2 [options] [properties] [install|stage]
#
# Builds and installs Boost.
#
# Targets and Related Options:
#
# install Install headers and compiled library files to the
# ======= configured locations (below).
#
# --prefix=<PREFIX> Install architecture independent files here.
# Default: C:\Boost on Windows
# Default: /usr/local on Unix, Linux, etc.
#
# --exec-prefix=<EPREFIX> Install architecture dependent files here.
# Default: <PREFIX>
#
# --libdir=<LIBDIR> Install library files here.
# Default: <EPREFIX>/lib
#
# --includedir=<HDRDIR> Install header files here.
# Default: <PREFIX>/include
#
# --cmakedir=<CMAKEDIR> Install CMake configuration files here.
# Default: <LIBDIR>/cmake
#
# --no-cmake-config Do not install CMake configuration files.
#
# stage Build and install only compiled library files to the
# ===== stage directory.
#
# --stagedir=<STAGEDIR> Install library files here
# Default: ./stage
#
# Other Options:
#
# --build-type=<type> Build the specified pre-defined set of variations of
# the libraries. Note, that which variants get built
# depends on what each library supports.
#
# -- minimal -- (default) Builds a minimal set of
# variants. On Windows, these are static
# multithreaded libraries in debug and release
# modes, using shared runtime. On Linux, these are
# static and shared multithreaded libraries in
# release mode.
#
# -- complete -- Build all possible variations.
#
# --build-dir=DIR Build in this location instead of building within
# the distribution tree. Recommended!
#
# --show-libraries Display the list of Boost libraries that require
# build and installation steps, and then exit.
#
# --layout=<layout> Determine whether to choose library names and header
# locations such that multiple versions of Boost or
# multiple compilers can be used on the same system.
#
# -- versioned -- Names of boost binaries include
# the Boost version number, name and version of
# the compiler and encoded build properties. Boost
# headers are installed in a subdirectory of
# <HDRDIR> whose name contains the Boost version
# number.
#
# -- tagged -- Names of boost binaries include the
# encoded build properties such as variant and
# threading, but do not including compiler name
# and version, or Boost version. This option is
# useful if you build several variants of Boost,
# using the same compiler.
#
# -- system -- Binaries names do not include the
# Boost version number or the name and version
# number of the compiler. Boost headers are
# installed directly into <HDRDIR>. This option is
# intended for system integrators building
# distribution packages.
#
# The default value is 'versioned' on Windows, and
# 'system' on Unix.
#
# --buildid=ID Add the specified ID to the name of built libraries.
# The default is to not add anything.
#
# --python-buildid=ID Add the specified ID to the name of built libraries
# that depend on Python. The default is to not add
# anything. This ID is added in addition to --buildid.
#
# --help This message.
#
# --with-<library> Build and install the specified <library>. If this
# option is used, only libraries specified using this
# option will be built.
#
# --without-<library> Do not build, stage, or install the specified
# <library>. By default, all libraries are built.
#
# Properties:
#
# toolset=toolset Indicate the toolset to build with.
#
# variant=debug|release Select the build variant
#
# link=static|shared Whether to build static or shared libraries
#
# threading=single|multi Whether to build single or multithreaded binaries
#
# runtime-link=static|shared
# Whether to link to static or shared C and C++
# runtime.
#
require-b2 5.1.0 ;
# TODO:
# - handle boost version
# - handle python options such as pydebug
import boostcpp ;
import package ;
import sequence ;
import xsltproc ;
import set ;
import path ;
import link ;
import notfile ;
import virtual-target ;
import "class" : new ;
import property-set ;
import threadapi-feature ;
import option ;
import property ;
import project ;
# Backslash because of `bcp --namespace`
import tools/boost\_install/boost-install ;
path-constant BOOST_ROOT : . ;
constant BOOST_VERSION : 1.88.0 ;
constant BOOST_JAMROOT_MODULE : $(__name__) ;
# Allow subprojects to simply `import config : requires ;` to get access to the requires rule
import-search $(BOOST_ROOT)/libs/config/checks ;
import-search $(BOOST_ROOT)/libs/predef/tools/check ;
boostcpp.set-version $(BOOST_VERSION) ;
use-project /boost/architecture : libs/config/checks/architecture ;
local all-headers =
[ MATCH .*libs/(.*)/include/boost : [ glob libs/*/include/boost libs/*/*/include/boost ] ] ;
for dir in $(all-headers)
{
link-directory $(dir)-headers : libs/$(dir)/include/boost : <location>. ;
explicit $(dir)-headers ;
}
if $(all-headers)
{
constant BOOST_MODULARLAYOUT : $(all-headers) ;
}
project /boost
: requirements <include>.
[ boostcpp.platform ]
# Disable auto-linking for all targets here, primarily because it caused
# troubles with V2.
<define>BOOST_ALL_NO_LIB=1
# Used to encode variant in target name. See the 'tag' rule below.
<tag>@$(__name__).tag
<conditional>@handle-static-runtime
<conditional>@clang-darwin-cxxstd-11
# Comeau does not support shared lib
<toolset>como:<link>static
<toolset>como-linux:<define>_GNU_SOURCE=1
# When building docs within Boost, we want the standard Boost style
<xsl:param>boost.defaults=Boost
<conditional>@threadapi-feature.detect
: usage-requirements <include>.
: default-build
<visibility>hidden
<threading>multi
: build-dir bin.v2
;
# General, top-level, modular project searching. Also include tools in the
# project search.
project-search /boost : libs tools ;
# Temporary custom project searching to account for special library paths.
project-search /boost : libs/numeric ;
project-search /boost/numeric_conversion : libs/numeric/conversion ;
# This rule is called by Boost.Build to determine the name of target. We use it
# to encode the build variant, compiler name and boost version in the target
# name.
#
rule tag ( name : type ? : property-set )
{
return [ boostcpp.tag $(name) : $(type) : $(property-set) ] ;
}
rule python-tag ( name : type ? : property-set )
{
return [ boostcpp.python-tag $(name) : $(type) : $(property-set) ] ;
}
rule handle-static-runtime ( properties * )
{
# Using static runtime with shared libraries is impossible on Linux, and
# dangerous on Windows. Therefore, we disallow it. This might be drastic,
# but it was disabled for a while without anybody complaining.
local argv = [ modules.peek : ARGV ] ;
if <link>shared in $(properties)
&& <runtime-link>static in $(properties)
# For CW, static runtime is needed so that std::locale works.
&& ! ( <toolset>cw in $(properties) )
&& ! --allow-shared-static in $(argv)
{
boostcpp.emit-shared-static-warning ;
return <build>no ;
}
}
rule clang-darwin-cxxstd-11 ( properties * )
{
# AppleClang defaults to C++03
local result = [ property.select <cxxstd> : $(properties) ] ;
if <toolset-clang:platform>darwin in $(properties)
{
result ?= <cxxstd>11 ;
}
return $(result) ;
}
# All libraries.
local all-libraries
= [ MATCH .*libs/(.*)/meta/libraries.json : [ glob libs/*/meta/libraries.json ] ] ;
# Find all the libraries that have something to build (the old way).
local all-libraries-to-build
= [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
[ glob libs/*/build/Jamfile ] ] ;
all-libraries-to-build = [ sequence.unique $(all-libraries-to-build) ] ;
# The function_types library has a Jamfile, but it's used for maintenance
# purposes, there's no library to build and install.
all-libraries-to-build = [ set.difference $(all-libraries-to-build) : function_types ] ;
# Find all the libraries that have a library-root build declaration (modular way).
local all-libraries-modular-build
= [ MATCH .*libs/(.*)/build.jam : [ glob libs/*/build.jam ] ] ;
# Modular and not are mutually exclusive as they have different lib targets.
all-libraries-to-build = [ set.difference $(all-libraries-to-build) : $(all-libraries-modular-build) ] ;
# The header only libraries that are not of the new modular form. For which we
# will create synthetic projects and targets to simulate the new modular form.
local all-libraries-to-declare
= [ set.difference $(all-libraries)
: $(all-libraries-modular-build) $(all-libraries-to-build) ] ;
if ! [ glob libs/numeric/conversion/build.jam ]
{
all-libraries-to-declare += numeric_conversion ;
}
if ! [ glob libs/numeric/interval/build.jam ]
{
all-libraries-to-declare += interval ;
}
if ! [ glob libs/numeric/odeint/build.jam ]
{
all-libraries-to-declare += odeint ;
}
if ! [ glob libs/numeric/ublas/build.jam ]
{
all-libraries-to-declare += ublas ;
}
all-libraries-to-declare = [ SORT $(all-libraries-to-declare) ] ;
# ECHO "INFO: Build Libraries:" [ SORT $(all-libraries-to-build) ] ;
# ECHO "INFO: Modular Libraries:" [ SORT $(all-libraries-modular-build) ] ;
# ECHO "INFO: Declared Libraries:" [ SORT $(all-libraries-to-declare) ] ;
# EXIT : 0 ;
# Setup convenient aliases for all libraries.
# First, the complicated libraries: where the target name in Jamfile is
# different from its directory name.
explicit
[ alias prg_exec_monitor : libs/test/build//boost_prg_exec_monitor ]
[ alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ]
[ alias unit_test_framework : libs/test/build//boost_unit_test_framework ]
[ alias serialization : libs/serialization/build//boost_serialization ]
[ alias wserialization : libs/serialization/build//boost_wserialization ]
;
for local l in $(all-libraries-to-build)
{
if ! $(l) in test graph serialization headers
{
explicit [ alias $(l) : libs/$(l)/build//boost_$(l) ] ;
}
}
for local l in $(all-libraries-modular-build)
{
if ! $(l) in test graph serialization headers
{
explicit [ alias $(l) : /boost/$(l)//boost_$(l) ] ;
}
}
rule do-nothing { }
rule generate-alias ( project name : property-set : sources * )
{
local action-name = [ $(property-set).get <action> ] ;
local m = [ MATCH ^@(.*) : $(action-name) ] ;
property-set = [ property-set.empty ] ;
local action = [ new action $(sources) : $(m[1]) : $(property-set) ] ;
local t = [ new notfile-target $(name) : $(project) : $(action) ] ;
return [ virtual-target.register $(t) ] ;
}
generate headers : $(all-headers)-headers : <generating-rule>@generate-alias <action>@do-nothing : : <include>. ;
#alias headers : $(all-headers)-headers : : : <include>. ;
explicit headers ;
# Make project ids of all libraries known.
for local l in $(all-libraries-to-build)
{
use-project /boost/$(l) : libs/$(l)/build ;
}
if [ path.exists $(BOOST_ROOT)/tools/inspect/build ]
{
use-project /boost/tools/inspect : tools/inspect/build ;
}
if [ path.exists $(BOOST_ROOT)/libs/wave/tool/build ]
{
use-project /boost/libs/wave/tool : $(BOOST_ROOT)/libs/wave/tool/build ;
}
# Make the boost-install rule visible in subprojects
# This rule should be called from libraries' Jamfiles and will create two
# targets, "install" and "stage", that will install or stage that library. The
# --prefix option is respected, but --with and --without options, naturally, are
# ignored.
#
# - libraries -- list of library targets to install.
rule boost-install ( libraries * )
{
boost-install.boost-install $(libraries) ;
}
# Creates a library target, adding autolink support and also creates
# stage and install targets via boost-install, above.
rule boost-lib ( name : sources * : requirements * : default-build * : usage-requirements * )
{
autolink = <link>shared:<define>BOOST_$(name:U)_DYN_LINK=1 ;
name = boost_$(name) ;
lib $(name)
: $(sources)
: $(requirements) $(autolink)
: $(default-build)
: $(usage-requirements) $(autolink)
;
boost-install $(name) ;
}
# Declare special top-level targets that build and install the desired variants
# of the libraries.
boostcpp.declare-targets $(all-libraries-to-build) $(all-libraries-modular-build) ;
# Declare a Boost library and run related declaration rules. This should be
# called from the libroot/build.jam to define the components of a Boost lib.
# The first arg is the base ID of the library. Each subsequence arg is a
# Boost (boost-x) declaration rule to call with arguments.
#
# For example:
#
# call-if : boost-library serialization
# : install boost_serialization boost_wserialization ;
#
rule boost-library ( id ? : options * : * )
{
# ECHO "INFO: Declare Boost library:" $(id) ;
local called-boost-install ;
for n in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{
local option = $($(n)) ;
if $(option)
{
call-if : boost-$(option[1]) $(option[2-]) ;
if $(option[1]) = install
{
called-boost-install = true ;
}
}
}
if ! $(called-boost-install)
{
# If the library didn't indicate an install build target it's likely
# header only. We should declare empty install targets to allow for
# generic handling.
boost-install.boost-install ;
}
}
# Declare projects and targets for all placeholder, header only, not yet
# modular libraries.
#
# NOTE: This has to be after the boost-* rule definitions to ensure that those
# are available for import into the new projects.
local location = [ project.attribute $(__name__) location ] ;
for local lib in $(all-libraries-to-declare)
{
local lib-path
= [ path.join $(location) libs $(lib) ] ;
if $(lib) = numeric_conversion
{
lib-path = [ path.join $(location) libs/numeric/conversion ] ;
}
else if $(lib) in interval odeint ublas
{
lib-path = [ path.join $(location) libs/numeric/$(lib) ] ;
}
local lib-module
= [ project.load $(lib-path) : synthesize ] ;
modules.poke $(lib-module) : BOOST_LIB_PROJECT : /boost/$(lib) ;
modules.poke $(lib-module) : BOOST_LIB_TARGET : boost_$(lib) ;
project.push-current [ project.target $(lib-module) ] ;
module $(lib-module)
{
project $(BOOST_LIB_PROJECT)
: requirements
<implicit-dependency>/boost//headers
;
alias $(BOOST_LIB_TARGET) ;
}
project.pop-current ;
}
# Backslash because of `bcp --namespace`
if ! [ project.search /boost/tools/boost\_install ]
{
use-project /boost/tools/boost\_install : tools/boost\_install ;
}
# Ensure "modular" libraries' projects are loaded before build request is
# calculated. This is necessary for subprojects that define custom features
# to be set by users on command line.
# This part should stay at the bottom of the file, because subprojects may rely
# on rules or constants from it.
for local l in $(all-libraries-modular-build)
{
# project.find returns the module for the project, which ensures that the
# project is loaded. The convoluted way the rule is invoked is due to the
# fact that project.find can only be called from a project target instance.
modules.call-in [ project.target $(__name__) ]
: project.find /boost/$(l)
: $(location) ;
}