The 0.5 release happened on 2/15, not on 2/14. :-)
[python/dscho.git] / Mac / scripts / fullbuild.py
blob2fd0f9c2247eefec1b0b85fe8af8ed3e51c309ff
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,
7 # however.
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"
14 import os
15 import sys
16 import macfs
17 import MacOS
18 import EasyDialogs
19 import regex
20 import string
22 import aetools
23 import AppleEvents
24 from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite
25 from CodeWarrior_Standard_Suite import CodeWarrior_Standard_Suite
26 from Required_Suite import Required_Suite
28 import Res
29 import Dlg
31 import buildtools
32 import cfmfile
34 # Dialog resource. Note that the item numbers should correspond
35 # to those in the DITL resource. Also note that the order is important:
36 # things are built in this order, so there should be no forward dependencies.
37 DIALOG_ID = 512
39 I_OK=1
40 I_CANCEL=2
41 I_INC_BUILDNO=19
43 I_CORE=3
44 I_PPC_PLUGINS=4
45 I_PPC_EXTENSIONS=5
46 I_68K_PLUGINS=6
47 I_68K_EXTENSIONS=7
48 I_PPC_FULL=8
49 I_PPC_SMALL=9
50 I_68K_FULL=10
51 I_68K_SMALL=11
52 I_APPLETS=12
54 N_BUTTONS=13
56 class MwShell(Metrowerks_Shell_Suite, CodeWarrior_Standard_Suite,
57 Required_Suite, aetools.TalkTo):
58 pass
60 RUNNING=[]
62 def buildmwproject(top, creator, projects):
63 """Build projects with an MW compiler"""
64 mgr = MwShell(creator, start=1)
65 mgr.send_timeout = AppleEvents.kNoTimeOut
67 for file in projects:
68 if type(file) == type(()):
69 file, target = file
70 else:
71 target = ''
72 file = os.path.join(top, file)
73 try:
74 fss = macfs.FSSpec(file)
75 except ValueError:
76 print '** file not found:', file
77 continue
78 print 'Building', file, target
79 try:
80 mgr.open(fss)
81 except aetools.Error, detail:
82 print '**', detail, file
83 continue
84 if target:
85 try:
86 mgr.Set_Current_Target(target)
87 except aetools.Error, arg:
88 print '**', file, target, 'Cannot select:', arg
89 try:
90 mgr.Make_Project()
91 except aetools.Error, arg:
92 print '**', file, target, 'Failed:', arg
93 mgr.Close_Project()
94 ## mgr.quit()
96 def buildapplet(top, dummy, list):
97 """Create python applets"""
98 template = buildtools.findtemplate()
99 for src, dst in list:
100 if src[-3:] != '.py':
101 raise 'Should end in .py', src
102 base = os.path.basename(src)
103 src = os.path.join(top, src)
104 dst = os.path.join(top, dst)
105 try:
106 os.unlink(dst)
107 except os.error:
108 pass
109 print 'Building applet', dst
110 buildtools.process(template, src, dst, 1)
112 def buildfat(top, dummy, list):
113 """Build fat binaries"""
114 for dst, src1, src2 in list:
115 dst = os.path.join(top, dst)
116 src1 = os.path.join(top, src1)
117 src2 = os.path.join(top, src2)
118 print 'Building fat binary', dst
119 cfmfile.mergecfmfiles((src1, src2), dst)
121 def handle_dialog(filename):
122 """Handle selection dialog, return list of selected items"""
123 d = Dlg.GetNewDialog(DIALOG_ID, -1)
124 d.SetDialogDefaultItem(I_OK)
125 d.SetDialogCancelItem(I_CANCEL)
126 results = [0]*N_BUTTONS
127 while 1:
128 n = Dlg.ModalDialog(None)
129 if n == I_OK:
130 break
131 if n == I_CANCEL:
132 return []
133 if n == I_INC_BUILDNO:
134 incbuildno(filename)
135 continue
136 if n < len(results):
137 results[n] = (not results[n])
138 ctl = d.GetDialogItemAsControl(n)
139 ctl.SetControlValue(results[n])
140 rv = []
141 for i in range(len(results)):
142 if results[i]:
143 rv.append(i)
144 return rv
147 # The build instructions. Entries are (routine, arg, list-of-files)
148 # XXXX We could also include the builds for stdwin and such here...
149 BUILD_DICT = {
150 I_CORE : (buildmwproject, "CWIE", [
151 (":Mac:Build:PythonCore.prj", "PythonCore"),
152 (":Mac:Build:PythonInterpreter.prj", "PythonInterpreter"),
155 I_PPC_PLUGINS : (buildmwproject, "CWIE", [
156 (":Mac:Build:calldll.ppc.prj", "calldll.ppc"),
157 (":Mac:Build:ctb.prj", "ctb.ppc"),
158 (":Mac:Build:gdbm.prj", "gdbm.ppc"),
159 (":Mac:Build:icglue.prj", "icglue.ppc"),
160 (":Mac:Build:macspeech.prj", "macspeech.ppc"),
161 (":Mac:Build:waste.prj", "waste.ppc"),
162 (":Mac:Build:zlib.prj", "zlib.ppc"),
163 (":Mac:Build:_tkinter.prj", "_tkinter.ppc"),
164 (":Mac:Build:ColorPicker.prj", "ColorPicker.ppc"),
165 (":Mac:Build:Printing.prj", "Printing.ppc"),
166 (":Mac:Build:AE.prj", "AE.ppc"),
167 (":Mac:Build:App.prj", "App.ppc"),
168 (":Mac:Build:Cm.prj", "Cm.ppc"),
169 (":Mac:Build:Evt.prj", "Evt.ppc"),
170 (":Mac:Build:Fm.prj", "Fm.ppc"),
171 (":Mac:Build:Help.prj", "Help.ppc"),
172 (":Mac:Build:Icn.prj", "Icn.ppc"),
173 (":Mac:Build:List.prj", "List.ppc"),
174 (":Mac:Build:Nav.prj", "Nav.ppc"),
175 (":Mac:Build:Qdoffs.prj", "Qdoffs.ppc"),
176 (":Mac:Build:Qt.prj", "Qt.ppc"),
177 (":Mac:Build:Scrap.prj", "Scrap.ppc"),
178 (":Mac:Build:Snd.prj", "Snd.ppc"),
179 (":Mac:Build:Sndihooks.prj", "Sndihooks.ppc"),
180 (":Mac:Build:TE.prj", "TE.ppc"),
183 I_68K_PLUGINS : (buildmwproject, "CWIE", [
184 (":Mac:Build:ctb.prj", "ctb.CFM68K"),
185 (":Mac:Build:gdbm.prj", "gdbm.CFM68K"),
186 (":Mac:Build:icglue.prj", "icglue.CFM68K"),
187 (":Mac:Build:waste.prj", "waste.CFM68K"),
188 (":Mac:Build:zlib.prj", "zlib.CFM68K"),
189 (":Mac:Build:_tkinter.prj", "_tkinter.CFM68K"),
190 (":Mac:Build:ColorPicker.prj", "ColorPicker.CFM68K"),
191 (":Mac:Build:Printing.prj", "Printing.CFM68K"),
192 (":Mac:Build:AE.prj", "AE.CFM68K"),
193 (":Mac:Build:App.prj", "App.CFM68K"),
194 (":Mac:Build:Cm.prj", "Cm.CFM68K"),
195 (":Mac:Build:Evt.prj", "Evt.CFM68K"),
196 (":Mac:Build:Fm.prj", "Fm.CFM68K"),
197 (":Mac:Build:Help.prj", "Help.CFM68K"),
198 (":Mac:Build:Icn.prj", "Icn.CFM68K"),
199 (":Mac:Build:List.prj", "List.CFM68K"),
200 (":Mac:Build:Nav.prj", "Nav.CFM68K"),
201 (":Mac:Build:Qdoffs.prj", "Qdoffs.CFM68K"),
202 (":Mac:Build:Qt.prj", "Qt.CFM68K"),
203 (":Mac:Build:Scrap.prj", "Scrap.CFM68K"),
204 (":Mac:Build:Snd.prj", "Snd.CFM68K"),
205 (":Mac:Build:Sndihooks.prj", "Sndihooks.CFM68K"),
206 (":Mac:Build:TE.prj", "TE.CFM68K"),
209 I_68K_FULL : (buildmwproject, "CWIE", [
210 (":Mac:Build:PythonStandalone.prj", "Python68K"),
213 I_68K_SMALL : (buildmwproject, "CWIE", [
214 (":Mac:Build:PythonStandSmall.prj", "PythonSmall68K"),
217 I_PPC_FULL : (buildmwproject, "CWIE", [
218 (":Mac:Build:PythonStandalone.prj", "PythonStandalone"),
221 I_PPC_SMALL : (buildmwproject, "CWIE", [
222 (":Mac:Build:PythonStandSmall.prj", "PythonStandSmall"),
225 I_PPC_EXTENSIONS : (buildmwproject, "CWIE", [
226 (":Extensions:Imaging:_imaging.prj", "_imaging.ppc"),
227 (":Extensions:Imaging:_tkinter.prj", "_tkinter.ppc"),
228 (":Extensions:img:Mac:imgmodules.prj", "imgmodules PPC"),
229 (":Extensions:Numerical:Mac:numpymodules.prj", "multiarraymodule"),
230 (":Extensions:Numerical:Mac:numpymodules.prj", "_numpy"),
231 (":Extensions:Numerical:Mac:numpymodules.prj", "umathmodule"),
232 (":Extensions:Numerical:Mac:numpymodules.prj", "fast_umathmodule"),
233 (":Extensions:Numerical:Mac:numpymodules.prj", "fftpackmodule"),
234 (":Extensions:Numerical:Mac:numpymodules.prj", "lapack_litemodule"),
235 (":Extensions:Numerical:Mac:numpymodules.prj", "ranlibmodule"),
238 I_68K_EXTENSIONS : (buildmwproject, "CWIE", [
239 (":Extensions:Imaging:_imaging.prj", "_imaging.CFM68K"),
240 (":Extensions:Imaging:_tkinter.prj", "_tkinter.CFM68K"),
241 (":Extensions:img:Mac:imgmodules.prj", "imgmodules CFM68K"),
242 ## (":Extensions:NumPy:numpymodules.prj", "numpymodules.CFM68K"),
245 I_APPLETS : (buildapplet, None, [
246 (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs"),
247 (":Mac:scripts:BuildApplet.py", "BuildApplet"),
248 (":Mac:scripts:BuildApplication.py", "BuildApplication"),
249 (":Mac:scripts:ConfigurePython.py", "ConfigurePython"),
250 (":Mac:Tools:IDE:PythonIDE.py", "Python IDE"),
254 def incbuildno(filename):
255 fp = open(filename)
256 line = fp.readline()
257 fp.close()
259 pat = regex.compile('#define BUILD \([0-9][0-9]*\)')
260 pat.match(line)
261 buildno = pat.group(1)
262 if not buildno:
263 raise 'Incorrect macbuildno.h line', line
264 new = string.atoi(buildno) + 1
265 fp = open(filename, 'w')
266 fp.write('#define BUILD %d\n'%new)
267 fp.close()
269 def main():
270 try:
271 h = Res.OpenResFile('fullbuild.rsrc')
272 except Res.Error:
273 pass # Assume we already have acces to our own resource
275 dir, ok = macfs.GetDirectory('Python source folder:')
276 if not ok:
277 sys.exit(0)
278 dir = dir.as_pathname()
280 todo = handle_dialog(os.path.join(dir, MACBUILDNO))
282 instructions = []
283 for i in todo:
284 instructions.append(BUILD_DICT[i])
286 for routine, arg, list in instructions:
287 routine(dir, arg, list)
289 print "All done!"
290 sys.exit(1)
292 if __name__ == '__main__':
293 main()