Boost logo

Boost-Build :

Subject: [Boost-build] Using properties of a concrete target
From: Niklas Angare (li51ckf02_at_[hidden])
Date: 2015-09-19 12:50:09

I need to post-process my executable after linking to separate the debug
symbols into a separate file, among other things. I have a basic version
(shown below) working but I would like to make some improvements.

The post-processing action needs to know which <architecture> the concrete
target is being built for. I have created an associated rule that checks the
property and sets a variable that the action has access to. This works as
long as I'm building for one architecture at a time, but when I build for
more than one architecture at the same time with "b2 architecture=x86,arm",
my variable gets the value corresponding to the last specified architecture
for both concrete targets. How do I solve this?

I would also like to use different actions depending on the value of the
<target-os> property. I'm guessing it could be done by having two different
generating-rules (generate-postprocess-linux and generate-postprocess-qnx
for example). But that would complicate the specification of each executable
target which I would prefer not to do as I have multiple executables that
need post-processing.

The code is below. The interesting part comes after the project

using qcc ;

project t
    : requirements
    : default-build

exe ProgramRaw : main.cpp : ;

generate Program
: ProgramRaw
: <generating-rule>@generate-postprocess

# For debugging
always Program ;

import "class" : new ;

rule generate-postprocess ( project name : property-set : source )
    local result ;

    # Create a new action
    local a = [ new non-scanning-action $(source) :
        $(__name__).postprocess : $(property-set) ] ;

    # Create a target to represent the action result. Uses the target name
    # passed here via the 'name' parameter and the same type and project as
    # the source.
    result += [ new file-target $(name) : [ $(source).type ] :
        $(project) : $(a) ] ;
    return $(result) ;

rule postprocess ( target : sources * : properties * )
    if <architecture>x86 in $(properties)
        qnxarch = x86 ;
    else if <architecture>arm in $(properties)
        qnxarch = armv7 ;

    toolprefix = nto$(qnxarch)- ;

actions postprocess
    $(toolprefix)objcopy --only-keep-debug "$(>)" "$(<)".sym
    $(toolprefix)objcopy --strip-debug --add-gnu-debuglink="$(<)".sym "$(>)"


Niklas Angare

Boost-Build list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at