blob: 71edb554edee4cb5f6b84674d5866dde80a946bd [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 Jansen6655c4e1995-09-01 12:03:32 +000079 ":build.macppc.shared:PythonCore.µ",
80 ":build.macppc.shared:PythonPPC.µ",
81 ":build.macppc.shared:PythonApplet.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +000082 ])
83]
84PLUGIN_INSTRUCTIONS=[
85 (buildmwproject, "CWIE", [
Jack Jansen6655c4e1995-09-01 12:03:32 +000086 ":PlugIns:ctbmodule.µ",
87 ":PlugIns:imgmodules.µ",
88 ":PlugIns:macspeechmodule.µ",
89 ":PlugIns:mactcpmodules.µ",
90 ":PlugIns:stdwinmodule.µ",
91 ":PlugIns:toolboxmodules.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +000092 ])
93]
94M68K_INSTRUCTIONS=[
95 (buildmwproject, "CWIE", [
Jack Jansen6655c4e1995-09-01 12:03:32 +000096 ":build.mac68k.stand:Python68K.µ",
Jack Jansenf04fa721996-04-10 14:51:14 +000097 ])
98]
99APPLET_INSTRUCTIONS=[
Jack Jansen6655c4e1995-09-01 12:03:32 +0000100 (buildapplet, None, [
101 ":Mac:scripts:EditPythonPrefs.py",
102 ":Mac:scripts:mkapplet.py",
Jack Jansenb39a5d71995-10-09 23:19:30 +0000103 ":Mac:scripts:RunLibScript.py",
104 ":Mac:scripts:MkPluginAliases.py"
Jack Jansen6655c4e1995-09-01 12:03:32 +0000105 ])
106]
Jack Jansenf04fa721996-04-10 14:51:14 +0000107
108ALLINST=[
109 ("PPC shared executable", PPC_INSTRUCTIONS),
110 ("PPC plugin modules", PLUGIN_INSTRUCTIONS),
111 ("68K executable", M68K_INSTRUCTIONS),
112 ("PPC applets", APPLET_INSTRUCTIONS)
113]
Jack Jansen6655c4e1995-09-01 12:03:32 +0000114
115def main():
116 dir, ok = macfs.GetDirectory('Python source folder:')
117 if not ok:
118 sys.exit(0)
119 dir = dir.as_pathname()
Jack Jansenf04fa721996-04-10 14:51:14 +0000120 INSTRUCTIONS = []
121 for string, inst in ALLINST:
122 answer = EasyDialogs.AskYesNoCancel("Build %s?"%string, 1)
123 if answer < 0:
124 sys.exit(0)
125 if answer:
126 INSTRUCTIONS = INSTRUCTIONS + inst
Jack Jansen6655c4e1995-09-01 12:03:32 +0000127 for routine, arg, list in INSTRUCTIONS:
128 routine(dir, arg, list)
129 print "All done!"
130 sys.exit(1)
131
132if __name__ == '__main__':
133 main()
134