Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f00c5e

Browse files
committed
- Use cfmfile to (finally) implement building fat Pythons
- Turned the 10 or so yes/no questions into a single dialog
1 parent c70c350 commit 0f00c5e

2 files changed

Lines changed: 137 additions & 62 deletions

File tree

Mac/scripts/fullbuild.py

Lines changed: 120 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,36 @@
1919
import aetools
2020
import AppleEvents
2121
from Metrowerks_Shell_Suite import Metrowerks_Shell_Suite
22-
from Required_Suite import Required_Suite
22+
from Required_Suite import Required_Suite
23+
24+
import Res
25+
import Dlg
2326

2427
import mkapplet
28+
import 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.
33+
DIALOG_ID = 512
34+
35+
I_OK=1
36+
I_CANCEL=2
37+
38+
I_PPC_CORE=3
39+
I_PPC_PLUGINS=4
40+
I_PPC_EXTENSIONS=5
41+
I_68K_CORE=6
42+
I_68K_PLUGINS=7
43+
I_68K_EXTENSIONS=8
44+
I_PPC_FULL=9
45+
I_PPC_SMALL=10
46+
I_68K_FULL=11
47+
I_68K_SMALL=12
48+
I_FAT=13
49+
I_APPLETS=14
50+
51+
N_BUTTONS=15
2552

2653
class MwShell(aetools.TalkTo, Metrowerks_Shell_Suite, Required_Suite):
2754
pass
@@ -46,7 +73,7 @@ def buildmwproject(top, creator, projects):
4673
## mgr.quit()
4774

4875
def buildapplet(top, dummy, list):
49-
"""Create a PPC python applet"""
76+
"""Create python applets"""
5077
template = mkapplet.findtemplate()
5178
for src in list:
5279
if src[-3:] != '.py':
@@ -60,32 +87,55 @@ def buildapplet(top, dummy, list):
6087
pass
6188
print 'Building applet', dst
6289
mkapplet.process(template, src, dst)
90+
91+
def 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+
100+
def 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
63121

