Boost logo

Boost-Build :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-06-24 00:57:57


Hi Emiliano,

> jar -c $(build-dir)/bin/jdk/debug/somejar.jar -C $(build-
> dir)/bin/jdk/debug com/pack1/pack2/Vector.class
> com/pack1/pack2/Quaternion.class
>
> I added a build-dir feature and binded it at the action so I can do
>
> jar -c $(<) -C $(BUILDDIR) $(>)
>
> The thing is that $(>) gets expanded to $(build-
> dir)/bin/jdk/debug/com/pack1/pack2/Vector.class and $(build-
> dir)/bin/jdk/debug/com/pack1/pack2/Quaternion.class which is not a
> relative path to $(build-dir)/bin/jdk/debug so it doesnt work.
...
> Ive been hitting my head against the wall with this. I tried to
> create a new derivate of file-target, so I overload the actualize-
> location rule, but this will affect the compilation and I don't want
> that. Is there a way AFTER it compiled the sources, reset the LOCATE
> on $(target)?

Well, you can't reset LOCATE in an easy way. Besides, if you reset LOCATE,
then bjam won't find the target when it invokes the action.

The problem you have if that the tool requires non-standard way of describing
sources, so the problem is better solved as close to the tool as possible --
preferrable in the actions code.

I attach a stetch of solution, which generates this command line:

jar -C bin gcc/debug/a.class

That is a source is relative to "bin". You would have to write your "jar" rule
in a was similiar to 'test-names" in my Jamfile, and of course, change
hardcoded "bin" ;-)

This is not 100% right solution -- because it works only if *.class targets
have LOCATE set. However, fixing that might require core Jam changes, so I
think it makes sense to use this code until somebody wants to jar *.class
files which are not generated.

HTH,
Volodya

 --Boundary-00=_l1m2AxTMX//LyYV Content-Type: text/plain;
charset="iso-8859-1";
name="Jamfile"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="Jamfile"

make a : a.class : $(__name__).test-names ;
make a.class : hello.cpp : $(__name__).copy ;

import path ;

rule test-names ( targets * : sources * : properties * )
{
local SOURCES ;
for local s in $(sources)
{
# Try to guess the location of the source.
local l = [ on $(s) return $(LOCATE) ] ;

local relative = [ path.relative-to "bin"
[ path.make $(l) ] ] ;

SOURCES += [ path.native [ path.join $(relative) $(s:G=) ] ] ;
}
SOURCES on $(targets) = $(SOURCES) ;
}

actions test-names
{
jar -C bin $(SOURCES)
}

actions copy
{
cp $(>) $(<)
} --Boundary-00=_l1m2AxTMX//LyYV--


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