Boost logo

Boost-Build :

Subject: [Boost-build] [boost-build] post-build install step
From: Steve Lorimer (steve.lorimer_at_[hidden])
Date: 2015-06-30 20:17:41


I tag my binaries with some git version information which aids release
procedures

The resulting installed binary looks something like the following:

my_app.1234.dirty

For interest's sake, this is the script:

#!/bin/bash

readonly commits=$(git rev-list HEAD | wc -l | bc)
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
    readonly dirty=".dirty"
fi

printf ${commits}${dirty}

In my Jamroot I define a path constant TOP so I can find my scripts:

path-constant TOP : . ;

and I define a constant SHORT_TAG which is the output of the above script:

local short_tag = [ SHELL "$(TOP)/utils/bash/short_tag.sh" ] ;
constant SHORT_TAG : $(short_tag) ;

In order to tag the binaries, I have the following .notfile rule in each of
my binary-specific Jamfiles:

constant EXE : my_app ;

exe $(EXE)
: [ glob *.cpp ]
;

install install-target : $(EXE) : <location>. ;

notfile . : @tag-file : install-target : ;
actions tag-file
{
    $(TOP)/utils/bash/rm_tagged_output.sh $(>) short

    # create tagged version
    cp $(>) $(>).$(SHORT_TAG)
}

I have two minor annoyances with this:

1. install-target and tag-file action are duplicated in every Jamfile which
needs them. I would like to put this in the Jamroot, but simply moving it
doesn't work (I think because it depends on the current path and target
name) - is there any way to create a rule/aciton like this which can live
in the Jamroot and be called from Jamfiles?

2. every time I build, it will always call the tag-file action, instead of
only when the exe target is rebuilt. How can I make my tag-file action only
run when the exe is updated?

TIA
Steve



Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk