summaryrefslogtreecommitdiff
path: root/tools/build/v2/contrib/wxFormBuilder.jam
blob: c9ee2de729bb1f4bf888fefcbc41060c55e40be9 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
################################################################################
#
# Copyright (c) 2007-2008 Dario Senic, Jurko Gospodnetic.
#
# Use, modification and distribution is subject to the Boost Software
# License Version 1.0. (See accompanying file LICENSE_1_0.txt or
# http://www.boost.org/LICENSE_1_0.txt)
#
################################################################################

################################################################################
#
#   Boost Build wxFormBuilder generator tool module.
#
#   wxFormBuilder is a GUI designer tool for the wxWidgets library. It can then
# generate C++ sources modeling the designed GUI using the wxWidgets library
# APIs.
#
#   This module defines a wxFormBuilder project file type and rules needed to
# generate C++ source files from those projects. With it you can simply list
# wxFormBuilder projects as sources for some target and Boost Build will
# automatically convert them to C++ sources and process from there.
#
#   The wxFormBuilder executable location may be provided as a parameter when
# configuring this toolset. Otherwise the default wxFormBuilder.exe executable
# name is used located in the folder pointed to by the WXFORMBUILDER environment
# variable.
#
#   Current limitations:
#
#   * Works only on Windows.
#   * Works only when run via Boost Jam using the native Windows cmd.exe command
#     interpreter, i.e. the default native Windows Boost Jam build.
#   * Used wxFormBuilder projects need to have their output file names defined
#     consistently with target names assumed by this build script. This means
#     that their target names must use the prefix 'wxFormBuilderGenerated_' and
#     have no output folder defined where the base name is equal to the .fpb
#     project file's name.
#
################################################################################

################################################################################
#
# Implementation note:
#
#   Avoiding the limitation on the generated target file names can be done but
# would require depending on external tools to copy the wxFormBuilder project to
# a temp location and then modify it in-place to set its target file names. On
# the other hand wxFormBuilder is expected to add command-line options for
# choosing the target file names from the command line which will allow us to
# remove this limitation in a much cleaner way.
#                                                    (23.08.2008.) (Jurko)
#
################################################################################

import generators ;
import os         ;
import path       ;
import toolset    ;
import type       ;


################################################################################
#
# wxFormBuilder.generate()
# ------------------------
#
#   Action for processing WX_FORM_BUILDER_PROJECT types.
#
################################################################################
#
# Implementation notes:
#
#   wxFormBuilder generated CPP and H files need to be moved to the location
# where the Boost Build target system expects them so that the generated CPP
# file can be included into the compile process and that the clean rule
# succesfully deletes both CPP and H files. We expect wxFormBuilder to generate
# files in the same location where the provided WX_FORM_BUILDER_PROJECT file is
# located.
#                                                    (15.05.2007.) (Dario)
#
################################################################################

actions generate
{
    start "" /wait "$(EXECUTABLE)" /g "$(2)"
    move "$(1[1]:BSR=$(2:P))" "$(1[1]:P)"
    move "$(1[2]:BSR=$(2:P))" "$(1[2]:P)"
}


################################################################################
#
# wxFormBuilder.init()
# --------------------
#
#   Main toolset initialization rule called via the toolset.using rule.
#
################################################################################

rule init ( executable ? )
{
    if $(.initialized)
    {
        if $(.debug-configuration)
        {
            ECHO notice: [wxFormBuilder-cfg] Repeated initialization request
                (executable \"$(executable:E="")\") detected and ignored. ;
        }
    }
    else
    {
        local environmentVariable = WXFORMBUILDER ;

        if $(.debug-configuration)
        {
            ECHO notice: [wxFormBuilder-cfg] Configuring wxFormBuilder... ;
        }

        # Deduce the path to the used wxFormBuilder executable.
        if ! $(executable)
        {
            executable = "wxFormBuilder.exe" ;
            local executable-path = [ os.environ $(environmentVariable) ] ;
            if $(executable-path)-is-not-empty
            {
                executable = [ path.root $(executable) $(executable-path) ] ;
            }
            else if $(.debug-configuration)
            {
                ECHO notice: [wxFormBuilder-cfg] No wxFormBuilder path
                    configured either explicitly or using the
                    $(environmentVariable) environment variable. ;
                ECHO notice: [wxFormBuilder-cfg] To avoid complications please
                    update your configuration to includes a correct path to the
                    wxFormBuilder executable. ;
                ECHO notice: [wxFormBuilder-cfg] wxFormBuilder executable will
                    be searched for on the system path. ;
            }
        }
        if $(.debug-configuration)
        {
            ECHO notice: [wxFormBuilder-cfg] Will use wxFormBuilder executable
                \"$(executable)\". ;
        }

        # Now we are sure we have everything we need to initialize this toolset.
        .initialized = true ;

        # Store the path to the used wxFormBuilder executable.
        .executable = $(executable) ;

        # Type registration.
        type.register WX_FORM_BUILDER_PROJECT : fbp ;

        # Parameters to be forwarded to the action rule.
        toolset.flags wxFormBuilder.generate EXECUTABLE : $(.executable) ;

        # Generator definition and registration.
        generators.register-standard wxFormBuilder.generate :
            WX_FORM_BUILDER_PROJECT : CPP(wxFormBuilderGenerated_%)
            H(wxFormBuilderGenerated_%) ;
    }
}


################################################################################
#
# wxFormBuilder.is-initialized()
# ------------------------------
#
#   Returns whether this toolset has been initialized.
#
################################################################################

rule is-initialized ( )
{
    return $(.initialized) ;
}


################################################################################
#
#   Startup code executed when loading this module.
#
################################################################################

# Global variables for this module.
.executable = ;
.initialized = ;

if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
{
    .debug-configuration = true ;
}