2 # fullbuild creates everything that needs to be created before a
3 # distribution can be made, and puts it all in the right place.
5 # It expects the projects to be in the places where Jack likes them:
6 # in directories named like 'build.mac'. That is fixable,
9 # NOTE: You should proably make a copy of python with which to execute this
10 # script, rebuilding running programs does not work...
12 MACBUILDNO
=":Mac:Include:macbuildno.h"
28 from Metrowerks_Shell_Suite
import Metrowerks_Shell_Suite
29 from CodeWarrior_suite
import CodeWarrior_suite
30 from Metrowerks_Standard_Suite
import Metrowerks_Standard_Suite
31 from Required_Suite
import Required_Suite
41 # Dialog resource. Note that the item numbers should correspond
42 # to those in the DITL resource. Also note that the order is important:
43 # things are built in this order, so there should be no forward dependencies.
51 I_GEN_PROJECTS_FORCE
=6
53 I_GEN_IMGPROJECTS_FORCE
=8
62 I_CARBON_EXTENSIONS
=17
76 class MwShell(Metrowerks_Shell_Suite
, CodeWarrior_suite
, Metrowerks_Standard_Suite
,
77 Required_Suite
, aetools
.TalkTo
):
80 MwShell
= CodeWarrior
.CodeWarrior
84 def buildmwproject(top
, creator
, projects
):
85 """Build projects with an MW compiler"""
86 mgr
= MwShell(creator
, start
=1)
87 mgr
.send_timeout
= AppleEvents
.kNoTimeOut
91 if type(file) == type(()):
95 file = os
.path
.join(top
, file)
97 fss
= macfs
.FSSpec(file)
99 print '** file not found:', file
101 print 'Building', file, target
104 except aetools
.Error
, detail
:
105 print '**', detail
, file
109 mgr
.Set_Current_Target(target
)
110 except aetools
.Error
, arg
:
111 print '**', file, target
, 'Cannot select:', arg
114 except aetools
.Error
, arg
:
115 print '**', file, target
, 'Failed:', arg
119 print 'Open failed projects and exit?',
120 rv
= sys
.stdin
.readline()
121 if rv
[0] in ('y', 'Y'):
127 def buildapplet(top
, dummy
, list):
128 """Create python applets"""
129 for src
, dst
, tmpl
in list:
130 template
= buildtools
.findtemplate(tmpl
)
131 if src
[-3:] != '.py':
132 raise 'Should end in .py', src
133 base
= os
.path
.basename(src
)
134 src
= os
.path
.join(top
, src
)
135 dst
= os
.path
.join(top
, dst
)
140 print 'Building applet', dst
142 buildtools
.process(template
, src
, dst
, 1)
143 except buildtools
.BuildError
, arg
:
146 def buildprojectfile(top
, arg
, list):
147 """Create CodeWarrior project files with a script"""
148 for folder
, module
, routine
in list:
149 print "Generating project files with", module
150 sys
.path
.insert(0, os
.path
.join(top
, folder
))
151 m
= __import__(module
)
152 r
= getattr(m
, routine
)
156 def buildfat(top
, dummy
, list):
157 """Build fat binaries"""
158 for dst
, src1
, src2
in list:
159 dst
= os
.path
.join(top
, dst
)
160 src1
= os
.path
.join(top
, src1
)
161 src2
= os
.path
.join(top
, src2
)
162 print 'Building fat binary', dst
163 cfmfile
.mergecfmfiles((src1
, src2
), dst
)
165 def buildcopy(top
, dummy
, list):
167 for src
, dst
in list:
168 src
= os
.path
.join(top
, src
)
169 dst
= os
.path
.join(top
, dst
)
170 macostools
.copy(src
, dst
, forcetype
="APPL")
172 def handle_dialog(filename
):
173 """Handle selection dialog, return list of selected items"""
174 d
= Dlg
.GetNewDialog(DIALOG_ID
, -1)
175 d
.SetDialogDefaultItem(I_OK
)
176 d
.SetDialogCancelItem(I_CANCEL
)
177 results
= [0]*N_BUTTONS
179 n
= Dlg
.ModalDialog(None)
184 if n
== I_INC_BUILDNO
:
188 results
[n
] = (not results
[n
])
189 ctl
= d
.GetDialogItemAsControl(n
)
190 ctl
.SetControlValue(results
[n
])
192 for i
in range(len(results
)):
198 # The build instructions. Entries are (routine, arg, list-of-files)
199 # XXXX We could also include the builds for stdwin and such here...
201 I_GEN_PROJECTS
: (buildprojectfile
, 0, [
202 (":Mac:scripts", "genpluginprojects", "genallprojects")
205 I_GEN_PROJECTS_FORCE
: (buildprojectfile
, 1, [
206 (":Mac:scripts", "genpluginprojects", "genallprojects")
209 I_GEN_IMGPROJECTS
: (buildprojectfile
, 0, [
210 (":Extensions:img:Mac", "genimgprojects", "genallprojects")
213 I_GEN_IMGPROJECTS_FORCE
: (buildprojectfile
, 1, [
214 (":Extensions:img:Mac", "genimgprojects", "genallprojects")
217 I_INTERPRETER
: (buildcopy
, None, [
218 ("PythonInterpreterCarbon", "PythonInterpreter"),
221 I_PPC_CORE
: (buildmwproject
, "CWIE", [
222 (":Mac:Build:PythonCore.mcp", "PythonCore"),
223 (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterClassic"),
226 I_CARBON_CORE
: (buildmwproject
, "CWIE", [
227 (":Mac:Build:PythonCore.mcp", "PythonCoreCarbon"),
228 (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterCarbon"),
231 I_PPC_EXTLIBS
: (buildmwproject
, "CWIE", [
232 ## (":Mac:Build:buildlibs.mcp", "buildlibs ppc plus tcl/tk"),
233 (":Mac:Build:buildlibs.mcp", "buildlibs ppc"),
236 I_PPC_PLUGINS
: (buildmwproject
, "CWIE", [
237 (":Mac:Build:_weakref.mcp", "_weakref.ppc"),
238 (":Mac:Build:_symtable.mcp", "_symtable.ppc"),
239 (":Mac:Build:_testcapi.mcp", "_testcapi.ppc"),
240 (":Mac:Build:pyexpat.mcp", "pyexpat.ppc"),
241 (":Mac:Build:calldll.mcp", "calldll.ppc"),
242 (":Mac:Build:ctb.mcp", "ctb.ppc"),
243 (":Mac:Build:gdbm.mcp", "gdbm.ppc"),
244 (":Mac:Build:icglue.mcp", "icglue.ppc"),
245 (":Mac:Build:macspeech.mcp", "macspeech.ppc"),
246 (":Mac:Build:waste.mcp", "waste.ppc"),
247 (":Mac:Build:zlib.mcp", "zlib.ppc"),
248 ## (":Mac:Build:_tkinter.mcp", "_tkinter.ppc"),
249 (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"),
250 (":Mac:Build:ColorPicker.mcp", "ColorPicker.ppc"),
251 (":Mac:Build:Printing.mcp", "Printing.ppc"),
252 (":Mac:Build:AE.mcp", "AE.ppc"),
253 (":Mac:Build:App.mcp", "App.ppc"),
254 (":Mac:Build:Cm.mcp", "Cm.ppc"),
255 (":Mac:Build:Ctl.mcp", "Ctl.ppc"),
256 (":Mac:Build:Dlg.mcp", "Dlg.ppc"),
257 (":Mac:Build:Drag.mcp", "Drag.ppc"),
258 (":Mac:Build:Evt.mcp", "Evt.ppc"),
259 (":Mac:Build:Fm.mcp", "Fm.ppc"),
260 (":Mac:Build:Help.mcp", "Help.ppc"),
261 (":Mac:Build:Icn.mcp", "Icn.ppc"),
262 (":Mac:Build:List.mcp", "List.ppc"),
263 (":Mac:Build:Menu.mcp", "Menu.ppc"),
264 (":Mac:Build:Mlte.mcp", "Mlte.ppc"),
265 (":Mac:Build:Qd.mcp", "Qd.ppc"),
266 (":Mac:Build:Qdoffs.mcp", "Qdoffs.ppc"),
267 (":Mac:Build:Qt.mcp", "Qt.ppc"),
268 (":Mac:Build:Res.mcp", "Res.ppc"),
269 (":Mac:Build:Scrap.mcp", "Scrap.ppc"),
270 (":Mac:Build:Snd.mcp", "Snd.ppc"),
271 (":Mac:Build:Sndihooks.mcp", "Sndihooks.ppc"),
272 (":Mac:Build:TE.mcp", "TE.ppc"),
273 (":Mac:Build:Win.mcp", "Win.ppc"),
276 I_CARBON_PLUGINS
: (buildmwproject
, "CWIE", [
277 (":Mac:Build:_weakref.carbon.mcp", "_weakref.carbon"),
278 (":Mac:Build:_symtable.carbon.mcp", "_symtable.carbon"),
279 (":Mac:Build:_testcapi.carbon.mcp", "_testcapi.carbon"),
280 (":Mac:Build:pyexpat.carbon.mcp", "pyexpat.carbon"),
281 (":Mac:Build:calldll.carbon.mcp", "calldll.carbon"),
282 (":Mac:Build:gdbm.carbon.mcp", "gdbm.carbon"),
283 (":Mac:Build:icglue.carbon.mcp", "icglue.carbon"),
284 (":Mac:Build:waste.carbon.mcp", "waste.carbon"),
285 (":Mac:Build:zlib.carbon.mcp", "zlib.carbon"),
286 (":Mac:Build:_dummy_tkinter.mcp", "_tkinter.carbon"),
287 ## (":Extensions:Imaging:_tkinter.carbon.mcp", "_tkinter.carbon"),
288 (":Mac:Build:ColorPicker.carbon.mcp", "ColorPicker.carbon"),
289 (":Mac:Build:AE.carbon.mcp", "AE.carbon"),
290 (":Mac:Build:App.carbon.mcp", "App.carbon"),
291 (":Mac:Build:CF.carbon.mcp", "CF.carbon"),
292 (":Mac:Build:Cm.carbon.mcp", "Cm.carbon"),
293 (":Mac:Build:Ctl.carbon.mcp", "Ctl.carbon"),
294 (":Mac:Build:Dlg.carbon.mcp", "Dlg.carbon"),
295 (":Mac:Build:Drag.carbon.mcp", "Drag.carbon"),
296 (":Mac:Build:Evt.carbon.mcp", "Evt.carbon"),
297 (":Mac:Build:Fm.carbon.mcp", "Fm.carbon"),
298 (":Mac:Build:Icn.carbon.mcp", "Icn.carbon"),
299 (":Mac:Build:List.carbon.mcp", "List.carbon"),
300 (":Mac:Build:Menu.carbon.mcp", "Menu.carbon"),
301 (":Mac:Build:Mlte.carbon.mcp", "Mlte.carbon"),
302 (":Mac:Build:Qd.carbon.mcp", "Qd.carbon"),
303 (":Mac:Build:Qdoffs.carbon.mcp", "Qdoffs.carbon"),
304 (":Mac:Build:Qt.carbon.mcp", "Qt.carbon"),
305 (":Mac:Build:Res.carbon.mcp", "Res.carbon"),
306 (":Mac:Build:Scrap.carbon.mcp", "Scrap.carbon"),
307 (":Mac:Build:Snd.carbon.mcp", "Snd.carbon"),
308 (":Mac:Build:Sndihooks.carbon.mcp", "Sndihooks.carbon"),
309 (":Mac:Build:TE.carbon.mcp", "TE.carbon"),
310 (":Mac:Build:Win.carbon.mcp", "Win.carbon"),
314 I_PPC_FULL
: (buildmwproject
, "CWIE", [
315 (":Mac:Build:PythonStandalone.mcp", "PythonStandalone"),
318 I_PPC_SMALL
: (buildmwproject
, "CWIE", [
319 (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmall"),
322 I_CARBON_FULL
: (buildmwproject
, "CWIE", [
323 (":Mac:Build:PythonStandalone.mcp", "PythonCarbonStandalone"),
326 I_CARBON_SMALL
: (buildmwproject
, "CWIE", [
327 (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmallCarbon"),
330 I_PPC_EXTENSIONS
: (buildmwproject
, "CWIE", [
331 (":Extensions:Imaging:_imaging.mcp", "_imaging.ppc"),
332 ## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"),
333 (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.ppc"),
336 I_CARBON_EXTENSIONS
: (buildmwproject
, "CWIE", [
337 (":Extensions:Imaging:_imaging.mcp", "_imaging.carbon"),
338 ## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.carbon"),
339 (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.carbon"),
342 I_APPLETS
: (buildapplet
, None, [
343 (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs", None),
344 (":Mac:scripts:BuildApplet.py", "BuildApplet", None),
345 (":Mac:scripts:BuildApplication.py", "BuildApplication", None),
346 (":Mac:scripts:ConfigurePython.py", "ConfigurePython", None),
347 (":Mac:scripts:ConfigurePython.py", "ConfigurePythonCarbon", "PythonInterpreterCarbon"),
348 (":Mac:scripts:ConfigurePython.py", "ConfigurePythonClassic", "PythonInterpreterClassic"),
349 (":Mac:Tools:IDE:PythonIDE.py", "Python IDE", None),
350 (":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave", None),
351 (":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet", None),
355 def incbuildno(filename
):
360 pat
= re
.compile('#define BUILD ([0-9]+)')
362 if not m
or not m
.group(1):
363 raise 'Incorrect macbuildno.h line', line
365 new
= string
.atoi(buildno
) + 1
366 fp
= open(filename
, 'w')
367 fp
.write('#define BUILD %d\n'%new
)
372 h
= Res
.FSpOpenResFile('fullbuild.rsrc', 1)
374 pass # Assume we already have acces to our own resource
376 dir, ok
= macfs
.GetDirectory('Python source folder:')
379 dir = dir.as_pathname()
381 todo
= handle_dialog(os
.path
.join(dir, MACBUILDNO
))
385 instructions
.append(BUILD_DICT
[i
])
387 for routine
, arg
, list in instructions
:
388 routine(dir, arg
, list)
393 if __name__
== '__main__':