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 ;
19 type.register GCI : gci ;
21 feature.feature server : off on : incidental ;
23 class soap-generator : generator
25 import "class" : new ;
27 rule __init__ ( * : * )
29 generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
32 rule run ( project name ? : property-set : sources * )
36 # Accept only single source.
37 local t = [ $(sources[1]).type ] ;
40 # The type is correct.
42 # If no output name is specified, guess it from sources.
45 name = [ generator.determine-output-name $(sources) ] ;
48 # Produce one output, using just copy.
49 local a = [ new action $(sources[1])
50 : common.copy : $(property-set) ] ;
51 local t = [ new file-target $(name) : CPP : $(project)
54 # If in server mode, create another output -- an
55 # empty file. If this were a real SOAP generator, we
56 # might have created a single action, and two targets
57 # both using that action.
59 if [ $(property-set).get <server> ] = "on"
61 local a = [ new action : soap.touch : $(property-set) ] ;
62 t2 = [ new file-target $(name)_server : CPP : $(project)
65 return [ virtual-target.register $(t) ]
66 [ virtual-target.register $(t2) ] ;
72 generators.register [ new soap-generator soap.soap : GCI : CPP ] ;
74 TOUCH = [ common.file-touch-command ] ;