blob: 2cf10f7095cf82a60082a1e7fbdc0383a9a3f2d4 [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 Jansen0f00c5e1997-05-06 16:15:32 +000022from Required_Suite import Required_Suite
23
24import Res
25import Dlg
Jack Jansen6655c4e1995-09-01 12:03:32 +000026
Jack Jansen6655c4e1995-09-01 12:03:32 +000027import mkapplet
Jack Jansen0f00c5e1997-05-06 16:15:32 +000028import cfmfile
29
30# Dialog resource. Note that the item numbers should correspond
31# to those in the DITL resource. Also note that the order is important:
32# things are built in this order, so there should be no forward dependencies.
33DIALOG_ID = 512
34
35I_OK=1
36I_CANCEL=2
37
38I_PPC_CORE=3
39I_PPC_PLUGINS=4
40I_PPC_EXTENSIONS=5
41I_68K_CORE=6
42I_68K_PLUGINS=7
43I_68K_EXTENSIONS=8
44I_PPC_FULL=9
45I_PPC_SMALL=10
46I_68K_FULL=11
47I_68K_SMALL=12
48I_FAT=13
49I_APPLETS=14
50
51N_BUTTONS=15
Jack Jansen6655c4e1995-09-01 12:03:32 +000052
53class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite):
54 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:
64 file = os.path.join(top, file)
65 fss = macfs.FSSpec(file)
66 print 'Building', file
67 mgr.open(fss)
Jack Jansen1023dff1996-02-21 15:28:49 +000068 try:
69 mgr.Make_Project()
Jack Jansenb9e5e141996-09-20 15:30:52 +000070 except aetools.Error, arg:
71 print '** Failed:', arg
Jack Jansen6655c4e1995-09-01 12:03:32 +000072 mgr.Close_Project()
Jack Jansenf04fa721996-04-10 14:51:14 +000073## mgr.quit()
Jack Jansen6655c4e1995-09-01 12:03:32 +000074
75def buildapplet(top, dummy, list):
Jack Jansen0f00c5e1997-05-06 16:15:32 +000076 """Create python applets"""
Jack Jansen6655c4e1995-09-01 12:03:32 +000077 template = mkapplet.findtemplate()
78 for src in list:
79 if src[-3:] != '.py':
80 raise 'Should end in .py', src
81 base = os.path.basename(src)
82 dst = os.path.join(top, base)[:-3]
83 src = os.path.join(top, src)
84 try:
85 os.unlink(dst)
86 except os.error:
87 pass
88 print 'Building applet', dst
89 mkapplet.process(template, src, dst)
Jack Jansen0f00c5e1997-05-06 16:15:32 +000090
91def buildfat(top, dummy, list):
92 """Build fat binaries"""
93 for dst, src1, src2 in list:
94 dst = os.path.join(top, dst)
95 src1 = os.path.join(top, src1)
96 src2 = os.path.join(top, src2)
97 print 'Building fat binary', dst
98 cfmfile.mergecfmfiles((src1, src2), dst)
99
100def handle_dialog():
101 """Handle selection dialog, return list of selected items"""
102 d = Dlg.GetNewDialog(DIALOG_ID, -1)
103 d.SetDialogDefaultItem(I_OK)
104 d.SetDialogCancelItem(I_CANCEL)
105 results = [0]*N_BUTTONS
106 while 1:
107 n = Dlg.ModalDialog(None)
108 if n == I_OK:
109 break
110 if n == I_CANCEL:
111 return []
112 if n < len(results):
113 results[n] = (not results[n])
114 tp, h, rect = d.GetDialogItem(n)
115 h.as_Control().SetControlValue(results[n])
116 rv = []
117 for i in range(len(results)):
118 if results[i]:
119 rv.append(i)
120 return rv
Jack Jansen6655c4e1995-09-01 12:03:32 +0000121
122#
123# The build instructions. Entries are (routine, arg, list-of-files)
124# XXXX We could also include the builds for stdwin and such here...
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000125BUILD_DICT = {
126I_PPC_CORE : (buildmwproject, "CWIE", [
Jack Jansen05797151996-08-23 15:52:56 +0000127 ":build.macppc.shared:PythonCorePPC.µ",
Jack Jansen6655c4e1995-09-01 12:03:32 +0000128 ":build.macppc.shared:PythonPPC.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000129 ":build.macppc.shared:PythonAppletPPC.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000130 ]),
131
132I_68K_CORE : (buildmwproject, "CWIE", [
Jack Jansen25b361f1996-08-20 16:35:30 +0000133 ":build.mac68k.shared:PythonCoreCFM68K.µ",
134 ":build.mac68k.shared:PythonCFM68K.µ",
135 ":build.mac68k.shared:PythonAppletCFM68K.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000136 ]),
137
138I_PPC_PLUGINS : (buildmwproject, "CWIE", [
Jack Jansen8b4c9871997-05-07 15:52:12 +0000139 ":PlugIns:toolboxmodules.ppc.µ", # First: used by others
140 ":PlugIns:qtmodules.ppc.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000141 ":PlugIns:ctb.ppc.µ",
Jack Jansene1d325f1996-12-23 16:56:19 +0000142 ":PlugIns:gdbm.ppc.µ",
Jack Jansen52e87f31997-01-07 16:24:18 +0000143 ":PlugIns:icglue.ppc.µ",
Jack Jansen25b361f1996-08-20 16:35:30 +0000144 ":PlugIns:imgmodules.ppc.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000145 ":PlugIns:macspeech.ppc.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000146 ":PlugIns:waste.ppc.µ",
147 ":PlugIns:_tkinter.ppc.µ",
Jack Jansenab786561997-02-20 15:27:44 +0000148 ":PlugIns:calldll.ppc.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000149 ]),
150
151I_68K_PLUGINS : (buildmwproject, "CWIE", [
Jack Jansen8b4c9871997-05-07 15:52:12 +0000152 ":PlugIns:toolboxmodules.CFM68K.µ", # First: used by others
153 ":PlugIns:qtmodules.CFM68K.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000154 ":PlugIns:ctb.CFM68K.µ",
Jack Jansene1d325f1996-12-23 16:56:19 +0000155 ":PlugIns:gdbm.CFM68K.µ",
Jack Jansen52e87f31997-01-07 16:24:18 +0000156 ":PlugIns:icglue.CFM68K.µ",
Jack Jansend2034c11996-10-23 15:51:35 +0000157 ":PlugIns:imgmodules.CFM68K.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000158 ":PlugIns:waste.CFM68K.µ",
159 ":PlugIns:_tkinter.CFM68K.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000160 ]),
161
162I_68K_FULL : (buildmwproject, "CWIE", [
Jack Jansen6655c4e1995-09-01 12:03:32 +0000163 ":build.mac68k.stand:Python68K.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000164 ]),
165
166I_68K_SMALL : (buildmwproject, "CWIE", [
167 ":build.mac68k.stand:Python68Ksmall.µ",
168 ]),
169
170I_PPC_FULL : (buildmwproject, "CWIE", [
Jack Jansen05797151996-08-23 15:52:56 +0000171 ":build.macppc.stand:PythonStandalone.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000172 ]),
173
174I_PPC_SMALL : (buildmwproject, "CWIE", [
175 ":build.macppc.stand:PythonStandSmall.µ",
176 ]),
177
178I_PPC_EXTENSIONS : (buildmwproject, "CWIE", [
Jack Jansen52e87f31997-01-07 16:24:18 +0000179 ":Extensions:Imaging:_imaging.ppc.µ",
Jack Jansen02dee9b1997-01-31 16:13:26 +0000180 ":Extensions:Imaging:_tkinter.ppc.µ",
Jack Jansen52e87f31997-01-07 16:24:18 +0000181 ":Extensions:NumPy:numpymodules.ppc.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000182 ]),
183
184I_68K_EXTENSIONS : (buildmwproject, "CWIE", [
185 ":Extensions:Imaging:_imaging.CFM68K.µ",
186 ":Extensions:Imaging:_tkinter.CFM68K.µ",
Jack Jansen52e87f31997-01-07 16:24:18 +0000187 ":Extensions:NumPy:numpymodules.CFM68K.µ",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000188 ]),
189
190I_APPLETS : (buildapplet, None, [
Jack Jansen6655c4e1995-09-01 12:03:32 +0000191 ":Mac:scripts:EditPythonPrefs.py",
192 ":Mac:scripts:mkapplet.py",
Jack Jansenb39a5d71995-10-09 23:19:30 +0000193 ":Mac:scripts:MkPluginAliases.py"
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000194 ]),
Jack Jansenf04fa721996-04-10 14:51:14 +0000195
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000196I_FAT : (buildfat, None, [
Jack Jansen8b4c9871997-05-07 15:52:12 +0000197 (":PythonFAT", ":build.macppc.shared:PythonPPC",
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000198 ":build.mac68k.shared:PythonCFM68K"),
199 (":PythonApplet", ":build.macppc.shared:PythonAppletPPC",
200 ":build.mac68k.shared:PythonAppletCFM68K")
201 ])
202}
Jack Jansen6655c4e1995-09-01 12:03:32 +0000203
204def main():
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000205 try:
206 h = Res.OpenResFile('fullbuild.rsrc')
207 except Res.Error:
208 pass # Assume we already have acces to our own resource
209
Jack Jansen6655c4e1995-09-01 12:03:32 +0000210 dir, ok = macfs.GetDirectory('Python source folder:')
211 if not ok:
212 sys.exit(0)
213 dir = dir.as_pathname()
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000214
215 todo = handle_dialog()
216
217 instructions = []
218 for i in todo:
219 instructions.append(BUILD_DICT[i])
220
221 for routine, arg, list in instructions:
Jack Jansen8b4c9871997-05-07 15:52:12 +0000222 routine(dir, arg, list)
Jack Jansen0f00c5e1997-05-06 16:15:32 +0000223
Jack Jansen6655c4e1995-09-01 12:03:32 +0000224 print "All done!"
225 sys.exit(1)
226
227if __name__ == '__main__':
228 main()
229