Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
2f7bc74f
Commit
2f7bc74f
authored
Sep 24, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed the way .rsrc and template are copied: hopefully this will
finally get the bundle stuff right.
parent
5f867ee8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
36 deletions
+53
-36
Mac/scripts/BuildApplet.py
Mac/scripts/BuildApplet.py
+53
-36
No files found.
Mac/scripts/BuildApplet.py
View file @
2f7bc74f
...
@@ -31,6 +31,7 @@ RESTYPE = 'PYC '
...
@@ -31,6 +31,7 @@ RESTYPE = 'PYC '
RESNAME
=
'__main__'
RESNAME
=
'__main__'
# A resource with this name sets the "owner" (creator) of the destination
# A resource with this name sets the "owner" (creator) of the destination
# XXXX Should look for id=0
OWNERNAME
=
"owner resource"
OWNERNAME
=
"owner resource"
# OpenResFile mode parameters
# OpenResFile mode parameters
...
@@ -60,7 +61,8 @@ def main():
...
@@ -60,7 +61,8 @@ def main():
# (there's no point in proceeding if we can't find it)
# (there's no point in proceeding if we can't find it)
template
=
findtemplate
()
template
=
findtemplate
()
print
'Using template'
,
template
if
DEBUG
:
print
'Using template'
,
template
# Ask for source text if not specified in sys.argv[1:]
# Ask for source text if not specified in sys.argv[1:]
...
@@ -83,8 +85,6 @@ def main():
...
@@ -83,8 +85,6 @@ def main():
for
filename
in
sys
.
argv
[
1
:]:
for
filename
in
sys
.
argv
[
1
:]:
process
(
template
,
filename
,
''
)
process
(
template
,
filename
,
''
)
undefs
=
(
'Atmp'
,
'????'
,
' '
,
'
\
0
\
0
\
0
\
0
'
,
'BINA'
)
def
process
(
template
,
filename
,
output
):
def
process
(
template
,
filename
,
output
):
if
DEBUG
:
if
DEBUG
:
...
@@ -113,12 +113,22 @@ def process(template, filename, output):
...
@@ -113,12 +113,22 @@ def process(template, filename, output):
if
output
:
if
output
:
destname
=
output
destname
=
output
# Copy the data from the template (creating the file as well)
# Try removing the output file
try
:
os
.
unlink
(
output
)
except
os
.
error
:
pass
# Create FSSpecs for the various files
template_fss
=
macfs
.
FSSpec
(
template
)
template_fss
=
macfs
.
FSSpec
(
template
)
template_fss
,
d1
,
d2
=
macfs
.
ResolveAliasFile
(
template_fss
)
template_fss
,
d1
,
d2
=
macfs
.
ResolveAliasFile
(
template_fss
)
dest_fss
=
macfs
.
FSSpec
(
destname
)
dest_fss
=
macfs
.
FSSpec
(
destname
)
# Copy data (not resources, yet) from the template
tmpl
=
open
(
template
,
"rb"
)
tmpl
=
open
(
template
,
"rb"
)
dest
=
open
(
destname
,
"wb"
)
dest
=
open
(
destname
,
"wb"
)
data
=
tmpl
.
read
()
data
=
tmpl
.
read
()
...
@@ -127,14 +137,6 @@ def process(template, filename, output):
...
@@ -127,14 +137,6 @@ def process(template, filename, output):
dest
.
close
()
dest
.
close
()
tmpl
.
close
()
tmpl
.
close
()
# Copy the creator of the template to the destination
# unless it already got one. Set type to APPL
tctor
,
ttype
=
template_fss
.
GetCreatorType
()
ctor
,
type
=
dest_fss
.
GetCreatorType
()
if
type
in
undefs
:
type
=
'APPL'
if
ctor
in
undefs
:
ctor
=
tctor
# Open the output resource fork
# Open the output resource fork
try
:
try
:
...
@@ -144,30 +146,38 @@ def process(template, filename, output):
...
@@ -144,30 +146,38 @@ def process(template, filename, output):
print
"Creating resource fork..."
print
"Creating resource fork..."
CreateResFile
(
destname
)
CreateResFile
(
destname
)
output
=
FSpOpenResFile
(
dest_fss
,
WRITE
)
output
=
FSpOpenResFile
(
dest_fss
,
WRITE
)
# Copy the resources from the template
input
=
FSpOpenResFile
(
template_fss
,
READ
)
newctor
=
copyres
(
input
,
output
)
CloseResFile
(
input
)
if
newctor
:
ctor
=
newctor
# Copy the resources from the target specific resource template, if any
# Copy the resources from the target specific resource template, if any
typesfound
,
ownertype
=
[],
None
try
:
try
:
input
=
FSpOpenResFile
(
rsrcname
,
READ
)
input
=
FSpOpenResFile
(
rsrcname
,
READ
)
except
(
MacOS
.
Error
,
ValueError
):
except
(
MacOS
.
Error
,
ValueError
):
print
'No resource file'
,
rsrcname
pass
pass
else
:
else
:
newctor
=
copyres
(
input
,
output
)
typesfound
,
ownertype
=
copyres
(
input
,
output
,
[],
0
)
CloseResFile
(
input
)
CloseResFile
(
input
)
if
newctor
:
ctor
=
newctor
# Check which resource-types we should not copy from the template
skiptypes
=
[]
if
'SIZE'
in
typesfound
:
skiptypes
.
append
(
'SIZE'
)
if
'BNDL'
in
typesfound
:
skiptypes
=
skiptypes
+
[
'BNDL'
,
'FREF'
,
'icl4'
,
'icl8'
,
'ics4'
,
'ics8'
,
'ICN#'
,
'ics#'
]
skipowner
=
(
ownertype
<>
None
)
# Copy the resources from the template
input
=
FSpOpenResFile
(
template_fss
,
READ
)
dummy
,
tmplowner
=
copyres
(
input
,
output
,
skiptypes
,
skipowner
)
if
ownertype
==
None
:
ownertype
=
tmplowner
CloseResFile
(
input
)
if
ownertype
==
None
:
die
(
"No owner resource found in either resource file or template"
)
# Now set the creator, type and bundle bit of the destination
# Now set the creator, type and bundle bit of the destination
dest_finfo
=
dest_fss
.
GetFInfo
()
dest_finfo
=
dest_fss
.
GetFInfo
()
dest_finfo
.
Creator
=
ctor
dest_finfo
.
Creator
=
ownertype
dest_finfo
.
Type
=
type
dest_finfo
.
Type
=
'APPL'
dest_finfo
.
Flags
=
dest_finfo
.
Flags
|
MACFS
.
kHasBundle
dest_finfo
.
Flags
=
dest_finfo
.
Flags
|
MACFS
.
kHasBundle
dest_finfo
.
Flags
=
dest_finfo
.
Flags
&
~
MACFS
.
kHasBeenInited
dest_finfo
.
Flags
=
dest_finfo
.
Flags
&
~
MACFS
.
kHasBeenInited
dest_fss
.
SetFInfo
(
dest_finfo
)
dest_fss
.
SetFInfo
(
dest_finfo
)
...
@@ -176,7 +186,7 @@ def process(template, filename, output):
...
@@ -176,7 +186,7 @@ def process(template, filename, output):
UseResFile
(
output
)
UseResFile
(
output
)
# Delete any existing 'PYC 'resource named __main__
# Delete any existing 'PYC '
resource named __main__
try
:
try
:
res
=
Get1NamedResource
(
RESTYPE
,
RESNAME
)
res
=
Get1NamedResource
(
RESTYPE
,
RESNAME
)
...
@@ -210,16 +220,19 @@ def process(template, filename, output):
...
@@ -210,16 +220,19 @@ def process(template, filename, output):
# Copy resources between two resource file descriptors.
# Copy resources between two resource file descriptors.
# Exception: don't copy a __main__ resource.
# skip a resource named '__main__' or (if skipowner is set) 'Owner resource'.
# If a resource's name is "owner resource", its type is returned
# Also skip resources with a type listed in skiptypes.
# (so the caller can use it to set the destination's creator)
#
def
copyres
(
input
,
output
,
skiptypes
,
skipowner
):
def
copyres
(
input
,
output
):
ctor
=
None
ctor
=
None
alltypes
=
[]
UseResFile
(
input
)
UseResFile
(
input
)
ntypes
=
Count1Types
()
ntypes
=
Count1Types
()
for
itype
in
range
(
1
,
1
+
ntypes
):
for
itype
in
range
(
1
,
1
+
ntypes
):
type
=
Get1IndType
(
itype
)
type
=
Get1IndType
(
itype
)
if
type
in
skiptypes
:
continue
alltypes
.
append
(
type
)
nresources
=
Count1Resources
(
type
)
nresources
=
Count1Resources
(
type
)
for
ires
in
range
(
1
,
1
+
nresources
):
for
ires
in
range
(
1
,
1
+
nresources
):
res
=
Get1IndResource
(
type
,
ires
)
res
=
Get1IndResource
(
type
,
ires
)
...
@@ -227,7 +240,12 @@ def copyres(input, output):
...
@@ -227,7 +240,12 @@ def copyres(input, output):
lcname
=
string
.
lower
(
name
)
lcname
=
string
.
lower
(
name
)
if
(
type
,
lcname
)
==
(
RESTYPE
,
RESNAME
):
if
(
type
,
lcname
)
==
(
RESTYPE
,
RESNAME
):
continue
# Don't copy __main__ from template
continue
# Don't copy __main__ from template
if
lcname
==
OWNERNAME
:
ctor
=
type
# XXXX should look for id=0
if
lcname
==
OWNERNAME
:
if
skipowner
:
continue
# Skip this one
else
:
ctor
=
type
size
=
res
.
size
size
=
res
.
size
attrs
=
res
.
GetResAttrs
()
attrs
=
res
.
GetResAttrs
()
if
DEBUG
:
if
DEBUG
:
...
@@ -250,7 +268,7 @@ def copyres(input, output):
...
@@ -250,7 +268,7 @@ def copyres(input, output):
print
"New attrs ="
,
hex
(
attrs
)
print
"New attrs ="
,
hex
(
attrs
)
res
.
SetResAttrs
(
attrs
)
res
.
SetResAttrs
(
attrs
)
UseResFile
(
input
)
UseResFile
(
input
)
return
ctor
return
alltypes
,
ctor
# Show a message and exit
# Show a message and exit
...
@@ -279,4 +297,3 @@ def message(str, id = 256):
...
@@ -279,4 +297,3 @@ def message(str, id = 256):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment