|
Boost-Build : |
From: Phillip Seaver (phil_at_[hidden])
Date: 2006-09-25 12:45:04
Vladimir Prus wrote, on 9/22/2006 1:50 AM:
> On Friday 22 September 2006 01:05, Phillip Seaver wrote:
>
>> Has anyone used boost-build to create jar files? One of my co-workers
>> is compiling .java files into .class files and then making a .jar file
>> out of the .class files. The problem is the paths in the class files.
>> He basically needs to strip off everything but the original relative
>> path. E.g., for apago/foo.java, he gets
>> ....../link-static/threading-multi/apago/foo.class and he needs to pass
>> just apago/foo.class to the jar creation program.
>>
>
> Isn't this the matter for passing right -C options to jar? Of course,
> computing the right options might not be straight-forward. Or maybe not --
> would
>
> jar
> -C ..../link-static/threading-multi
> <all .class file>
>
> work?
>
> - Volodya
Not quite. javac creates filenames relative to the source directory, so
for ./apago/foo.java, "javac -d {build-dir}" creates
{build-dir}/apago/foo.class. So, I think I need my own javac generator
that "knows" where the output files end up. As I understand it, I'll
need to override the "run" method to accomplish this. I'll then need to
make the .class filenames I pass to the jar command relative to the .jar
file.
Here's what I have in my class's run method:
rule run ( project name ? : property-set : sources * )
{
local s = $(sources[1]) ;
local a = [ new action $(s) : java.javac :
$(property-set) ] ;
name ?= [ $(s).name ] ;
local sp = [ $(s).project ] ;
local source-root = [ $(sp).get source-location ] ;
source-root = [ path.root $(source-root) [ path.pwd ] ] ;
local d = $(s).path ;
d = [ path.root $(name:D) $(d) ] ;
d = [ path.root $(d) [ path.pwd ] ] ;
local relative = [ path.relative-to $(source-root) $(d) ] ;
local targets = [ new file-target $(name:D=$(relative))
: CLASS : $(project) : $(a) ] ;
return $(targets) ;
}
Am I on the right track? Or do I need to go somewhere else and start
again? :-)
Thanks,
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