Boost logo

Boost-Build :

From: Christopher Currie (Christopher_at_[hidden])
Date: 2004-03-19 17:33:07


Quan,

I spent a lot of time working on this problem, for the xsd2cpp tool that
also comes with LEIF. I went through a number of different iterations,
and eventually settled on the usage below. It should be adaptable to
wsdl2cpp without much trouble.

The usage is probably not all you'd like, but it works the best of all
the approaches I've tried. The key is that you have to specify the names
of all the source files that the tool generates, because there really
isn't any way we can expect bjam to deduce them. An example Jamfile
would look like:

# Jamfile

SOURCES = one two three ;

schema myschema
: myschema.xsd
: $(SOURCES).cpp $(SOURCES).h
: <ol:config>xsdconfig.xml
;

lib libmyschema : myschema : : <dependency>myschema
<implicit-dependency>myschema ;

# end of Jamfile

The apparently redundant usage-requirements are necessary to achieve two
goals. The <dependency> property ensures that the schema gets built
first, so that sources that use the library's header files will have
them available. The <implicit-dependency> property puts the path to the
generated headers in the include path of dependent main-targets.

The file that implements the schema rule is below. Adapting it to
process wsdl files *should* be trivial, but let me know if you have trouble.

Good luck!
Christopher

# objectlink.jam

import "class" : new ;
import feature ;
import toolset : flags ;
import targets ;
import type ;
import virtual-target ;

class xsd-cpp-target-class : basic-target
{
import sequence ;
import regex ;
import type ;
import virtual-target ;

rule __init__ ( name : project : targets * : source : requirements *
: default-build * : usage-requirements *
)
{
basic-target.__init__ $(name) : $(project) : $(source)
: $(requirements) : $(default-build) : $(usage-requirements)
;

self.targets = $(targets) ;
self.file-targets = ;
}

rule construct ( schema-target : property-set )
{
if ! $(self.file-targets)
{
for local name in $(self.targets)
{
local _t = [ new file-target $(name:S=)
: [ type.type $(name) ]
: $(self.project)
] ;
$(_t).suffix = [ regex.match .(.*) : $(self.name:S) ] ;

# This is needed so the generators know where to find
# the headers but don't complain about unused sources
if [ type.is-derived [ type.type $(name) ] H ]
{
$(_t).set-itermediate true ;
}

virtual-target.register $(_t) ;
self.file-targets += $(_t) ;
}

# This has to be done separately from the for loop above,
# because the action must know about ALL the virtual-targets
# it generates, and all the virtual-targets must have the
# same action
#
# Third argument binds action to the schema-compile rule
local _a = [ new action $(self.file-targets)
: $(schema-target)
: objectlink.schema-compile
: $(property-set)
] ;

for local name in $(self.file-targets)
{
$(name).action $(_a) ;
}
}
return $(self.file-targets) ;
}
}

rule schema ( name
: source # only one!
: targets + # the generated sources and headers
: requirements *
: default-build *
: usage-requirements *
)
{
local project = [ CALLER_MODULE ] ;

return [ targets.main-target-alternative
[ new xsd-cpp-target-class $(name) : $(project) : $(targets)
: [ targets.main-target-sources $(source) : $(name) ]
: [ targets.main-target-requirements $(requirements)
: $(project) ]
: [ targets.main-target-default-build $(default-build)
: $(project) ]
: [ targets.main-target-usage-requirements $(usage-requirements)
: $(project) ]
]
] ;
}
IMPORT $(__name__) : schema : : schema ;

feature.feature ol:config : : free path incidental ;
feature.feature ol:docsdir : : free path incidental ;
feature.feature ol:docs : on off : incidental ;
feature.feature ol:make : on off : incidental ;

# Note "flags" don't work, because it's not a "toolset"

rule schema-compile
{
_ on $(targets) = " " ;

CONFIG on $(targets) = [ feature.get-values <ol:config>
: $(properties) ] ;

if off in [ feature.get-values <ol:docs> : $(properties) ]
{
OPTIONS on $(targets) += "-nohtml" ;
}
else
{
DOCSDIR on $(targets) = [ feature.get-values <ol:docsdir>
: $(properties) ] ;
}

if off in [ feature.get-values <ol:make> : $(properties) ]
{
OPTIONS on $(targets) += "-nomake" ;
}
}

# xsd2cpp doesn't touch files if they don't need to change, which mucks
# up dependency tracking, causing bjam to rebuild the schema every time
actions schema-compile
{
xsd2cpp -outdir "$(<[1]:D)" "-config$(_)$(CONFIG)" \
"-docsdir$(_)$(DOCSDIR)" $(OPTIONS) "$(>)" && touch "$(<)"
}

quancta wrote:
> Hi BJam'ers,
>
> I am working on a project that use RogueWave LEIF tool to generate
> C++ code from a webservice schema with this command:
> wsdl2cpp.bat [options] webservice.wsdl
> which produces a bunches of CPP files that need to be compiled into
> a library. Hope someone can help me with the target spec; how can
> I tell bjam that the targets is all the *.cpp files generated ?
>
> I have this module - test.jam as follow:
> #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> type.register WSDL : wsdl ;
> generators.register-standard test.wsdl : WSDL : CPP H ;
>
> rule wsdl ( targets * : sources * : properties * )
> {
> .leif_dir = C:/RogueWave/LEIF ;
> .leif_wsdl2cpp = $(.leif_dir)/bin/wsdl2cpp.bat -noserver -nosample
> -nossl -nohtml -SourcePro ;
> }
>
> actions wsdl
> {
> del /Q $(<[1]:D)\\*.cpp $(<[1]:D)\\*.h
> $(.leif_wsdl2cpp) -outdir $(<[1]:D) $(>)
> }
> #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Then in my Jamfile:
> lib webservice : webservice.wsdl ;
>
> but that will only get me webservice.cpp into the build. I've trying
> with glob, etc., but haven't figured out anything that work.
>
> TIA,
> Quan

 


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