Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for modular build structure. #854

Merged
merged 5 commits into from
May 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 64 additions & 23 deletions Jamroot
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright Vladimir Prus 2002-2006.
# Copyright Dave Abrahams 2005-2006.
# Copyright Rene Rivera 2005-2007.
# Copyright René Ferdinand Rivera Morell 2005-2024.
# Copyright Douglas Gregor 2005.
#
# Distributed under the Boost Software License, Version 1.0.
Expand Down Expand Up @@ -122,6 +122,8 @@
# runtime.
#

require-b2 5 ;

# TODO:
# - handle boost version
# - handle python options such as pydebug
Expand Down Expand Up @@ -149,7 +151,8 @@ constant BOOST_VERSION : 1.85.0 ;
constant BOOST_JAMROOT_MODULE : $(__name__) ;

# Allow subprojects to simply `import config : requires ;` to get access to the requires rule
modules.poke : BOOST_BUILD_PATH : $(BOOST_ROOT)/libs/config/checks [ modules.peek : BOOST_BUILD_PATH ] ;
import-search $(BOOST_ROOT)/libs/config/checks ;
import-search $(BOOST_ROOT)/libs/predef/tools/checks ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still work if libs/predef is empty? (In a partial checkout)

Copy link
Member Author

@grafikrobot grafikrobot Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still work if libs/predef is empty? (In a partial checkout)

Yes, as it has the same effect as what it replaces. In that it just pokes BOOST_BUILD_PATH. In the future when individual libraries use import-search /boost/predef/tools/check ; instead it will work "better" as it will error at that line if it doesn't find the project reference and dir. Instead of erroring later when doing the import predef ;.

Interesting that you didn't ask about it working or not if libs/config is empty. Which is also a possibility. ;-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually do remember an occasion on which libs/config was empty and things failed somewhere, which is why I was reminded to ask. :-)

(That's why depinst always installs libs/config.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(But libs/config is needed for more than that - the architecture and address model checks are there. Which is another story; these aren't Boost-specific and need to be in b2 proper.)


boostcpp.set-version $(BOOST_VERSION) ;

Expand Down Expand Up @@ -195,6 +198,8 @@ project boost
: build-dir bin.v2
;

project-search /boost : libs ;

# 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.
Expand Down Expand Up @@ -242,39 +247,53 @@ rule clang-darwin-cxxstd-11 ( properties * )
return $(result) ;
}

all-libraries = [ MATCH .*libs/(.*)/build/.* : [ glob libs/*/build/Jamfile.v2 ]
[ glob libs/*/build/Jamfile ] ] ;

all-libraries = [ sequence.unique $(all-libraries) ] ;
# 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 = [ set.difference $(all-libraries) : function_types ] ;
all-libraries-to-build = [ set.difference $(all-libraries-to-build) : function_types ] ;

# Setup convenient aliases for all libraries.
# 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 ] ] ;

local rule explicit-alias ( id : targets + )
{
alias $(id) : $(targets) ;
explicit $(id) ;
}
# 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) ;

# 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 ;
explicit-alias test_exec_monitor : libs/test/build//boost_test_exec_monitor ;
explicit-alias unit_test_framework : libs/test/build//boost_unit_test_framework ;
explicit-alias serialization : libs/serialization/build//boost_serialization ;
explicit-alias wserialization : libs/serialization/build//boost_wserialization ;
for local l in $(all-libraries)
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) ;
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) ] ;
}
}

# Log has an additional target
explicit-alias log_setup : libs/log/build//boost_log_setup ;
explicit [ alias log_setup : libs/log/build//boost_log_setup ] ;

rule do-nothing { }

Expand All @@ -294,7 +313,7 @@ generate headers : $(all-headers)-headers : <generating-rule>@generate-alias <ac
explicit headers ;

# Make project ids of all libraries known.
for local l in $(all-libraries)
for local l in $(all-libraries-to-build)
{
use-project /boost/$(l) : libs/$(l)/build ;
}
Expand Down Expand Up @@ -341,4 +360,26 @@ rule boost-lib ( name : sources * : requirements * : default-build * : usage-req

# Declare special top-level targets that build and install the desired variants
# of the libraries.
boostcpp.declare-targets $(all-libraries) ;
boostcpp.declare-targets $(all-libraries-to-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 * : * )
{
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-]) ;
}
}
}
Loading