Declare fake modular targets for non-modular header only libs.

This declares fake/temporary modular projects and top-level targets for header only libraries that have not yet applied the modular changes. It allows for merging such modular changes in any order. And hence avoiding a complicated management of such a DAG merge order.
This commit is contained in:
René Ferdinand Rivera Morell 2024-03-17 15:21:52 -05:00 committed by GitHub
parent b7230b0a39
commit 3c25ac6ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

78
Jamroot
View file

@ -122,7 +122,7 @@
# runtime.
#
require-b2 5 ;
require-b2 5.1.0 ;
# TODO:
# - handle boost version
@ -143,6 +143,7 @@ import property-set ;
import threadapi-feature ;
import option ;
import property ;
import project ;
# Backslash because of `bcp --namespace`
import tools/boost\_install/boost-install ;
@ -172,7 +173,7 @@ if $(all-headers)
constant BOOST_MODULARLAYOUT : $(all-headers) ;
}
project boost
project /boost
: requirements <include>.
[ boostcpp.architecture ]
@ -198,7 +199,12 @@ project boost
: build-dir bin.v2
;
project-search /boost : libs ;
# 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
@ -247,6 +253,10 @@ rule clang-darwin-cxxstd-11 ( properties * )
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 ]
@ -263,8 +273,33 @@ local all-libraries-modular-build
# 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) ] ;
# ECHO "INFO: Build Libraries:" $(all-libraries-to-build) ;
# ECHO "INFO: Modular Libraries:" $(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.
@ -383,3 +418,36 @@ rule boost-library ( id ? : options * : * )
}
}
}
# 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.
for local lib in $(all-libraries-to-declare)
{
local lib-path
= [ path.join [ project.attribute $(__name__) location ] libs $(lib) ] ;
if $(lib) = numeric_conversion
{
lib-path = [ path.join [ project.attribute $(__name__) location ] libs/numeric/conversion ] ;
}
else if $(lib) in interval odeint ublas
{
lib-path = [ path.join [ project.attribute $(__name__) 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
<dependency>/boost//headers
;
alias $(BOOST_LIB_TARGET) ;
}
project.pop-current ;
}