Boost logo

Boost-Build :

From: Rene Rivera (grafik666_at_[hidden])
Date: 2003-10-13 15:07:24


[2003-10-13] Peter Steiner wrote:

>I'm using Boost.Build successfully in an embedded project.
>
>I would like to define an additional transformation for stripping my
>executables. What would be the best way?

The short answer is, yes you can. The long answer depends on which version
of BB you are using. Given your previous post about v1, and that's the
version I can talk about confidently, I'll answer for the BBv1 case.

>I'm debugging my applications remotely using gdbserver. My scenario:
>- my executables get built with debug information
>- copy and strip the executables (with i386-linux-strip)
>- transfer the stripped executable to the embedded system and debug;
> the original executable is needed on my PC to provide the debugging
> informations.
>
>Questions:
>- The two kinds of executables have the same name (with no extension
> as it is common under linux), but live in different directories.
> Can Boost.Build handle that?

Yes.. BBv1 targets have the directory as part of the target ID (in the
grist: <>).

>- How can I define an additional transformation and where should I put
> it?

The easiest way to do this is to define a new top level target that depends
on the "exe" target. I do this on my project to create Linux shared
libraries with extra processing. If you look at the EXE targets, in
boost-base.jam, you can see what you need to define:

gTARGET_TYPE_ID(exe) = EXE ;
gGENERATOR_FUNCTION(EXE) = executable-file ;
rule exe ( target : sources + : requirements * : default-build * )
{
declare-local-target $(target) : $(sources) : $(requirements) :
$(default-build) : EXE ;
}

You probably want something like this (in your Jamrules file):

gTARGET_TYPE_ID(embeded-exe) = EMBEDED_EXE ;
gGENERATOR_FUNCTION(EMBEDED_EXE) = embeded-executable-file ;
rule embeded-exe ( target : sources + : requirements * : default-build * )
{
local gIS_DEPENDENCY(EXE) = TRUE ;
declare-local-target $(target) : $(sources) : $(requirements) :
$(default-build) : EMBEDED_EXE ;
}

The "gIS_DEPENDENCY(EXE)" assignment is needed because exe targets don't
normally generate dependency information for other targets (stage hacks
around this also). And it allows you to place "<exe>something" in your new
embeded-exe target as a source.

Next you need to define the generator rule, most of this is modified from
"main-from-objects" which executable-file calls:

rule embeded-executable-file ( target : sources * )
{
MakeLocate $(target) : $(LOCATE_TARGET) ;
local source-exe-target = [ get-values <EMBEDED_EXE> :
$(gTARGET_DEPS($(target)) ] ;
embeded-executable-action $(target) : $(source-exe-target) ;
Clean clean : $(target) ;
MODE on $(target) : $(EXEMODE) ;
Chmod $(target) ;
}

actions embeded-executable-action
{
## and here goes what you need to do copy/transfrom from $(>) to $(<)
cp "$(>)" "$(>)"
}

This is mostly off the top of my head... i.e. there are probably more
details. It's also possible to generalize this so that you can process/place
multiple <exe>'s into a single destination.

HTH.

-- grafik - Don't Assume Anything
-- rrivera (at) acm.org - grafik (at) redshift-software.com
-- 102708583 (at) icq

 


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