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"
21 import genpluginprojects
25 from Carbon
import AppleEvents
30 from Metrowerks_Shell_Suite
import Metrowerks_Shell_Suite
31 from CodeWarrior_suite
import CodeWarrior_suite
32 from Metrowerks_Standard_Suite
import Metrowerks_Standard_Suite
33 from Required_Suite
import Required_Suite
37 from Carbon
import Res
38 from Carbon
import Dlg
43 # Dialog resource. Note that the item numbers should correspond
44 # to those in the DITL resource. Also note that the order is important:
45 # things are built in this order, so there should be no forward dependencies.
53 I_GEN_PROJECTS_FORCE
=6
55 I_GEN_IMGPROJECTS_FORCE
=8
64 I_CARBON_EXTENSIONS
=17
78 class MwShell(Metrowerks_Shell_Suite
, CodeWarrior_suite
, Metrowerks_Standard_Suite
,
79 Required_Suite
, aetools
.TalkTo
):
82 MwShell
= CodeWarrior
.CodeWarrior
86 def buildmwproject(top
, creator
, projects
):
87 """Build projects with an MW compiler"""
88 mgr
= MwShell(creator
, start
=1)
89 mgr
.send_timeout
= AppleEvents
.kNoTimeOut
93 if type(file) == type(()):
97 file = os
.path
.join(top
, file)
99 fss
= macfs
.FSSpec(file)
101 print '** file not found:', file
103 print 'Building', file, target
106 except aetools
.Error
, detail
:
107 print '**', detail
, file
111 mgr
.Set_Current_Target(target
)
112 except aetools
.Error
, arg
:
113 print '**', file, target
, 'Cannot select:', arg
116 except aetools
.Error
, arg
:
117 print '**', file, target
, 'Failed:', arg
121 print 'Open failed projects and exit?',
122 rv
= sys
.stdin
.readline()
123 if rv
[0] in ('y', 'Y'):
129 def buildapplet(top
, dummy
, list):
130 """Create python applets"""
131 for src
, dst
, tmpl
in list:
132 template
= buildtools
.findtemplate(tmpl
)
133 if src
[-3:] != '.py':
134 raise 'Should end in .py', src
135 base
= os
.path
.basename(src
)
136 src
= os
.path
.join(top
, src
)
137 dst
= os
.path
.join(top
, dst
)
142 print 'Building applet', dst
144 buildtools
.process(template
, src
, dst
, 1)
145 except buildtools
.BuildError
, arg
:
148 def buildprojectfile(top
, arg
, list):
149 """Create CodeWarrior project files with a script"""
150 for folder
, module
, routine
in list:
151 print "Generating project files with", module
152 sys
.path
.insert(0, os
.path
.join(top
, folder
))
153 m
= __import__(module
)
154 r
= getattr(m
, routine
)
158 def buildfat(top
, dummy
, list):
159 """Build fat binaries"""
160 for dst
, src1
, src2
in list:
161 dst
= os
.path
.join(top
, dst
)
162 src1
= os
.path
.join(top
, src1
)
163 src2
= os
.path
.join(top
, src2
)
164 print 'Building fat binary', dst
165 cfmfile
.mergecfmfiles((src1
, src2
), dst
)
167 def buildcopy(top
, dummy
, list):
169 for src
, dst
in list:
170 src
= os
.path
.join(top
, src
)
171 dst
= os
.path
.join(top
, dst
)
172 macostools
.copy(src
, dst
, forcetype
="APPL")
174 def handle_dialog(filename
):
175 """Handle selection dialog, return list of selected items"""
176 d
= Dlg
.GetNewDialog(DIALOG_ID
, -1)
177 d
.SetDialogDefaultItem(I_OK
)
178 d
.SetDialogCancelItem(I_CANCEL
)
179 results
= [0]*N_BUTTONS
181 n
= Dlg
.ModalDialog(None)
186 if n
== I_INC_BUILDNO
:
190 results
[n
] = (not results
[n
])
191 ctl
= d
.GetDialogItemAsControl(n
)
192 ctl
.SetControlValue(results
[n
])
194 for i
in range(len(results
)):
200 # The build instructions. Entries are (routine, arg, list-of-files)
201 # XXXX We could also include the builds for stdwin and such here...
203 I_GEN_PROJECTS
: (buildprojectfile
, 0, [
204 (":Mac:scripts", "genpluginprojects", "genallprojects")
207 I_GEN_PROJECTS_FORCE
: (buildprojectfile
, 1, [
208 (":Mac:scripts", "genpluginprojects", "genallprojects")
211 I_GEN_IMGPROJECTS
: (buildprojectfile
, 0, [
212 (":Extensions:img:Mac", "genimgprojects", "genallprojects")
215 I_GEN_IMGPROJECTS_FORCE
: (buildprojectfile
, 1, [
216 (":Extensions:img:Mac", "genimgprojects", "genallprojects")
219 I_INTERPRETER
: (buildcopy
, None, [
220 ("PythonInterpreterCarbon", "PythonInterpreter"),
223 I_PPC_CORE
: (buildmwproject
, "CWIE", [
224 (":Mac:Build:PythonCore.mcp", "PythonCore"),
225 (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterClassic"),
228 I_CARBON_CORE
: (buildmwproject
, "CWIE", [
229 (":Mac:Build:PythonCore.mcp", "PythonCoreCarbon"),
230 (":Mac:Build:PythonInterpreter.mcp", "PythonInterpreterCarbon"),
233 I_PPC_EXTLIBS
: (buildmwproject
, "CWIE", [
234 ## (":Mac:Build:buildlibs.mcp", "buildlibs ppc plus tcl/tk"),
235 (":Mac:Build:buildlibs.mcp", "buildlibs ppc"),
238 I_PPC_PLUGINS
: (buildmwproject
, "CWIE", [
239 (":Mac:Build:_weakref.mcp", "_weakref.ppc"),
240 (":Mac:Build:_symtable.mcp", "_symtable.ppc"),
241 (":Mac:Build:_testcapi.mcp", "_testcapi.ppc"),
242 (":Mac:Build:_hotshot.mcp", "_hotshot.ppc"),
243 (":Mac:Build:xx.mcp", "xx.ppc"),
244 (":Mac:Build:xxsubtype.mcp", "xxsubtype.ppc"),
245 (":Mac:Build:pyexpat.mcp", "pyexpat.ppc"),
246 (":Mac:Build:calldll.mcp", "calldll.ppc"),
247 (":Mac:Build:ctb.mcp", "ctb.ppc"),
248 (":Mac:Build:gdbm.mcp", "gdbm.ppc"),
249 (":Mac:Build:icglue.mcp", "icglue.ppc"),
250 (":Mac:Build:macspeech.mcp", "macspeech.ppc"),
251 (":Mac:Build:waste.mcp", "waste.ppc"),
252 (":Mac:Build:zlib.mcp", "zlib.ppc"),
253 ## (":Mac:Build:_tkinter.mcp", "_tkinter.ppc"),
254 (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"),
255 (":Mac:Build:ColorPicker.mcp", "ColorPicker.ppc"),
256 (":Mac:Build:Printing.mcp", "Printing.ppc"),
257 (":Mac:Build:_AE.mcp", "_AE.ppc"),
258 (":Mac:Build:_App.mcp", "_App.ppc"),
259 (":Mac:Build:_Cm.mcp", "_Cm.ppc"),
260 (":Mac:Build:_Ctl.mcp", "_Ctl.ppc"),
261 (":Mac:Build:_Dlg.mcp", "_Dlg.ppc"),
262 (":Mac:Build:_Drag.mcp", "_Drag.ppc"),
263 (":Mac:Build:_Evt.mcp", "_Evt.ppc"),
264 (":Mac:Build:_Fm.mcp", "_Fm.ppc"),
265 (":Mac:Build:_Help.mcp", "_Help.ppc"),
266 (":Mac:Build:_Icn.mcp", "_Icn.ppc"),
267 (":Mac:Build:_List.mcp", "_List.ppc"),
268 (":Mac:Build:_Menu.mcp", "_Menu.ppc"),
269 (":Mac:Build:_Mlte.mcp", "_Mlte.ppc"),
270 (":Mac:Build:_Qd.mcp", "_Qd.ppc"),
271 (":Mac:Build:_Qdoffs.mcp", "_Qdoffs.ppc"),
272 (":Mac:Build:_Qt.mcp", "_Qt.ppc"),
273 (":Mac:Build:_Res.mcp", "_Res.ppc"),
274 (":Mac:Build:_Scrap.mcp", "_Scrap.ppc"),
275 (":Mac:Build:_Snd.mcp", "_Snd.ppc"),
276 (":Mac:Build:_Sndihooks.mcp", "_Sndihooks.ppc"),
277 (":Mac:Build:_TE.mcp", "_TE.ppc"),
278 (":Mac:Build:_Win.mcp", "_Win.ppc"),
281 I_CARBON_PLUGINS
: (buildmwproject
, "CWIE", [
282 (":Mac:Build:_weakref.carbon.mcp", "_weakref.carbon"),
283 (":Mac:Build:_symtable.carbon.mcp", "_symtable.carbon"),
284 (":Mac:Build:_testcapi.carbon.mcp", "_testcapi.carbon"),
285 (":Mac:Build:_hotshot.carbon.mcp", "_hotshot.carbon"),
286 (":Mac:Build:xx.carbon.mcp", "xx.carbon"),
287 (":Mac:Build:xxsubtype.carbon.mcp", "xxsubtype.carbon"),
288 (":Mac:Build:pyexpat.carbon.mcp", "pyexpat.carbon"),
289 (":Mac:Build:calldll.carbon.mcp", "calldll.carbon"),
290 (":Mac:Build:gdbm.carbon.mcp", "gdbm.carbon"),
291 (":Mac:Build:icglue.carbon.mcp", "icglue.carbon"),
292 (":Mac:Build:waste.carbon.mcp", "waste.carbon"),
293 (":Mac:Build:zlib.carbon.mcp", "zlib.carbon"),
294 (":Mac:Build:_dummy_tkinter.mcp", "_tkinter.carbon"),
295 (":Mac:Build:hfsplus.carbon.mcp", "hfsplus.carbon"),
296 ## (":Extensions:Imaging:_tkinter.carbon.mcp", "_tkinter.carbon"),
297 (":Mac:Build:ColorPicker.carbon.mcp", "ColorPicker.carbon"),
298 (":Mac:Build:_AE.carbon.mcp", "_AE.carbon"),
299 (":Mac:Build:_App.carbon.mcp", "_App.carbon"),
300 (":Mac:Build:_CF.carbon.mcp", "_CF.carbon"),
301 (":Mac:Build:_Cm.carbon.mcp", "_Cm.carbon"),
302 (":Mac:Build:_Ctl.carbon.mcp", "_Ctl.carbon"),
303 (":Mac:Build:_Dlg.carbon.mcp", "_Dlg.carbon"),
304 (":Mac:Build:_Drag.carbon.mcp", "_Drag.carbon"),
305 (":Mac:Build:_Evt.carbon.mcp", "_Evt.carbon"),
306 (":Mac:Build:_Fm.carbon.mcp", "_Fm.carbon"),
307 (":Mac:Build:_Icn.carbon.mcp", "_Icn.carbon"),
308 (":Mac:Build:_List.carbon.mcp", "_List.carbon"),
309 (":Mac:Build:_Menu.carbon.mcp", "_Menu.carbon"),
310 (":Mac:Build:_Mlte.carbon.mcp", "_Mlte.carbon"),
311 (":Mac:Build:_Qd.carbon.mcp", "_Qd.carbon"),
312 (":Mac:Build:_Qdoffs.carbon.mcp", "_Qdoffs.carbon"),
313 (":Mac:Build:_Qt.carbon.mcp", "_Qt.carbon"),
314 (":Mac:Build:_Res.carbon.mcp", "_Res.carbon"),
315 (":Mac:Build:_Scrap.carbon.mcp", "_Scrap.carbon"),
316 (":Mac:Build:_Snd.carbon.mcp", "_Snd.carbon"),
317 (":Mac:Build:_Sndihooks.carbon.mcp", "_Sndihooks.carbon"),
318 (":Mac:Build:_TE.carbon.mcp", "_TE.carbon"),
319 (":Mac:Build:_Win.carbon.mcp", "_Win.carbon"),
323 I_PPC_FULL
: (buildmwproject
, "CWIE", [
324 (":Mac:Build:PythonStandalone.mcp", "PythonStandalone"),
327 I_PPC_SMALL
: (buildmwproject
, "CWIE", [
328 (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmall"),
331 I_CARBON_FULL
: (buildmwproject
, "CWIE", [
332 (":Mac:Build:PythonStandalone.mcp", "PythonCarbonStandalone"),
335 I_CARBON_SMALL
: (buildmwproject
, "CWIE", [
336 (":Mac:Build:PythonStandSmall.mcp", "PythonStandSmallCarbon"),
339 I_PPC_EXTENSIONS
: (buildmwproject
, "CWIE", [
340 (":Extensions:Imaging:_imaging.mcp", "_imaging.ppc"),
341 ## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.ppc"),
342 (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.ppc"),
345 I_CARBON_EXTENSIONS
: (buildmwproject
, "CWIE", [
346 (":Extensions:Imaging:_imaging.mcp", "_imaging.carbon"),
347 ## (":Extensions:Imaging:_tkinter.mcp", "_tkinter.carbon"),
348 (":Extensions:img:Mac:imgmodules.mcp", "imgmodules.carbon"),
351 I_APPLETS
: (buildapplet
, None, [
352 (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs", None),
353 (":Mac:scripts:BuildApplet.py", "BuildApplet", None),
354 (":Mac:scripts:BuildApplication.py", "BuildApplication", None),
355 (":Mac:scripts:ConfigurePython.py", "ConfigurePython", None),
356 (":Mac:scripts:ConfigurePython.py", "ConfigurePythonCarbon", "PythonInterpreterCarbon"),
357 (":Mac:scripts:ConfigurePython.py", "ConfigurePythonClassic", "PythonInterpreterClassic"),
358 (":Mac:Tools:IDE:PythonIDE.py", "Python IDE", None),
359 (":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave", None),
360 (":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet", None),
364 def incbuildno(filename
):
369 pat
= re
.compile('#define BUILD ([0-9]+)')
371 if not m
or not m
.group(1):
372 raise 'Incorrect macbuildno.h line', line
374 new
= string
.atoi(buildno
) + 1
375 fp
= open(filename
, 'w')
376 fp
.write('#define BUILD %d\n'%new
)
380 macresource
.need('DLOG', DIALOG_ID
, 'fullbuild.rsrc')
381 dir, ok
= macfs
.GetDirectory('Python source folder:')
384 dir = dir.as_pathname()
385 # Set genpluginprojects to use this folder (slight hack)
386 genpluginprojects
.PYTHONDIR
= dir
388 todo
= handle_dialog(os
.path
.join(dir, MACBUILDNO
))
392 instructions
.append(BUILD_DICT
[i
])
394 for routine
, arg
, list in instructions
:
395 routine(dir, arg
, list)
400 if __name__
== '__main__':