Boost logo

Boost-Build :

From: Phillip Seaver (phil_at_[hidden])
Date: 2006-09-21 08:22:42


K. Noel Belcourt wrote:
> On Sep 20, 2006, at 6:48 AM, Phillip Seaver wrote:
>
>
>> K. Noel Belcourt wrote:
>>
>>> I'd like to invoke a bjam built executable in an actions.
>>>
>> Here's something that I use. It may not be the best way to do things,
>> but it works for me. :-)
>>
>> exe bin2c : bin2c.c ;
>> make Splash.h : bin2c Splash.png : bin2c_run ;
>> actions bin2c_run
>> {
>> $(>[1]) $(>[2-]) $(<)
>> }
>>
>>
>> The "make" command here creates Splash.h using bin2c and Splash.png as
>> source files with bin2c_run as the commands to run. Since it's using
>> the target "bin2c" as a source file, it has to build it first, so it
>> compiles bin2c before trying to run it. :-)
>>
>> "actions bin2c_run" gets the full path of the bin2c executable as the
>> first item in the source argument "$(>[1])" and uses the rest of the
>> source arguments "$(>[2-])" and the output argument "$(<)" as the
>> arguments to bin2c, so on Windows you get a command like:
>>
>> bin\msvc-7.1\debug\link-static\threading-multi\bin2c.exe
>> Splash.png
>> msvc-7.1\debug\link-static\threading-multi\Splash.h
>>
>
> It does help. The only thing I can't figure out is how to call an
> actions from a rule. If I define a rule like your 'make' rule above,
> how do I call the action from within the rule?
>
> This is probably easy to do but I don't see how.
>
> -- Noel
The "make" rule above has "bin2c_run", which tells bb to use those
commands for creating Splash.h. All you have to do is reference the
target of the make rule. In my case, I use
<implicit-dependency>Splash.h on the exe rule that includes it. If
you're generating a source file, you would just add it to the sources of
the target that uses it.

    exe gen_c : gen_c.c ;
    make foo.c : gen_c gen_c_source.x : gen_c_run ;
    actions gen_c_run
    {
        $(>[1]) $(>[2-]) $(<)
    }
    exe use_c : use_c.c foo.c ;

Phillip


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