You remove always BuildTime2.cpp ; and change
make BuildTime2.cpp : : @buildtimecpp ;
to
make BuildTime2.cpp : : @buildtimecpp : <dependency>$(myfiles) ;

example:

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

exe MyExe : main.cpp second.cpp BuildTime2.cpp ;



On Sat, Sep 19, 2015 at 10:17 AM Niklas Angare <li51ckf02@sneakemail.com> wrote:
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


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build