Skip to content

Commit 54934a3

Browse files
authored
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 <[email protected]>
1 parent ea28232 commit 54934a3

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

boost-stacktrace-features.jam

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
#
77
import feature ;
88

9+
feature.feature boost.stacktrace.noop : on off : optional propagated ;
10+
feature.feature boost.stacktrace.backtrace : on off : optional propagated ;
11+
feature.feature boost.stacktrace.addr2line : on off : optional propagated ;
12+
feature.feature boost.stacktrace.basic : on off : optional propagated ;
13+
feature.feature boost.stacktrace.windbg : on off : optional propagated ;
14+
feature.feature boost.stacktrace.windbg_cached : on off : optional propagated ;
915
feature.feature boost.stacktrace.from_exception : on off : optional propagated ;

build/Jamfile.v2

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,24 @@ explicit WinDbg ;
6363
mp-run-simple has_windbg_cached.cpp : : : <library>Dbgeng <library>ole32 : WinDbgCached ;
6464
explicit WinDbgCached ;
6565

66+
rule build-stacktrace-feature ( name : props * )
67+
{
68+
local enabled = [ property.select <boost.stacktrace.$(name)> : $(props) ] ;
69+
switch $(enabled:G=)
70+
{
71+
case "on" : return ;
72+
case "off" : return <build>no ;
73+
}
74+
}
75+
6676
lib boost_stacktrace_noop
6777
: # sources
6878
../src/noop.cpp
6979
: # requirements
7080
<warnings>all
7181
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
82+
# Enable build when explicitly requested
83+
<conditional>@$(build-stacktrace-feature noop)
7284
: # default build
7385
: # usage-requirements
7486
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
@@ -84,12 +96,29 @@ lib boost_stacktrace_backtrace
8496
<library>backtrace
8597
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
8698
[ check-target-builds libbacktrace : : <build>no ]
99+
<conditional>@$(build-stacktrace-feature backtrace)
87100
: # default build
88101
: # usage-requirements
89102
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
90103
<define>BOOST_STACKTRACE_NO_LIB=1
91104
;
92105

106+
rule build-stacktrace-addr2line ( props * )
107+
{
108+
local enabled = [ property.select <boost.stacktrace.addr2line> : $(props) ] ;
109+
switch $(enabled:G=)
110+
{
111+
case "on" : return ;
112+
case "off" : return <build>no ;
113+
}
114+
115+
# Disable by default on Windows when not using Cygwin
116+
if <target-os>windows in $(props) && ! ( <target-os>cygwin in $(props) )
117+
{
118+
return <build>no ;
119+
}
120+
}
121+
93122
lib boost_stacktrace_addr2line
94123
: # sources
95124
../src/addr2line.cpp
@@ -98,6 +127,7 @@ lib boost_stacktrace_addr2line
98127
<target-os>linux:<library>dl
99128
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
100129
[ check-target-builds addr2line : : <build>no ]
130+
<conditional>@build-stacktrace-addr2line
101131
: # default build
102132
: # usage-requirements
103133
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
@@ -112,6 +142,7 @@ lib boost_stacktrace_basic
112142
<target-os>linux:<library>dl
113143
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
114144
[ check-target-builds WinDbg : <build>no ]
145+
<conditional>@$(build-stacktrace-feature basic)
115146
: # default build
116147
: # usage-requirements
117148
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
@@ -126,6 +157,7 @@ lib boost_stacktrace_windbg
126157
<library>Dbgeng <library>ole32
127158
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
128159
[ check-target-builds WinDbg : : <build>no ]
160+
<conditional>@$(build-stacktrace-feature windbg)
129161
: # default build
130162
: # usage-requirements
131163
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
@@ -140,6 +172,7 @@ lib boost_stacktrace_windbg_cached
140172
<library>Dbgeng <library>ole32
141173
<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1
142174
[ check-target-builds WinDbgCached : : <build>no ]
175+
<conditional>@$(build-stacktrace-feature windbg-cached)
143176
: # default build
144177
: # usage-requirements
145178
#<link>shared:<define>BOOST_STACKTRACE_DYN_LINK=1

0 commit comments

Comments
 (0)