Skip to content

Commit

Permalink
Add support for modular build structure. (#172)
Browse files Browse the repository at this point in the history
This is part of the effort to make the Boost libraries "modular" for build and consumption. See https://lists.boost.org/Archives/boost/2024/01/255704.php and https://github.com/grafikrobot/boost-b2-modular/blob/b2-modular/README.adoc for more information.
  • Loading branch information
grafikrobot committed Sep 1, 2024
1 parent 981e37c commit ad121db
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 20 deletions.
50 changes: 50 additions & 0 deletions build.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright René Ferdinand Rivera Morell 2023-2024
# 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)

require-b2 5.2 ;

constant boost_dependencies :
<library>/boost/config//boost_config
<library>/boost/container_hash//boost_container_hash
<library>/boost/core//boost_core
<library>/boost/predef//boost_predef
<target-os>windows:<library>/boost/winapi//boost_winapi ;

project /boost/stacktrace
: common-requirements
<include>include
;

explicit
[ alias boost_stacktrace_addr2line : build//boost_stacktrace_addr2line ]
[ alias boost_stacktrace_backtrace : build//boost_stacktrace_backtrace ]
[ alias boost_stacktrace_basic : build//boost_stacktrace_basic ]
[ alias boost_stacktrace_from_exception : build//boost_stacktrace_from_exception ]
[ alias boost_stacktrace_noop : build//boost_stacktrace_noop ]
[ alias boost_stacktrace_windbg : build//boost_stacktrace_windbg ]
[ alias boost_stacktrace_windbg_cached : build//boost_stacktrace_windbg_cached ]
[ alias boost_stacktrace : boost_stacktrace_noop ]
[ alias all :
boost_stacktrace_addr2line
boost_stacktrace_backtrace
boost_stacktrace_basic
boost_stacktrace_from_exception
boost_stacktrace_noop
boost_stacktrace_windbg
boost_stacktrace_windbg_cached
test
]
;

call-if : boost-library stacktrace
: install
boost_stacktrace_addr2line
boost_stacktrace_backtrace
boost_stacktrace_basic
boost_stacktrace_from_exception
boost_stacktrace_noop
boost_stacktrace_windbg
boost_stacktrace_windbg_cached
;
36 changes: 24 additions & 12 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
# http://www.boost.org/LICENSE_1_0.txt)
#

require-b2 5.0.1 ;
import-search /boost/config/checks ;
import config : requires ;
import feature ;
import property ;
import ../../config/checks/config : requires ;

constant boost_dependencies_private :
<library>/boost/assert//boost_assert
;

project
: source-location .
: common-requirements $(boost_dependencies)
: requirements
[ requires cxx11_rvalue_references ]
$(boost_dependencies_private)
: default-build
<visibility>hidden
;
Expand All @@ -26,10 +33,10 @@ feature.feature boost.stacktrace.from_exception : on off : optional propagated ;

local LIBBACKTRACE_PATH = [ modules.peek : LIBBACKTRACE_PATH ] ;
lib backtrace
:
:
: <search>$(LIBBACKTRACE_PATH)/lib <link>static
:
: <include>$(LIBBACKTRACE_PATH)/include
: <include>$(LIBBACKTRACE_PATH)/include
;

actions mp_simple_run_action
Expand Down Expand Up @@ -67,6 +74,7 @@ lib boost_stacktrace_noop
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

lib boost_stacktrace_backtrace
Expand All @@ -77,10 +85,11 @@ lib boost_stacktrace_backtrace
<target-os>linux:<library>dl
<library>backtrace
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds ../build//libbacktrace : : <build>no ]
[ check-target-builds libbacktrace : : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

lib boost_stacktrace_addr2line
Expand All @@ -90,10 +99,11 @@ lib boost_stacktrace_addr2line
<warnings>all
<target-os>linux:<library>dl
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds ../build//addr2line : : <build>no ]
[ check-target-builds addr2line : : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

lib boost_stacktrace_basic
Expand All @@ -103,10 +113,11 @@ lib boost_stacktrace_basic
<warnings>all
<target-os>linux:<library>dl
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds ../build//WinDbg : <build>no ]
[ check-target-builds WinDbg : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

lib boost_stacktrace_windbg
Expand All @@ -116,10 +127,11 @@ lib boost_stacktrace_windbg
<warnings>all
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds ../build//WinDbg : : <build>no ]
[ check-target-builds WinDbg : : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

lib boost_stacktrace_windbg_cached
Expand All @@ -129,10 +141,11 @@ lib boost_stacktrace_windbg_cached
<warnings>all
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds ../build//WinDbgCached : : <build>no ]
[ check-target-builds WinDbgCached : : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

rule build-stacktrace-from-exception ( props * )
Expand Down Expand Up @@ -162,10 +175,9 @@ lib boost_stacktrace_from_exception
<conditional>@build-stacktrace-from-exception

# Require usable libbacktrace on other platforms
#[ check-target-builds ../build//libbacktrace : : <build>no ]
# [ check-target-builds libbacktrace : : <build>no ]
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

boost-install boost_stacktrace_noop boost_stacktrace_backtrace boost_stacktrace_addr2line boost_stacktrace_basic boost_stacktrace_windbg boost_stacktrace_windbg_cached boost_stacktrace_from_exception ;
6 changes: 3 additions & 3 deletions doc/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import doxygen ;

doxygen autodoc
:
[ glob ../../../boost/stacktrace.hpp ]
[ glob ../../../boost/stacktrace/*.hpp ]
[ glob ../../../boost/stacktrace/detail/frame_decl.hpp ]
[ glob ../include/boost/stacktrace.hpp ]
[ glob ../include/boost/stacktrace/*.hpp ]
[ glob ../include/boost/stacktrace/detail/frame_decl.hpp ]
:
<doxygen:param>EXTRACT_ALL=NO
<doxygen:param>HIDE_UNDOC_MEMBERS=YES
Expand Down
2 changes: 1 addition & 1 deletion example/user_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#define BOOST_USER_CONFIG <libs/stacktrace/example/user_config.hpp>
#define BOOST_USER_CONFIG <example/user_config.hpp>

#include <boost/array.hpp>
#include <exception> // std::set_terminate, std::abort
Expand Down
17 changes: 13 additions & 4 deletions test/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
# http://www.boost.org/LICENSE_1_0.txt)
#

import ../../config/checks/config : requires ;
import-search /boost/config/checks ;
import config : requires ;
import testing ;

lib dl : : <link>shared ;
lib gcc_s ;
Expand All @@ -31,6 +33,8 @@ project
<warnings>all
<test-info>always_show_run_output
<visibility>hidden
<include>..
<library>/boost/optional//boost_optional
;

local FORCE_SYMBOL_EXPORT = <target-os>freebsd:<linkflags>"-rdynamic" <target-os>solaris:<linkflags>"-Bdynamic" <target-os>aix:<linkflags>"-rdynamic"
Expand Down Expand Up @@ -122,15 +126,19 @@ test-suite stacktrace_tests
[ run thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_backtrace $(LINKSHARED_BT)
<define>BOOST_STACKTRACE_BACKTRACE_FORCE_STATIC
<library>/boost/optional//boost_optional
: backtrace_lib_threaded_static ]
[ run thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_windbg $(LINKSHARED_WIND)
<library>/boost/optional//boost_optional
: windbg_lib_threaded ]
[ run thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_windbg_cached $(LINKSHARED_WIND_CACHED)
<library>/boost/optional//boost_optional
: windbg_cached_lib_threaded ]
[ run thread_safety_checking.cpp
: : : <debug-symbols>on <library>.//test_impl_lib_basic $(LINKSHARED_BASIC)
<library>/boost/optional//boost_optional
: basic_lib_threaded ]

##### Tests with disabled debug symbols #####
Expand Down Expand Up @@ -158,6 +166,7 @@ test-suite stacktrace_tests
[ run thread_safety_checking.cpp
: : : <debug-symbols>off
<library>.//test_impl_lib_backtrace_no_dbg
<library>/boost/optional//boost_optional
$(LINKSHARED_BT)
: backtrace_lib_no_dbg_threaded ]
[ run thread_safety_checking.cpp
Expand Down Expand Up @@ -212,15 +221,15 @@ test-suite stacktrace_tests
for local p in [ glob ../example/*.cpp ]
{
local target_name = $(p[1]:B) ;
local additional_dependency = ;
local additional_dependency = <library>/boost/array//boost_array ;
if $(target_name) = "terminate_handler"
{
additional_dependency = <library>/boost/filesystem//boost_filesystem <library>/boost/system//boost_system <target-os>linux:<library>rt ;
additional_dependency += <library>/boost/filesystem//boost_filesystem <library>/boost/system//boost_system <target-os>linux:<library>rt ;
}

if $(target_name) = "throwing_st"
{
additional_dependency = [ requires rtti ] ;
additional_dependency += [ requires rtti ] <library>/boost/exception//boost_exception ;
}

stacktrace_tests += [ run $(p) : : : <debug-symbols>on $(LINKSHARED_BT) $(additional_dependency) : backtrace_$(p2[1]:B) ] ;
Expand Down

0 comments on commit ad121db

Please sign in to comment.