Skip to content

Commit 95930ca

Browse files
authored
Add support for modular build structure. (#2)
* Switch to library requirements instead of source. As source puts extra source in install targets. * Add top-level build for consistency and testing. * Add support for root-less modular build/install. * Add requires-b2 check to top-level build file. * Bump B2 require to 5.2 * Increment b2 version require. * Move inter-lib dependencies to a project variable and into the build targets.
1 parent 5c0228e commit 95930ca

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed

build.jam

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright René Ferdinand Rivera Morell 2024
2+
# Distributed under the Boost Software License, Version 1.0.
3+
# (See accompanying file LICENSE_1_0.txt or copy at
4+
# http://www.boost.org/LICENSE_1_0.txt)
5+
6+
require-b2 5.2 ;
7+
8+
project /boost/headers
9+
;
10+
11+
explicit
12+
[ alias boost_headers : build//boost_headers ]
13+
[ alias install : build//install ]
14+
[ alias stage : build//stage ]
15+
[ alias all : boost_headers stage ]
16+
;
17+
18+
call-if : boost-library headers
19+
;
20+

build/Jamfile

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
# Distributed under the Boost Software License, Version 1.0.
33
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
44

5+
require-b2 5.2 ;
6+
57
import package ;
68
import path ;
79
import sequence ;
810
import set ;
9-
import ../../../tools/boost_install/boost-install ;
10-
import ../../../tools/boost_install/boost-install-dirs ;
11+
import project ;
12+
import regex ;
13+
14+
import-search /boost/boost_install ;
15+
import boost-install ;
16+
import boost-install-dirs ;
17+
18+
path-constant LIBS_ROOT : ../.. ;
1119

1220
# header-subdir
1321

@@ -18,13 +26,17 @@ header-subdir ?= "" ;
1826

1927
# first, the 'modular' headers
2028

21-
local modular-headers = $(BOOST_MODULARLAYOUT) ;
29+
local modular-headers
30+
= [ SORT [ MATCH .*libs/(.*)/include/boost : [ glob
31+
$(LIBS_ROOT)/*/include/boost
32+
$(LIBS_ROOT)/numeric/*/include/boost
33+
] ] ] ;
2234

2335
local skip-headers ;
2436

2537
for local lib in $(modular-headers)
2638
{
27-
local header-root = $(BOOST_ROOT)/libs/$(lib)/include ;
39+
local header-root = $(LIBS_ROOT)/$(lib)/include ;
2840
local header-boost = $(header-root)/boost ;
2941

3042
local headers =
@@ -46,11 +58,17 @@ for local lib in $(modular-headers)
4658

4759
# then, the non-modular headers in boost/, minus the modular ones
4860

49-
local header-root = [ path.make $(BOOST_ROOT) ] ;
61+
local headers ;
62+
local header-root ;
63+
64+
if $(BOOST_ROOT)
65+
{
66+
header-root = [ path.make $(BOOST_ROOT) ] ;
5067

51-
local headers =
52-
[ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc ]
53-
[ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* ] ;
68+
headers =
69+
[ path.glob-tree $(BOOST_ROOT)/boost : *.hpp *.ipp *.h *.inc ]
70+
[ path.glob-tree $(BOOST_ROOT)/boost/compatibility/cpp_c_headers : c* ] ;
71+
}
5472

5573
headers = [ set.difference $(headers) : $(header-root)/$(skip-headers) ] ;
5674

@@ -64,6 +82,26 @@ install install-boost-headers
6482

6583
explicit install-boost-headers ;
6684

85+
# Boost version format: XYYYZZ
86+
87+
if ! [ modules.peek boostcpp : BOOST_VERSION ]
88+
{
89+
local boost-config = [ project.search /boost/config ] ;
90+
ECHO "[INFO] boost-config:" $(boost-config) ;
91+
if $(boost-config)
92+
{
93+
local boost-version-num = [ regex.grep
94+
[ path.native [ path.join $(boost-config) include boost ] ]
95+
: version.hpp : "BOOST_VERSION ([0-9]+)" : 1 ] ;
96+
boost-version-num = [ MATCH "(.*)(...)(..)" : $(boost-version-num[2]) ] ;
97+
boost-version-num =
98+
[ CALC $(boost-version-num[1]) + 0 ]
99+
[ CALC $(boost-version-num[2]) + 0 ]
100+
[ CALC $(boost-version-num[3]) + 0 ] ;
101+
modules.poke boostcpp : BOOST_VERSION : $(boost-version-num:J=.) ;
102+
}
103+
}
104+
67105
#
68106

69107
alias install-headers : install-$(modular-headers)-headers install-boost-headers ;

0 commit comments

Comments
 (0)