Imported Upstream version 1.57.0
[platform/upstream/boost.git] / tools / build / src / contrib / wxFormBuilder.jam
1 ################################################################################
2 #
3 # Copyright (c) 2007-2008 Dario Senic, Jurko Gospodnetic.
4 #
5 # Use, modification and distribution is subject to the Boost Software
6 # License Version 1.0. (See accompanying file LICENSE_1_0.txt or
7 # http://www.boost.org/LICENSE_1_0.txt)
8 #
9 ################################################################################
10
11 ################################################################################
12 #
13 #   Boost Build wxFormBuilder generator tool module.
14 #
15 #   wxFormBuilder is a GUI designer tool for the wxWidgets library. It can then
16 # generate C++ sources modeling the designed GUI using the wxWidgets library
17 # APIs.
18 #
19 #   This module defines a wxFormBuilder project file type and rules needed to
20 # generate C++ source files from those projects. With it you can simply list
21 # wxFormBuilder projects as sources for some target and Boost Build will
22 # automatically convert them to C++ sources and process from there.
23 #
24 #   The wxFormBuilder executable location may be provided as a parameter when
25 # configuring this toolset. Otherwise the default wxFormBuilder.exe executable
26 # name is used located in the folder pointed to by the WXFORMBUILDER environment
27 # variable.
28 #
29 #   Current limitations:
30 #
31 #   * Works only on Windows.
32 #   * Works only when run via Boost Jam using the native Windows cmd.exe command
33 #     interpreter, i.e. the default native Windows Boost Jam build.
34 #   * Used wxFormBuilder projects need to have their output file names defined
35 #     consistently with target names assumed by this build script. This means
36 #     that their target names must use the prefix 'wxFormBuilderGenerated_' and
37 #     have no output folder defined where the base name is equal to the .fpb
38 #     project file's name.
39 #
40 ################################################################################
41
42 ################################################################################
43 #
44 # Implementation note:
45 #
46 #   Avoiding the limitation on the generated target file names can be done but
47 # would require depending on external tools to copy the wxFormBuilder project to
48 # a temp location and then modify it in-place to set its target file names. On
49 # the other hand wxFormBuilder is expected to add command-line options for
50 # choosing the target file names from the command line which will allow us to
51 # remove this limitation in a much cleaner way.
52 #                                                    (23.08.2008.) (Jurko)
53 #
54 ################################################################################
55
56 import generators ;
57 import os         ;
58 import path       ;
59 import toolset    ;
60 import type       ;
61
62
63 ################################################################################
64 #
65 # wxFormBuilder.generate()
66 # ------------------------
67 #
68 #   Action for processing WX_FORM_BUILDER_PROJECT types.
69 #
70 ################################################################################
71 #
72 # Implementation notes:
73 #
74 #   wxFormBuilder generated CPP and H files need to be moved to the location
75 # where the Boost Build target system expects them so that the generated CPP
76 # file can be included into the compile process and that the clean rule
77 # succesfully deletes both CPP and H files. We expect wxFormBuilder to generate
78 # files in the same location where the provided WX_FORM_BUILDER_PROJECT file is
79 # located.
80 #                                                    (15.05.2007.) (Dario)
81 #
82 ################################################################################
83
84 actions generate
85 {
86     start "" /wait "$(EXECUTABLE)" /g "$(2)"
87     move "$(1[1]:BSR=$(2:P))" "$(1[1]:P)"
88     move "$(1[2]:BSR=$(2:P))" "$(1[2]:P)"
89 }
90
91
92 ################################################################################
93 #
94 # wxFormBuilder.init()
95 # --------------------
96 #
97 #   Main toolset initialization rule called via the toolset.using rule.
98 #
99 ################################################################################
100
101 rule init ( executable ? )
102 {
103     if $(.initialized)
104     {
105         if $(.debug-configuration)
106         {
107             ECHO notice: [wxFormBuilder-cfg] Repeated initialization request
108                 (executable \"$(executable:E="")\") detected and ignored. ;
109         }
110     }
111     else
112     {
113         local environmentVariable = WXFORMBUILDER ;
114
115         if $(.debug-configuration)
116         {
117             ECHO notice: [wxFormBuilder-cfg] Configuring wxFormBuilder... ;
118         }
119
120         # Deduce the path to the used wxFormBuilder executable.
121         if ! $(executable)
122         {
123             executable = "wxFormBuilder.exe" ;
124             local executable-path = [ os.environ $(environmentVariable) ] ;
125             if $(executable-path)-is-not-empty
126             {
127                 executable = [ path.root $(executable) $(executable-path) ] ;
128             }
129             else if $(.debug-configuration)
130             {
131                 ECHO notice: [wxFormBuilder-cfg] No wxFormBuilder path
132                     configured either explicitly or using the
133                     $(environmentVariable) environment variable. ;
134                 ECHO notice: [wxFormBuilder-cfg] To avoid complications please
135                     update your configuration to includes a correct path to the
136                     wxFormBuilder executable. ;
137                 ECHO notice: [wxFormBuilder-cfg] wxFormBuilder executable will
138                     be searched for on the system path. ;
139             }
140         }
141         if $(.debug-configuration)
142         {
143             ECHO notice: [wxFormBuilder-cfg] Will use wxFormBuilder executable
144                 \"$(executable)\". ;
145         }
146
147         # Now we are sure we have everything we need to initialize this toolset.
148         .initialized = true ;
149
150         # Store the path to the used wxFormBuilder executable.
151         .executable = $(executable) ;
152
153         # Type registration.
154         type.register WX_FORM_BUILDER_PROJECT : fbp ;
155
156         # Parameters to be forwarded to the action rule.
157         toolset.flags wxFormBuilder.generate EXECUTABLE : $(.executable) ;
158
159         # Generator definition and registration.
160         generators.register-standard wxFormBuilder.generate :
161             WX_FORM_BUILDER_PROJECT : CPP(wxFormBuilderGenerated_%)
162             H(wxFormBuilderGenerated_%) ;
163     }
164 }
165
166
167 ################################################################################
168 #
169 # wxFormBuilder.is-initialized()
170 # ------------------------------
171 #
172 #   Returns whether this toolset has been initialized.
173 #
174 ################################################################################
175
176 rule is-initialized ( )
177 {
178     return $(.initialized) ;
179 }
180
181
182 ################################################################################
183 #
184 #   Startup code executed when loading this module.
185 #
186 ################################################################################
187
188 # Global variables for this module.
189 .executable = ;
190 .initialized = ;
191
192 if [ MATCH (--debug-configuration) : [ modules.peek : ARGV ] ]
193 {
194     .debug-configuration = true ;
195 }