Expose stacktrace libraries as build features (#202)

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 <uilianries@gmail.com>
This commit is contained in:
Uilian Ries
2025-01-18 11:26:21 +01:00
committed by GitHub
parent ea282324b8
commit 54934a386a
2 changed files with 39 additions and 0 deletions

View File

@@ -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 ;

View File

@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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