|
Boost-Build : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-02-15 09:39:59
Vladimir Prus <ghost_at_[hidden]> writes:
> On Saturday 12 February 2005 23:31, David Abrahams wrote:
>> testing.jam now contains a new rule called "time" that can be used to
>> measure the length of a build step (including a step that runs an
>> executable). For example:
>>
>> import testing ;
>>
>> compile c.cpp ;
>> obj c-obj : c.cpp ;
>> compile-fail c-f.cpp ;
>> run r.cpp : : dir/input.txt ;
>> run-fail r-f.cpp ;
>> time execution : r ; # <- here
>> time compilation : c-obj ; # <- here
>
> Cool. Do I understand that it only measures the time to build the top-level
> target (here, 'r' and 'c-obj' and does not include any dependencies?). E.g.
> for
>
> time build_time : program_options ;
>
> I get:
>
> user: [program_options-gcc-d_1.32.0.so.1.32.0] 0.000023
> system: [program_options-gcc-d_1.32.0.so.1.32.0] 0.000015
>
> which is time for linking, not for full build.
Yes. It might be nice to accumulate the different times for
dependencies and stick that in some other variables so you can get the
net gross time for any item, but that would require making REBUILDS
call on all dependencies, transitively.
>> Volodya, regarding the above, I found it impossible to time the
>> compilation of the object file created as a result of
>>
>> compile c.cpp
>>
>> because there was no way to name the intermediate OBJ target
>> produced. Adding
>>
>> obj c : c.cpp ;
>> time c-compilation : c.obj ;
>>
>> doesn't work, and neither does
>>
>> time c-compilation : c ;
>
> For a Jamroot that contains only:
>
> obj c : c.cpp ;
> time c-compilation : c ;
>
> I get:
>
> gcc.compile.c++ bin/gcc/debug/c.o
> testing.time bin/gcc/debug/c-compilation.time
> user: [c.o] 0.000002
> system: [c.o] 0.000002
>
> What does not work in your case.
compile c.cpp ;
obj c : c.cpp ;
time c-compilation : c.obj ;
>> I'm a little confused about what's going on here -- it seems as though
>> we're being stopped by the built-in limitation that says two main
>> targets can't have the same name. But surely it ought to be possible
>> to write
>>
>> obj c : c.cpp ;
>> exe c : c.obj ;
>>
>> or something very similar and simple. No?
>
> It's hard to guess if user meant two alternatives or two independent targets.
> I though we need to allow some 'grist' in this cases, say:
>
> obj c.obj : c.cpp ; <- note 'obj' here.
> exe c : c.obj ;
>
> When calling generator, we should strip the ".obj" from "c.obj" so that suffix
> can actually vary between platforms. What do you think?
That sounds reasonable. But then all of the following build requests
should also be possible:
bjam c.obj
bjam c.exe
bjam c # builds the exe
and on unix,
bjam c.o
should probably work.
Similarly, if you wrote:
obj c.o : c.cpp ;
obj c : c.o ;
then
bjam c.obj
should probably work on Windows.
So to translate that into what I'm doing, this should work:
compile c.cpp ;
obj c.obj : c.cpp ;
time c-compilation : c.obj ;
and only one copy of c.obj (or c.o if on Unix) should be built.
-- Dave Abrahams Boost Consulting www.boost-consulting.com
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