blob: d81b650766d26a31300c1139e77ec04792b0d030 [file] [log] [blame]
Jack Jansen6655c4e1995-09-01 12:03:32 +00001#
2# fullbuild creates everything that needs to be created before a
3# distribution can be made, and puts it all in the right place.
4#
5# It expects the projects to be in the places where Jack likes them:
6# in directories named like 'build.macppc.shared'. That is fixable,
7# however.
8#
9# NOTE: You should proably make a copy of python with which to execute this
10# script, rebuilding running programs does not work...
11
12import os
13import sys
14import macfs
Jack Jansen1023dff1996-02-21 15:28:49 +000015import MacOS
Jack Jansenf04fa721996-04-10 14:51:14 +000016import EasyDialogs
Jack Jansen6655c4e1995-09-01 12:03:32 +000017
18import addpack
Jack Jansen6655c4e1995-09-01 12:03:32 +000019import aetools
Jack Jansen1023dff1996-02-21 15:28:49 +000020import AppleEvents
Jack Jansen6655c4e1995-09-01 12:03:32 +000021from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite
Jack Jansen82bfde91997-08-27 14:10:29 +000022from CodeWarrior_Standard_Suite import CodeWarrior_Standard_Suite
Jack Jansen0f00c5e1997-05-06 16:15:32 +000023from Required_Suite import Required_Suite
24
25import Res
26import Dlg
Jack Jansen6655c4e1995-09-01 12:03:32 +000027
Jack Jansen82bfde91997-08-27 14:10:29 +000028import BuildApplet
Jack Jansen0f00c5e1997-05-06 16:15:32 +000029import cfmfile
30
31# Dialog resource. Note that the item numbers should correspond
32# to those in the DITL resource. Also note that the order is important:
33# things are built in this order, so there should be no forward dependencies.
34DIALOG_ID = 512
35
36I_OK=1
37I_CANCEL=2
38
Jack Jansen82bfde91997-08-27 14:10:29 +000039I_CORE=3
Jack Jansen0f00c5e1997-05-06 16:15:32 +000040I_PPC_PLUGINS=4
41I_PPC_EXTENSIONS=5
Jack Jansen82bfde91997-08-27 14:10:29 +000042I_68K_PLUGINS=6
43I_68K_EXTENSIONS=7
44I_PPC_FULL=8
45I_PPC_SMALL=9
46I_68K_FULL=10
47I_68K_SMALL=11
48I_APPLETS=12
Jack Jansen0f00c5e1997-05-06 16:15:32 +000049
Jack Jansen82bfde91997-08-27 14:10:29 +000050N_BUTTONS=13
Jack Jansen6655c4e1995-09-01 12:03:32 +000051
Jack Jansen82bfde91997-08-27 14:10:29 +000052class MwShell(Metrowerks_Shell_Suite, CodeWarrior_Standard_Suite,
53 Required_Suite, aetools.TalkTo):
Jack Jansen6655c4e1995-09-01 12:03:32 +000054 pass
55
Jack Jansenf04fa721996-04-10 14:51:14 +000056RUNNING=[]
Jack Jansen6655c4e1995-09-01 12:03:32 +000057
58def buildmwproject(top, creator, projects):
59 """Build projects with an MW compiler"""
Jack Jansenb9e5e141996-09-20 15:30:52 +000060 mgr = MwShell(creator, start=1)
Jack Jansen1023dff1996-02-21 15:28:49 +000061 mgr.send_timeout = AppleEvents.kNoTimeOut
62
Jack Jansen6655c4e1995-09-01 12:03:32 +000063 for file in projects:
Jack Jansen82bfde91997-08-27 14:10:29 +000064 if type(file) == type(()):
65 file, target = file
66 else:
67 target = ''
Jack Jansen6655c4e1995-09-01 12:03:32 +000068 file = os.path.join(top, file)
69 fss = macfs.FSSpec(file)
Jack Jansen82bfde91997-08-27 14:10:29 +000070 print 'Building', file, target
Jack Jansen6655c4e1995-09-01 12:03:32 +000071 mgr.open(fss)
Jack Jansen82bfde91997-08-27 14:10:29 +000072 if target:
73 try:
74 mgr.Set_Current_Target(target)
75 except aetools.Error, arg:
76 print '**', file, target, 'Cannot select:', arg
Jack Jansen1023dff1996-02-21 15:28:49 +000077 try:
78 mgr.Make_Project()
Jack Jansenb9e5e141996-09-20 15:30:52 +000079 except aetools.Error, arg:
Jack Jansen82bfde91997-08-27 14:10:29 +000080 print '**', file, target, 'Failed:', arg
Jack Jansen6655c4e1995-09-01 12:03:32 +000081 mgr.Close_Project()
Jack Jansenf04fa721996-04-10 14:51:14 +000082## mgr.quit()
Jack Jansen6655c4e1995-09-01 12:03:32 +000083
84def buildapplet(top, dummy, list):
Jack Jansen0f00c5e1997-05-06 16:15:32 +000085 """Create python applets"""
Jack Jansen82bfde91997-08-27 14:10:29 +000086 template = BuildApplet.findtemplate()
Jack Jansen6655c4e1995-09-01 12:03:32 +000087 for src in list:
88 if src[-3:] != '.py':
89 raise 'Should end in .py', src
90 base = os.path.basename(src)
91 dst = os.path.join(top, base)[:-3]
92 src = os.path.join(top, src)
93 try:
94 os.unlink(dst)
95 except os.error:
96 pass
97 print 'Building applet', dst
Jack Jansen82bfde91997-08-27 14:10:29 +000098 BuildApplet.process(template, src, dst)
Jack Jansen0f00c5e1997-05-06 16:15:32 +000099
100def buildfat(top, dummy, list):
101 """Build fat binaries"""
102 for dst, src1, src2 in list:
103 dst = os.path.join(top, dst)
104 src1 = os.path.join(top, src1)
105 src2 = os.path.join(top, src2)
106 print 'Building fat binary', dst
107 cfmfile.mergecfmfiles((src1, src2), dst)
108
109def handle_dialog():
110 """Handle selection dialog, return list of selected items"""
111 d = Dlg.GetNewDialog(DIALOG_ID, -1)
112 d.SetDialogDefaultItem(I_OK)
113 d.SetDialogCancelItem(I_CANCEL)
114 results = [0]*N_BUTTONS
115 while 1:
116 n = Dlg.ModalDialog(None)
117 if n == I_OK:
118 break
119 if n == I_CANCEL:
120 return []
121 if n < len(results):
122 results[n] = (not results[n])
123 tp, h, rect = d.GetDialogItem(n)
124 h.as_Control().SetControlValue(results[n])
125 rv = []
126 for i in range(len(results)):
127 if results[i]:
128 rv.append(i)
129 return rv
Jack Jansen6655c4e1995-09-01 12:03:32 +0000130
131#
132# The build instructions. Entries are (routine, arg, list-of-files)
133# XXXX We could also include the builds for stdwin and such here...
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000134BUILD_DICT = {
Jack Jansen82bfde91997-08-27 14:10:29 +0000135I_CORE : (buildmwproject, "CWIE", [
136 (":build.mac:PythonCore.prj", "PythonCore"),
137 (":build.mac:Python.prj", "PythonFAT"),
138 (":build.mac:PythonApplet.prj", "PythonAppletFAT"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000139 ]),
140
141I_PPC_PLUGINS : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000142 (":PlugIns:PlugIns.prj", "PlugIns.ppc"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000143 ]),
144
145I_68K_PLUGINS : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000146 (":PlugIns:PlugIns.prj", "PlugIns.CFM68K"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000147 ]),
148
149I_68K_FULL : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000150 (":build.macstand:PythonStandalone.prj", "Python68K"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000151 ]),
152
153I_68K_SMALL : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000154 (":build.macstand:PythonStandSmall.prj", "PythonSmall68K"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000155 ]),
156
157I_PPC_FULL : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000158 (":build.macstand:PythonStandalone.prj", "PythonStandalone"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000159 ]),
160
161I_PPC_SMALL : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000162 (":build.macstand:PythonStandSmall.prj", "PythonStandSmall"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000163 ]),
164
165I_PPC_EXTENSIONS : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000166 (":Extensions:Imaging:_imaging.prj", "_imaging.ppc"),
167 (":Extensions:Imaging:_tkinter.prj", "_tkinter.ppc"),
168 (":Extensions:NumPy:numpymodules.prj", "numpymodules.ppc"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000169 ]),
170
171I_68K_EXTENSIONS : (buildmwproject, "CWIE", [
Jack Jansen82bfde91997-08-27 14:10:29 +0000172 (":Extensions:Imaging:_imaging.prj", "_imaging.CFM68K"),
173 (":Extensions:Imaging:_tkinter.prj", "_tkinter.CFM68K"),
174 (":Extensions:NumPy:numpymodules.prj", "numpymodules.CFM68K"),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000175 ]),
176
177I_APPLETS : (buildapplet, None, [
Jack Jansen6655c4e1995-09-01 12:03:32 +0000178 ":Mac:scripts:EditPythonPrefs.py",
Jack Jansen82bfde91997-08-27 14:10:29 +0000179 ":Mac:scripts:BuildApplet.py",
180 ":Mac:scripts:ConfigurePython.py"
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000181 ]),
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000182}
Jack Jansen6655c4e1995-09-01 12:03:32 +0000183
184def main():
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000185 try:
186 h = Res.OpenResFile('fullbuild.rsrc')
187 except Res.Error:
188 pass # Assume we already have acces to our own resource
189
Jack Jansen6655c4e1995-09-01 12:03:32 +0000190 dir, ok = macfs.GetDirectory('Python source folder:')
191 if not ok:
192 sys.exit(0)
193 dir = dir.as_pathname()
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000194
195 todo = handle_dialog()
196
197 instructions = []
198 for i in todo:
199 instructions.append(BUILD_DICT[i])
200
201 for routine, arg, list in instructions:
Jack Jansen8b4c9871997-05-07 15:52:12 +0000202 routine(dir, arg, list)
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000203
Jack Jansen6655c4e1995-09-01 12:03:32 +0000204 print "All done!"
205 sys.exit(1)
206
207if __name__ == '__main__':
208 main()
209