Boost logo

Boost-Build :

Subject: Re: [Boost-build] Automatic version number or build-id
From: Vladimir Prus (vladimir.prus_at_[hidden])
Date: 2015-09-29 00:15:52


On 29-Sep-15 12:36 AM, Niklas Angare wrote:
> "Vladimir Prus" <vladimir.prus_at_[hidden]> wrote:
>> On 26-Sep-15 1:22 AM, Niklas Angare wrote:
>>> "Vladimir Prus" <vladimir.prus_at_[hidden]> wrote:
>>>> On 19-Sep-15 4:15 PM, Niklas Angare wrote:
>>>>> I'm trying to get Boost.Build to generate a source file at build time containing an automatically generated version
>>>>> number or build-id.
> ...
>>
>> You're correct, I've declared victory too early. The below example should work better, it's modified in two ways:
>
> I think you forgot to insert the example :)

Indeed. Here we go:

import notfile ;
import property-set ;
import type ;

exe hello : hello.cpp hello2.cpp build-id ;

obj build-id : build-id.cpp ;

make build-id.cpp : : @generate-build-id ;

rule generate-build-id
{
     REV on $(<) = [ SHELL "git rev-parse --short HEAD" : strip-eol ] ;
}

actions generate-build-id
{
     echo // Revision is $(REV) > $(<)
}

explicit build-id build-id.cpp ;

generate setup-build-id-rebuild : hello build-id.cpp : <generating-rule>@setup-rebuild ;

rule setup-rebuild ( project name : property-set : sources * )
{
     local exe = [ $(sources[1]).actualize-no-scanner ] ;
     local scanner = [ type.get-scanner CPP : $(property-set) ] ;
     local cpp1 = [ $(sources[-1]).actualize $(scanner) ] ;
     local cpp2 = [ $(sources[-1]).actualize-no-scanner ] ;

     REBUILDS $(exe) : $(cpp1) $(cpp2) ;

     return [ property-set.empty ] ;
}


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