64122
#
65123
# The build instructions. Entries are (routine, arg, list-of-files)
66124
# XXXX We could also include the builds for stdwin and such here...
67-
PPC_INSTRUCTIONS=[
68-
(buildmwproject, "CWIE", [
125+
BUILD_DICT = {
126+
I_PPC_CORE : (buildmwproject, "CWIE", [
69127
":build.macppc.shared:PythonCorePPC.µ",
70128
":build.macppc.shared:PythonPPC.µ",
71129
":build.macppc.shared:PythonAppletPPC.µ",
72-
])
73-
]
74-
CFM68K_INSTRUCTIONS=[
75-
(buildmwproject, "CWIE", [
130+
]),
131+
132+
I_68K_CORE : (buildmwproject, "CWIE", [
76133
":build.mac68k.shared:PythonCoreCFM68K.µ",
77134
":build.mac68k.shared:PythonCFM68K.µ",
78135
":build.mac68k.shared:PythonAppletCFM68K.µ",
79-
])
80-
]
81-
FAT_INSTRUCTIONS=[
82-
(buildmwproject, "CWIE", [
83-
":build.macppc.shared:Python.µ",
84-
":build.macppc.shared:PythonApplet.µ",
85-
])
86-
]
87-
PLUGIN_INSTRUCTIONS=[
88-
(buildmwproject, "CWIE", [
136+
]),
137+
138+
I_PPC_PLUGINS : (buildmwproject, "CWIE", [
89139
":PlugIns:ctb.ppc.µ",
90140
":PlugIns:gdbm.ppc.µ",
91141
":PlugIns:icglue.ppc.µ",
@@ -96,10 +146,9 @@ def buildapplet(top, dummy, list):
96146
":PlugIns:waste.ppc.µ",
97147
":PlugIns:_tkinter.ppc.µ",
98148
":PlugIns:calldll.ppc.µ",
99-
])
100-
]
101-
CFM68KPLUGIN_INSTRUCTIONS=[
102-
(buildmwproject, "CWIE", [
149+
]),
150+
151+
I_68K_PLUGINS : (buildmwproject, "CWIE", [
103152
":PlugIns:ctb.CFM68K.µ",
104153
":PlugIns:gdbm.CFM68K.µ",
105154
":PlugIns:icglue.CFM68K.µ",
@@ -108,62 +157,71 @@ def buildapplet(top, dummy, list):
108157
":PlugIns:qtmodules.CFM68K.µ",
109158
":PlugIns:waste.CFM68K.µ",
110159
":PlugIns:_tkinter.CFM68K.µ",
111-
])
112-
]
113-
M68K_INSTRUCTIONS=[
114-
(buildmwproject, "CWIE", [
160+
]),
161+
162+
I_68K_FULL : (buildmwproject, "CWIE", [
115163
":build.mac68k.stand:Python68K.µ",
116-
])
117-
]
118-
PPCSTAND_INSTRUCTIONS=[
119-
(buildmwproject, "CWIE", [
164+
]),
165+
166+
I_68K_SMALL : (buildmwproject, "CWIE", [
167+
":build.mac68k.stand:Python68Ksmall.µ",
168+
]),
169+
170+
I_PPC_FULL : (buildmwproject, "CWIE", [
120171
":build.macppc.stand:PythonStandalone.µ",
121-
])
122-
]
123-
EXTENSION_INSTRUCTIONS=[
124-
(buildmwproject, "CWIE", [
172+
]),
173+
174+
I_PPC_SMALL : (buildmwproject, "CWIE", [
175+
":build.macppc.stand:PythonStandSmall.µ",
176+
]),
177+
178+
I_PPC_EXTENSIONS : (buildmwproject, "CWIE", [
125179
":Extensions:Imaging:_imaging.ppc.µ",
126-
":Extensions:Imaging:_imaging.CFM68K.µ",
127180
":Extensions:Imaging:_tkinter.ppc.µ",
128-
":Extensions:Imaging:_tkinter.CFM68K.µ",
129181
":Extensions:NumPy:numpymodules.ppc.µ",
182+
]),
183+
184+
I_68K_EXTENSIONS : (buildmwproject, "CWIE", [
185+
":Extensions:Imaging:_imaging.CFM68K.µ",
186+
":Extensions:Imaging:_tkinter.CFM68K.µ",
130187
":Extensions:NumPy:numpymodules.CFM68K.µ",
131-
])
132-
]
133-
APPLET_INSTRUCTIONS=[
134-
(buildapplet, None, [
188+
]),
189+
190+
I_APPLETS : (buildapplet, None, [
135191
":Mac:scripts:EditPythonPrefs.py",
136192
":Mac:scripts:mkapplet.py",
137193
":Mac:scripts:MkPluginAliases.py"
194+
]),
195+
196+
I_FAT : (buildfat, None, [
197+
(":Python", ":build.macppc.shared:PythonPPC",
198+
":build.mac68k.shared:PythonCFM68K"),
199+
(":PythonApplet", ":build.macppc.shared:PythonAppletPPC",
200+
":build.mac68k.shared:PythonAppletCFM68K")
138201
])
139-
]
140-
141-
ALLINST=[
142-
("PPC shared executable", PPC_INSTRUCTIONS),
143-
("PPC plugin modules", PLUGIN_INSTRUCTIONS),
144-
("CFM68K shared executable", CFM68K_INSTRUCTIONS),
145-
("CFM68K plugin modules", CFM68KPLUGIN_INSTRUCTIONS),
146-
("FAT shared executables", FAT_INSTRUCTIONS),
147-
("68K standalone executable", M68K_INSTRUCTIONS),
148-
("PPC standalone executable", PPCSTAND_INSTRUCTIONS),
149-
("Extensions", EXTENSION_INSTRUCTIONS),
150-
("Applets", APPLET_INSTRUCTIONS)
151-
]
202+
}
152203

153204
def main():
205+
try:
206+
h = Res.OpenResFile('fullbuild.rsrc')
207+
except Res.Error:
208+
pass # Assume we already have acces to our own resource
209+
154210
dir, ok = macfs.GetDirectory('Python source folder:')
155211
if not ok:
156212
sys.exit(0)
157213
dir = dir.as_pathname()
158-
INSTRUCTIONS = []
159-
for string, inst in ALLINST:
160-
answer = EasyDialogs.AskYesNoCancel("Build %s?"%string, 1)
161-
if answer < 0:
162-
sys.exit(0)
163-
if answer:
164-
INSTRUCTIONS = INSTRUCTIONS + inst
165-
for routine, arg, list in INSTRUCTIONS:
166-
routine(dir, arg, list)
214+
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:
222+
#routine(dir, arg, list)
223+
print routine, dir, arg, list # DBG
224+
167225
print "All done!"
168226
sys.exit(1)
169227

Mac/scripts/fullbuild.rsrc.hqx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(This file must be converted with BinHex 4.0)
2+
3+
:$QCeE'aLG@PXC#jbFh*M!(*cFQ058d9%!3#3"`-0T%X!N!3"!!!!!XF!!!((!!!
4+
!4J!!4dJ-8f0bC@9Z)%9KFf@U)!)!!!"45f9i8f0&B5%!$QCeE'aLG@PXC#jbFh*
5+
MFJ)!!!"bFh*M8P0&4!%!N!9bFh*M8P0&4!%!!!!"3!#3%Uq9%&m!N!B$$3#3#Ji
6+
!!!"(5!K6EfCd5f9jFfB#!!)!88YPH&&i8fXK!!!d!%!!N!4(L!#3$RNf!!"q!+K
7+
"F!#TGUAD!*!LMT%!"`#3$"3!N!39!#J!+!$l!IF!!3%!!3#3"3)!N!3"UJ!6!*!
8+
&Y!''!-J"`!3#6dX!N!@d!!S!b!"%"!C$B@jMC@`!N!8N!'F!0J$4"34$Eh*P!*!
9+
&*!$I!$B"538(8'aeCfPZFp%!N!8N!9F!0J(""3T&H(4PER0TEfjc!*!&2!"R!%i
10+
!d38%3fpbC3#3"6`!h`"1!8N&"e"XG@GTER24!*!&2!&A!%i"`38+4AKdC@jcD@p
11+
ZF`#3"9`!C`"Z!0%&"%CeE'`!N!9F!0m!EJ&*"396E@&XE'`!N!9d!'F!KJ$4"34
12+
'G@aX!*!&G!$I!)B"538&8feKE'a*!*!&P!"R!+B!d38*4Q&d)("bEfGc!`#3"C3
13+
!h`#Q!8N&"d&`F'aPG(08!*!&*!!0!$3!@)J$8&"$G!#3"6`!$3"-!&L)!cBi5eJ
14+
!N!9F!!d!E!"BL!T6G'&dD@-J8&"$!*!&G!!0!)3!@)J+8h4KG'PM)$Bi5`#3"C3
15+
!$3#N!&L)"%eTFf-!N!8)!)m!'!%JL"96C@aPBh3JGfKKG#"dEb"LG@PXC$TX!!!
16+
"!!!!!XF!!!((!!!!4J)YC+344!!!!"`!4J!"4%a24`!!!"*%594-!!!!(J)!rrm
17+
!N!3#,@0m!J$rr`!!!"N#,@*B93-:

0 commit comments

Comments
 (0)