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.
64 class MwShell(Metrowerks_Shell_Suite
, CodeWarrior_suite
, Metrowerks_Standard_Suite
,
65 Required_Suite
, aetools
.TalkTo
):
68 MwShell
= CodeWarrior
.CodeWarrior
72 def buildmwproject(top
, creator
, projects
):
73 """Build projects with an MW compiler"""
74 mgr
= MwShell(creator
, start
=1)
75 mgr
.send_timeout
= AppleEvents
.kNoTimeOut
79 if type(file) == type(()):
83 file = os
.path
.join(top
, file)
85 fss
= macfs
.FSSpec(file)
87 print '** file not found:', file
89 print 'Building', file, target
92 except aetools
.Error
, detail
:
93 print '**', detail
, file
97 mgr
.Set_Current_Target(target
)
98 except aetools
.Error
, arg
:
99 print '**', file, target
, 'Cannot select:', arg
102 except aetools
.Error
, arg
:
103 print '**', file, target
, 'Failed:', arg
107 print 'Open failed projects and exit?',
108 rv
= sys
.stdin
.readline()
109 if rv
[0] in ('y', 'Y'):
115 def buildapplet(top
, dummy
, list):
116 """Create python applets"""
117 template
= buildtools
.findtemplate()
118 for src
, dst
in list:
119 if src
[-3:] != '.py':
120 raise 'Should end in .py', src
121 base
= os
.path
.basename(src
)
122 src
= os
.path
.join(top
, src
)
123 dst
= os
.path
.join(top
, dst
)
128 print 'Building applet', dst
129 buildtools
.process(template
, src
, dst
, 1)
131 def buildfat(top
, dummy
, list):
132 """Build fat binaries"""
133 for dst
, src1
, src2
in list:
134 dst
= os
.path
.join(top
, dst
)
135 src1
= os
.path
.join(top
, src1
)
136 src2
= os
.path
.join(top
, src2
)
137 print 'Building fat binary', dst
138 cfmfile
.mergecfmfiles((src1
, src2
), dst
)
140 def handle_dialog(filename
):
141 """Handle selection dialog, return list of selected items"""
142 d
= Dlg
.GetNewDialog(DIALOG_ID
, -1)
143 d
.SetDialogDefaultItem(I_OK
)
144 d
.SetDialogCancelItem(I_CANCEL
)
145 results
= [0]*N_BUTTONS
147 n
= Dlg
.ModalDialog(None)
152 if n
== I_INC_BUILDNO
:
156 results
[n
] = (not results
[n
])
157 ctl
= d
.GetDialogItemAsControl(n
)
158 ctl
.SetControlValue(results
[n
])
160 for i
in range(len(results
)):
166 # The build instructions. Entries are (routine, arg, list-of-files)
167 # XXXX We could also include the builds for stdwin and such here...
169 I_CORE
: (buildmwproject
, "CWIE", [
170 (":Mac:Build:PythonCore.prj", "PythonCore"),
171 (":Mac:Build:PythonInterpreter.prj", "PythonInterpreter"),
174 I_PPC_PLUGINS
: (buildmwproject
, "CWIE", [
175 (":Mac:Build:ucnhash.prj", "ucnhash.ppc"),
176 (":Mac:Build:pyexpat.prj", "pyexpat.ppc"),
177 (":Mac:Build:calldll.ppc.prj", "calldll.ppc"),
178 (":Mac:Build:ctb.prj", "ctb.ppc"),
179 (":Mac:Build:gdbm.prj", "gdbm.ppc"),
180 (":Mac:Build:icglue.prj", "icglue.ppc"),
181 (":Mac:Build:macspeech.prj", "macspeech.ppc"),
182 (":Mac:Build:waste.prj", "waste.ppc"),
183 (":Mac:Build:zlib.prj", "zlib.ppc"),
184 ## (":Mac:Build:_tkinter.prj", "_tkinter.ppc"),
185 (":Extensions:Imaging:_tkinter.prj", "_tkinter.ppc"),
186 (":Mac:Build:ColorPicker.prj", "ColorPicker.ppc"),
187 (":Mac:Build:Printing.prj", "Printing.ppc"),
188 (":Mac:Build:App.prj", "App.ppc"),
189 (":Mac:Build:Cm.prj", "Cm.ppc"),
190 (":Mac:Build:Drag.prj", "Drag.ppc"),
191 (":Mac:Build:Fm.prj", "Fm.ppc"),
192 (":Mac:Build:Help.prj", "Help.ppc"),
193 (":Mac:Build:Icn.prj", "Icn.ppc"),
194 (":Mac:Build:List.prj", "List.ppc"),
195 (":Mac:Build:Qdoffs.prj", "Qdoffs.ppc"),
196 (":Mac:Build:Qt.prj", "Qt.ppc"),
197 (":Mac:Build:Scrap.prj", "Scrap.ppc"),
198 (":Mac:Build:Snd.prj", "Snd.ppc"),
199 (":Mac:Build:Sndihooks.prj", "Sndihooks.ppc"),
200 (":Mac:Build:TE.prj", "TE.ppc"),
203 I_68K_PLUGINS
: (buildmwproject
, "CWIE", [
204 (":Mac:Build:ucnhash.prj", "ucnhash.CFM68K"),
205 (":Mac:Build:ucnhash.prj", "ucnhash.CFM68K"),
206 (":Mac:Build:ctb.prj", "ctb.CFM68K"),
207 (":Mac:Build:gdbm.prj", "gdbm.CFM68K"),
208 (":Mac:Build:icglue.prj", "icglue.CFM68K"),
209 (":Mac:Build:waste.prj", "waste.CFM68K"),
210 (":Mac:Build:zlib.prj", "zlib.CFM68K"),
211 ## (":Mac:Build:_tkinter.prj", "_tkinter.CFM68K"),
212 (":Extensions:Imaging:_tkinter.prj", "_tkinter.CFM68K"),
213 (":Mac:Build:ColorPicker.prj", "ColorPicker.CFM68K"),
214 (":Mac:Build:Printing.prj", "Printing.CFM68K"),
215 (":Mac:Build:App.prj", "App.CFM68K"),
216 (":Mac:Build:Cm.prj", "Cm.CFM68K"),
217 (":Mac:Build:Drag.prj", "Drag.CFM68K"),
218 (":Mac:Build:Fm.prj", "Fm.CFM68K"),
219 (":Mac:Build:Help.prj", "Help.CFM68K"),
220 (":Mac:Build:Icn.prj", "Icn.CFM68K"),
221 (":Mac:Build:List.prj", "List.CFM68K"),
222 (":Mac:Build:Qdoffs.prj", "Qdoffs.CFM68K"),
223 (":Mac:Build:Qt.prj", "Qt.CFM68K"),
224 (":Mac:Build:Scrap.prj", "Scrap.CFM68K"),
225 (":Mac:Build:Snd.prj", "Snd.CFM68K"),
226 (":Mac:Build:Sndihooks.prj", "Sndihooks.CFM68K"),
227 (":Mac:Build:TE.prj", "TE.CFM68K"),
230 I_68K_FULL
: (buildmwproject
, "CWIE", [
231 (":Mac:Build:PythonStandalone.prj", "Python68K"),
234 I_68K_SMALL
: (buildmwproject
, "CWIE", [
235 (":Mac:Build:PythonStandSmall.prj", "PythonSmall68K"),
238 I_PPC_FULL
: (buildmwproject
, "CWIE", [
239 (":Mac:Build:PythonStandalone.prj", "PythonStandalone"),
242 I_PPC_SMALL
: (buildmwproject
, "CWIE", [
243 (":Mac:Build:PythonStandSmall.prj", "PythonStandSmall"),
246 I_PPC_EXTENSIONS
: (buildmwproject
, "CWIE", [
247 (":Extensions:Imaging:_imaging.prj", "_imaging.ppc"),
248 ## (":Extensions:Imaging:_tkinter.prj", "_tkinter.ppc"),
249 (":Extensions:img:Mac:imgmodules.prj", "imgmodules PPC"),
250 (":Extensions:Numerical:Mac:numpymodules.prj", "multiarraymodule"),
251 (":Extensions:Numerical:Mac:numpymodules.prj", "_numpy"),
252 (":Extensions:Numerical:Mac:numpymodules.prj", "umathmodule"),
253 (":Extensions:Numerical:Mac:numpymodules.prj", "lapack_litemodule"),
254 (":Extensions:Numerical:Mac:numpymodules.prj", "ranlibmodule"),
257 I_68K_EXTENSIONS
: (buildmwproject
, "CWIE", [
258 (":Extensions:Imaging:_imaging.prj", "_imaging.CFM68K"),
259 ## (":Extensions:Imaging:_tkinter.prj", "_tkinter.CFM68K"),
260 (":Extensions:img:Mac:imgmodules.prj", "imgmodules CFM68K"),
261 ## (":Extensions:NumPy:numpymodules.prj", "numpymodules.CFM68K"),
264 I_APPLETS
: (buildapplet
, None, [
265 (":Mac:scripts:EditPythonPrefs.py", "EditPythonPrefs"),
266 (":Mac:scripts:BuildApplet.py", "BuildApplet"),
267 (":Mac:scripts:BuildApplication.py", "BuildApplication"),
268 (":Mac:scripts:ConfigurePython.py", "ConfigurePython"),
269 (":Mac:Tools:IDE:PythonIDE.py", "Python IDE"),
270 (":Mac:Tools:CGI:PythonCGISlave.py", ":Mac:Tools:CGI:PythonCGISlave"),
271 (":Mac:Tools:CGI:BuildCGIApplet.py", ":Mac:Tools:CGI:BuildCGIApplet"),
275 def incbuildno(filename
):
280 pat
= regex
.compile('#define BUILD \([0-9][0-9]*\)')
282 buildno
= pat
.group(1)
284 raise 'Incorrect macbuildno.h line', line
285 new
= string
.atoi(buildno
) + 1
286 fp
= open(filename
, 'w')
287 fp
.write('#define BUILD %d\n'%new
)
292 h
= Res
.FSpOpenResFile('fullbuild.rsrc', 1)
294 pass # Assume we already have acces to our own resource
296 dir, ok
= macfs
.GetDirectory('Python source folder:')
299 dir = dir.as_pathname()
301 todo
= handle_dialog(os
.path
.join(dir, MACBUILDNO
))
305 instructions
.append(BUILD_DICT
[i
])
307 for routine
, arg
, list in instructions
:
308 routine(dir, arg
, list)
313 if __name__
== '__main__':