I tag my binaries with some git version information which aids release procedures
The resulting installed binary looks something like the following:
For interest's sake, this is the script:
readonly commits=$(git rev-list HEAD | wc -l | bc)
if [[ $(git diff --shortstat 2> /dev/null | tail -n1) != "" ]]; then
printf ${commits}${dirty}
In my Jamroot I define a path constant TOP so I can find my scripts:
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