1 # Copyright 2006 Vladimir Prus
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
5 # This is example of a fictional code generator tool.
6 # It accepts a single input of type '.gci' and produces
7 # either one or two outputs of type .cpp, depending
8 # on the value of the feature <server-mode>
10 # This example is loosely based on gSOAP code generator.
16 import "class" : new ;
18 type.register GCI : gci ;
20 feature.feature server : off on : incidental ;
22 class soap-generator : generator
24 import "class" : new ;
26 rule __init__ ( * : * )
28 generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
31 rule run ( project name ? : property-set : sources * )
35 # Accept only single source.
36 local t = [ $(sources[1]).type ] ;
39 # The type is correct.
41 # If no output name is specified, guess it from sources.
44 name = [ generator.determine-output-name $(sources) ] ;
47 # Produce one output, using just copy.
48 local a = [ new action $(sources[1])
49 : common.copy : $(property-set) ] ;
50 local t = [ new file-target $(name) : CPP : $(project)
53 # If in server mode, create another output -- an
54 # empty file. If this were a real SOAP generator, we
55 # might have created a single action, and two targets
56 # both using that action.
58 if [ $(property-set).get <server> ] = "on"
60 local a = [ new action : soap.touch : $(property-set) ] ;
61 t2 = [ new file-target $(name)_server : CPP : $(project)
64 return [ virtual-target.register $(t) ]
65 [ virtual-target.register $(t2) ] ;
71 generators.register [ new soap-generator soap.soap : GCI : CPP ] ;
73 TOUCH = [ common.file-touch-command ] ;