Boost logo

Boost-Build :

Subject: [Boost-build] Automatic version number or build-id
From: Niklas Angare (li51ckf02_at_[hidden])
Date: 2015-09-19 09:15:52


Hi,

I'm trying to get Boost.Build to generate a source file at build time
containing an automatically generated version number or build-id. I have a
solution that sort of works. However it causes my exe to be rebuilt every
time I invoke b2. I would like the source file to be generated only when the
exe is built. And of course it needs to be generated every time the exe is
built. How do I accomplish that?

Are there examples of this having been done before? I would assume so but I
haven't been able to find any.

Here's what I have so far:

explicit BuildTime2.cpp ;

always BuildTime2.cpp ;

time = [ SHELL "sh BuildTime.sh" ] ;

make BuildTime2.cpp : : @buildtimecpp ;
actions buildtimecpp
{
    echo const char* g_BuildTime = "$(time)"; >"$(<)"
}

exe MyExe :
        BuildTime2.cpp
        ...

Regards,

Niklas Angare


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