From 54934a386aee807f58dc88d9ffff992c1872f7ac Mon Sep 17 00:00:00 2001 From: Uilian Ries Date: Sat, 18 Jan 2025 11:26:21 +0100 Subject: [PATCH] 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 --- boost-stacktrace-features.jam | 6 ++++++ build/Jamfile.v2 | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/boost-stacktrace-features.jam b/boost-stacktrace-features.jam index db1cd4e..b3bf83a 100644 --- a/boost-stacktrace-features.jam +++ b/boost-stacktrace-features.jam @@ -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 ; diff --git a/build/Jamfile.v2 b/build/Jamfile.v2 index ce57c34..39c511b 100644 --- a/build/Jamfile.v2 +++ b/build/Jamfile.v2 @@ -63,12 +63,24 @@ explicit WinDbg ; mp-run-simple has_windbg_cached.cpp : : : Dbgeng ole32 : WinDbgCached ; explicit WinDbgCached ; +rule build-stacktrace-feature ( name : props * ) +{ + local enabled = [ property.select : $(props) ] ; + switch $(enabled:G=) + { + case "on" : return ; + case "off" : return no ; + } +} + lib boost_stacktrace_noop : # sources ../src/noop.cpp : # requirements all shared:BOOST_STACKTRACE_DYN_LINK=1 + # Enable build when explicitly requested + @$(build-stacktrace-feature noop) : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1 @@ -84,12 +96,29 @@ lib boost_stacktrace_backtrace backtrace shared:BOOST_STACKTRACE_DYN_LINK=1 [ check-target-builds libbacktrace : : no ] + @$(build-stacktrace-feature backtrace) : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1 BOOST_STACKTRACE_NO_LIB=1 ; +rule build-stacktrace-addr2line ( props * ) +{ + local enabled = [ property.select : $(props) ] ; + switch $(enabled:G=) + { + case "on" : return ; + case "off" : return no ; + } + + # Disable by default on Windows when not using Cygwin + if windows in $(props) && ! ( cygwin in $(props) ) + { + return no ; + } +} + lib boost_stacktrace_addr2line : # sources ../src/addr2line.cpp @@ -98,6 +127,7 @@ lib boost_stacktrace_addr2line linux:dl shared:BOOST_STACKTRACE_DYN_LINK=1 [ check-target-builds addr2line : : no ] + @build-stacktrace-addr2line : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1 @@ -112,6 +142,7 @@ lib boost_stacktrace_basic linux:dl shared:BOOST_STACKTRACE_DYN_LINK=1 [ check-target-builds WinDbg : no ] + @$(build-stacktrace-feature basic) : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1 @@ -126,6 +157,7 @@ lib boost_stacktrace_windbg Dbgeng ole32 shared:BOOST_STACKTRACE_DYN_LINK=1 [ check-target-builds WinDbg : : no ] + @$(build-stacktrace-feature windbg) : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1 @@ -140,6 +172,7 @@ lib boost_stacktrace_windbg_cached Dbgeng ole32 shared:BOOST_STACKTRACE_DYN_LINK=1 [ check-target-builds WinDbgCached : : no ] + @$(build-stacktrace-feature windbg-cached) : # default build : # usage-requirements #shared:BOOST_STACKTRACE_DYN_LINK=1