Skip to content

Commit

Permalink
Expose stacktrace libraries as build features (#202)
Browse files Browse the repository at this point in the history
As I commented in the issue #195, this PR exposes all stacktrace libraries as boost features, mirroring what's available in the CMakeLists.txt in this project. So users will be able to build or not specific libraries present in this project. Here are some keypoints to evaluate these new changes:

- Added `build-stacktrace-feature` as generic rule validate on/off entry from users for each feature
- For `addr2line` I added a rule to disable in case using Windows and not Cygwin. It reflects the rule present in CMakeLists.txt: https://github.com/boostorg/stacktrace/blob/develop/CMakeLists.txt#L67

close #195

Signed-off-by: Uilian Ries <[email protected]>
  • Loading branch information
uilianries authored Jan 18, 2025
1 parent ea28232 commit 54934a3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boost-stacktrace-features.jam
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
#
import feature ;

feature.feature boost.stacktrace.noop : on off : optional propagated ;
feature.feature boost.stacktrace.backtrace : on off : optional propagated ;
feature.feature boost.stacktrace.addr2line : on off : optional propagated ;
feature.feature boost.stacktrace.basic : on off : optional propagated ;
feature.feature boost.stacktrace.windbg : on off : optional propagated ;
feature.feature boost.stacktrace.windbg_cached : on off : optional propagated ;
feature.feature boost.stacktrace.from_exception : on off : optional propagated ;
33 changes: 33 additions & 0 deletions build/Jamfile.v2
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,24 @@ explicit WinDbg ;
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
explicit WinDbgCached ;

rule build-stacktrace-feature ( name : props * )
{
local enabled = [ property.select <boost.stacktrace.$(name)> : $(props) ] ;
switch $(enabled:G=)
{
case "on" : return ;
case "off" : return <build>no ;
}
}

lib boost_stacktrace_noop
: # sources
../src/noop.cpp
: # requirements
<warnings>all
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
# Enable build when explicitly requested
<conditional>@$(build-stacktrace-feature noop)
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
Expand All @@ -84,12 +96,29 @@ lib boost_stacktrace_backtrace
<library>backtrace
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds libbacktrace : : <build>no ]
<conditional>@$(build-stacktrace-feature backtrace)
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
<define>BOOST_STACKTRACE_NO_LIB=1
;

rule build-stacktrace-addr2line ( props * )
{
local enabled = [ property.select <boost.stacktrace.addr2line> : $(props) ] ;
switch $(enabled:G=)
{
case "on" : return ;
case "off" : return <build>no ;
}

# Disable by default on Windows when not using Cygwin
if <target-os>windows in $(props) && ! ( <target-os>cygwin in $(props) )
{
return <build>no ;
}
}

lib boost_stacktrace_addr2line
: # sources
../src/addr2line.cpp
Expand All @@ -98,6 +127,7 @@ lib boost_stacktrace_addr2line
<target-os>linux:<library>dl
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds addr2line : : <build>no ]
<conditional>@build-stacktrace-addr2line
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
Expand All @@ -112,6 +142,7 @@ lib boost_stacktrace_basic
<target-os>linux:<library>dl
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds WinDbg : <build>no ]
<conditional>@$(build-stacktrace-feature basic)
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
Expand All @@ -126,6 +157,7 @@ lib boost_stacktrace_windbg
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds WinDbg : : <build>no ]
<conditional>@$(build-stacktrace-feature windbg)
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
Expand All @@ -140,6 +172,7 @@ lib boost_stacktrace_windbg_cached
<library>Dbgeng <library>ole32
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
[ check-target-builds WinDbgCached : : <build>no ]
<conditional>@$(build-stacktrace-feature windbg-cached)
: # default build
: # usage-requirements
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
Expand Down

0 comments on commit 54934a3

Please sign in to comment.