summaryrefslogtreecommitdiffstats
path: root/src/boost/tools/build/example/generator/soap.jam
blob: d53f3a54d97bd39269aca7e8723ca658671fafae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Copyright 2006 Vladimir Prus
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE.txt or https://www.bfgroup.xyz/b2/LICENSE.txt)

# This is example of a fictional code generator tool.
# It accepts a single input of type '.gci' and produces
# either one or two outputs of type .cpp, depending
# on the value of the feature <server-mode>
#
# This example is loosely based on gSOAP code generator.

import type ;
import generators ;
import feature ;
import common ;
import "class" : new ;
import os ;

type.register GCI : gci ;

feature.feature server : off on : incidental ;

class soap-generator : generator
{
    import "class" : new ;

    rule __init__ ( * : * )
    {
        generator.__init__ $(1) : $(2) : $(3) : $(4) : $(5) : $(6) : $(7) : $(8) : $(9) ;
    }

    rule run ( project name ? : property-set : sources * )
    {
        if ! $(sources[2])
        {
            # Accept only single source.
            local t = [ $(sources[1]).type ] ;
            if $(t) = GCI
            {
                # The type is correct.

                # If no output name is specified, guess it from sources.
                if ! $(name)
                {
                    name = [ generator.determine-output-name $(sources) ] ;
                }

                # Produce one output, using just copy.
                local a = [ new action $(sources[1])
                  : common.copy : $(property-set) ] ;
                local t = [ new file-target $(name) : CPP : $(project)
                  : $(a) ] ;

                # If in server mode, create another output -- an
                # empty file. If this were a real SOAP generator, we
                # might have created a single action, and two targets
                # both using that action.
        local t2 ;
        if [ $(property-set).get <server> ] = "on"
        {
                    local a = [ new action : soap.touch : $(property-set) ] ;
                    t2 = [ new file-target $(name)_server : CPP : $(project)
                      : $(a) ] ;
                }
                return [ virtual-target.register $(t) ]
               [ virtual-target.register $(t2) ] ;
            }
        }
    }
}

generators.register [ new soap-generator soap.soap : GCI : CPP ] ;

TOUCH = [ common.file-touch-command ] ;
actions touch
{
    $(TOUCH) $(<)
}

if [ os.name ] = VMS
{
    actions touch
    {
        $(TOUCH) $(<:W)
    }
}