Boost logo

Boost-Build :

From: Bojan Resnik (resnikb_at_[hidden])
Date: 2005-11-01 10:14:33


 I am trying to implement ICU support for my projects. The problem I
am facing is resource generation. ICU has a tool that generates
resources from txt files and another that bundles the generated
resources into a single file. My goal is to be able to write something
like:
icu.bundle myapp : [ glob res/*.txt ] ;

and have ICU automatically generate a resource file for each txt
file, and a resource bundle named myapp that contains all these
resources.

I thought I had solved this rather elegantly, but as it turns out this
doesn't work as expected. For example, given the following

app/Jamfile.v2
-------------------
lib app : [ glob *.cpp ] ;
icu.bundle app : [ glob res/*.txt ] ;

import testing ;
unit-test app_test : test ;

app/test/Jamfile.v2
-------------------------
exe app_test : [ glob *.cpp ] ..//app/<link>static ;
icu.bundle test-bundle : [ glob ../res/*.txt ] ;

When Jam is run in the app folder, the resource files for app
library are generated correctly, but no resources are generated
neither for app_test, nor for its dependency ..//app/<link>static.
Below is an excerpt from the jam file I am using for ICU support.

I suspect I misunderstood the generators concept. Can someone please
shed some light on this?

--
Bojan Resnik
-----------------------------------------------
.genrb = ; # Path to the genrb tool
.gencmn = ; # Path to the gencmn tool
# Register ICU resource types
type.register icu.SOURCE : txt ;
type.register icu.RESOURCE : res ;
type.register icu.BUNDLE : dat ;
generators.register-standard icu.generate-resource : icu.SOURCE :
icu.RESOURCE ;
generators.register-composing icu.bundle-resource : icu.RESOURCE :
icu.BUNDLE ;
rule generate-resource ( targets + : sources * : properties * )
{
}
actions generate-resource
{
echo ICU resource: $(>)
"$(.genrb)" "-d$(<:D)" "$(>)"
}
actions quietly write-first-line
{
echo $(>:B)$(>:S) > "$(<)"
}
actions quietly piecemeal append-line
{
echo $(>:B)$(>:S) >> "$(<)"
}
rule bundle-resource ( targets + : sources * : properties * )
{
local dir = [ MATCH ^<p(.*)>$ : $(targets[1]:G) ] ;
local file = $(targets[1]:G=).lst ;
local list-file = [ path.native [ path.join $(dir) $(file) ] ] ;
LIST_FILE on $(targets) = $(list-file) ;
DATA_NAME on $(targets) = $(targets[1]:B) ;
LOCATE on $(list-file) = [ on $(targets[1]) return $(LOCATE) ] ;
DEPENDS $(targets) : $(list-file) ;
DEPENDS $(list-file) : $(sources) ;
DEPENDS $(list-file) : [ on $(targets[1]) return $(LOCATE) ] ;
TEMPORARY $(list-file) ;
write-first-line $(list-file) : $(sources[1]) ;
for local s in $(sources[2-])
{
append-line $(list-file) : $(s) ;
}
}
actions bundle-resource
{
echo ICU resource bundle: $(DATA_NAME)
"$(.gencmn)" "-s$(<:D)" "-d$(<:D)" "-n$(DATA_NAME)" 0
"$(LIST_FILE)" && $(.rm) "$(LIST_FILE)"
}
 

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