blob: 0247c4b286ad99d4e12d1a1e92174690c8e0ee81 [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
22from Required_Suite import Required_Suite
23
24addpack.addpack('Mac')
25addpack.addpack('scripts')
26import mkapplet
27
28class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite):
29 pass
30
Jack Jansenf04fa721996-04-10 14:51:14 +000031RUNNING=[]
Jack Jansen6655c4e1995-09-01 12:03:32 +000032
33def buildmwproject(top, creator, projects):
34 """Build projects with an MW compiler"""
Jack Jansenf04fa721996-04-10 14:51:14 +000035 if not creator in RUNNING:
36 print 'Please start project mgr with signature', creator,'-'
37 sys.stdin.readline()
38 RUNNING.append(creator)
Jack Jansen6655c4e1995-09-01 12:03:32 +000039 try:
40 mgr = MwShell(creator)
41 except 'foo':
42 print 'Not handled:', creator
43 return
Jack Jansen1023dff1996-02-21 15:28:49 +000044 mgr.send_timeout = AppleEvents.kNoTimeOut
45
Jack Jansen6655c4e1995-09-01 12:03:32 +000046 for file in projects:
47 file = os.path.join(top, file)
48 fss = macfs.FSSpec(file)
49 print 'Building', file
50 mgr.open(fss)
Jack Jansen1023dff1996-02-21 15:28:49 +000051 try:
52 mgr.Make_Project()
53 except MacOS.Error, arg:
54 print '** Failed. Possible error:', arg
Jack Jansen6655c4e1995-09-01 12:03:32 +000055 mgr.Close_Project()
Jack Jansenf04fa721996-04-10 14:51:14 +000056## mgr.quit()
Jack Jansen6655c4e1995-09-01 12:03:32 +000057
58def buildapplet(top, dummy, list):
59 """Create a PPC python applet"""
60 template = mkapplet.findtemplate()
61 for src in list:
62 if src[-3:] != '.py':
63 raise 'Should end in .py', src
64 base = os.path.basename(src)
65 dst = os.path.join(top, base)[:-3]
66 src = os.path.join(top, src)
67 try:
68 os.unlink(dst)
69 except os.error:
70 pass
71 print 'Building applet', dst
72 mkapplet.process(template, src, dst)
73
74#
75# The build instructions. Entries are (routine, arg, list-of-files)
76# XXXX We could also include the builds for stdwin and such here...
Jack Jansenf04fa721996-04-10 14:51:14 +000077PPC_INSTRUCTIONS=[
Jack Jansenb39a5d71995-10-09 23:19:30 +000078 (buildmwproject, "CWIE", [
Jack Jansen05797151996-08-23 15:52:56 +000079 ":build.macppc.shared:PythonCorePPC.µ",
Jack Jansen6655c4e1995-09-01 12:03:32 +000080 ":build.macppc.shared:PythonPPC.µ",
Jack Jansen05797151996-08-23 15:52:56 +000081 ":build.macppc.shared:PythonAppletPPC.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +000082 ])
83]
Jack Jansen25b361f1996-08-20 16:35:30 +000084CFM68K_INSTRUCTIONS=[
85 (buildmwproject, "CWIE", [
86 ":build.mac68k.shared:PythonCoreCFM68K.µ",
87 ":build.mac68k.shared:PythonCFM68K.µ",
88 ":build.mac68k.shared:PythonAppletCFM68K.µ",
89 ])
90]
Jack Jansen05797151996-08-23 15:52:56 +000091FAT_INSTRUCTIONS=[
92 (buildmwproject, "CWIE", [
93 ":build.macppc.shared:Python.µ",
94 ":build.macppc.shared:PythonApplet.µ",
95 ])
96]
Jack Jansenf04fa721996-04-10 14:51:14 +000097PLUGIN_INSTRUCTIONS=[
98 (buildmwproject, "CWIE", [
Jack Jansen05797151996-08-23 15:52:56 +000099 ":PlugIns:ctb.ppc.µ",
Jack Jansen25b361f1996-08-20 16:35:30 +0000100 ":PlugIns:imgmodules.ppc.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000101 ":PlugIns:macspeech.ppc.µ",
Jack Jansen25b361f1996-08-20 16:35:30 +0000102 ":PlugIns:toolboxmodules.ppc.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000103 ":PlugIns:qtmodules.ppc.µ",
104 ":PlugIns:waste.ppc.µ",
105 ":PlugIns:_tkinter.ppc.µ",
Jack Jansen25b361f1996-08-20 16:35:30 +0000106 ])
107]
108CFM68KPLUGIN_INSTRUCTIONS=[
109 (buildmwproject, "CWIE", [
Jack Jansen05797151996-08-23 15:52:56 +0000110 ":PlugIns:ctb.CFM68K.µ",
111 ":PlugIns:imgmodules.ppc.µ",
Jack Jansen25b361f1996-08-20 16:35:30 +0000112 ":PlugIns:toolboxmodules.CFM68K.µ",
Jack Jansen05797151996-08-23 15:52:56 +0000113 ":PlugIns:qtmodules.CFM68K.µ",
114 ":PlugIns:waste.CFM68K.µ",
115 ":PlugIns:_tkinter.CFM68K.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +0000116 ])
117]
118M68K_INSTRUCTIONS=[
119 (buildmwproject, "CWIE", [
Jack Jansen6655c4e1995-09-01 12:03:32 +0000120 ":build.mac68k.stand:Python68K.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +0000121 ])
122]
Jack Jansen05797151996-08-23 15:52:56 +0000123PPCSTAND_INSTRUCTIONS=[
124 (buildmwproject, "CWIE", [
125 ":build.macppc.stand:PythonStandalone.µ",
126 ])
127]
Jack Jansenf04fa721996-04-10 14:51:14 +0000128APPLET_INSTRUCTIONS=[
Jack Jansen6655c4e1995-09-01 12:03:32 +0000129 (buildapplet, None, [
130 ":Mac:scripts:EditPythonPrefs.py",
131 ":Mac:scripts:mkapplet.py",
Jack Jansenb39a5d71995-10-09 23:19:30 +0000132 ":Mac:scripts:RunLibScript.py",
133 ":Mac:scripts:MkPluginAliases.py"
Jack Jansen6655c4e1995-09-01 12:03:32 +0000134 ])
135]
Jack Jansenf04fa721996-04-10 14:51:14 +0000136
137ALLINST=[
138 ("PPC shared executable", PPC_INSTRUCTIONS),
139 ("PPC plugin modules", PLUGIN_INSTRUCTIONS),
Jack Jansen25b361f1996-08-20 16:35:30 +0000140 ("CFM68K shared executable", CFM68K_INSTRUCTIONS),
Jack Jansen05797151996-08-23 15:52:56 +0000141 ("CFM68K plugin modules", CFM68KPLUGIN_INSTRUCTIONS),
142 ("FAT shared executables", FAT_INSTRUCTIONS),
Jack Jansen25b361f1996-08-20 16:35:30 +0000143 ("68K standalone executable", M68K_INSTRUCTIONS),
Jack Jansen05797151996-08-23 15:52:56 +0000144 ("PPC standalone executable", PPCSTAND_INSTRUCTIONS),
Jack Jansen25b361f1996-08-20 16:35:30 +0000145 ("Applets", APPLET_INSTRUCTIONS)
Jack Jansenf04fa721996-04-10 14:51:14 +0000146]
Jack Jansen6655c4e1995-09-01 12:03:32 +0000147
148def main():
149 dir, ok = macfs.GetDirectory('Python source folder:')
150 if not ok:
151 sys.exit(0)
152 dir = dir.as_pathname()
Jack Jansenf04fa721996-04-10 14:51:14 +0000153 INSTRUCTIONS = []
154 for string, inst in ALLINST:
155 answer = EasyDialogs.AskYesNoCancel("Build %s?"%string, 1)
156 if answer < 0:
157 sys.exit(0)
158 if answer:
159 INSTRUCTIONS = INSTRUCTIONS + inst
Jack Jansen6655c4e1995-09-01 12:03:32 +0000160 for routine, arg, list in INSTRUCTIONS:
161 routine(dir, arg, list)
162 print "All done!"
163 sys.exit(1)
164
165if __name__ == '__main__':
166 main()
167