Index: build/mac/strip_save_dsym |
=================================================================== |
--- build/mac/strip_save_dsym (revision 22482) |
+++ build/mac/strip_save_dsym (working copy) |
@@ -43,13 +43,18 @@ |
# architecture. On error, returns an empty list. Determines the architecture |
# list by calling file. |
def macho_archs(macho): |
+ macho_types = ["executable", |
+ "dynamically linked shared library", |
+ "bundle"] |
+ macho_types_re = "Mach-O (?:64-bit )?(?:" + "|".join(macho_types) + ")" |
+ |
file_cmd = subprocess.Popen(["/usr/bin/file", "-b", "--", macho], |
- stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
+ stdout=subprocess.PIPE) |
archs = [] |
type_line = file_cmd.stdout.readline() |
- type_match = re.match("^Mach-O executable (.*)$", type_line) |
+ type_match = re.match("^%s (.*)$" % macho_types_re, type_line) |
if type_match: |
archs.append(type_match.group(1)) |
return [type_match.group(1)] |
@@ -60,7 +65,7 @@ |
for i in range(0, int(type_match.group(1))): |
arch_line = file_cmd.stdout.readline() |
arch_match = re.match( |
- "^.* \(for architecture (.*)\):\tMach-O executable .*$", |
+ "^.* \(for architecture (.*)\):\t%s .*$" % macho_types_re, |
arch_line) |
if arch_match: |
archs.append(arch_match.group(1)) |
@@ -68,6 +73,9 @@ |
if file_cmd.wait() != 0: |
archs = [] |
+ if len(archs) == 0: |
+ print >> sys.stderr, "No architectures in %s" % macho |
+ |
return archs |
# Returns a dictionary mapping architectures contained in the file as returned |
@@ -75,17 +83,19 @@ |
# Architectures with no LC_UUID load command are omitted from the dictionary. |
# Determines the UUID value by calling otool. |
def macho_uuids(macho): |
+ uuids = {} |
+ |
archs = macho_archs(macho) |
+ if len(archs) == 0: |
+ return uuids |
- uuids = {} |
- |
for arch in archs: |
if arch == "": |
continue |
otool_cmd = subprocess.Popen(["/usr/bin/otool", "-arch", arch, "-l", "-", |
macho], |
- stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
+ stdout=subprocess.PIPE) |
# state 0 is when nothing UUID-related has been seen yet. State 1 is |
# entered after a load command begins, but it may not be an LC_UUID load |
# command. States 2, 3, and 4 are intermediate states while reading an |
@@ -138,6 +148,9 @@ |
if state == 5: |
uuids[arch] = uuid.upper() |
+ if len(uuids) == 0: |
+ print >> sys.stderr, "No UUIDs in %s" % macho |
+ |
return uuids |
# Given a path to a Mach-O file and possible information from the environment, |
@@ -309,5 +322,5 @@ |
return 0 |
-if __name__ == '__main__': |
+if __name__ == "__main__": |
sys.exit(main(sys.argv)) |
Property changes on: build/mac/strip_save_dsym |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |