OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2008 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2008 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # Usage: strip_save_dsym <whatever-arguments-you-would-pass-to-strip> | 7 # Usage: strip_save_dsym <whatever-arguments-you-would-pass-to-strip> |
8 # | 8 # |
9 # strip_save_dsym is a wrapper around the standard strip utility. Given an | 9 # strip_save_dsym is a wrapper around the standard strip utility. Given an |
10 # input Mach-O file, strip_save_dsym will save a copy of the file in a "fake" | 10 # input Mach-O file, strip_save_dsym will save a copy of the file in a "fake" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 if re.match("^ cmd LC_UUID$", otool_line): | 111 if re.match("^ cmd LC_UUID$", otool_line): |
112 state = 2 | 112 state = 2 |
113 else: | 113 else: |
114 state = 0 | 114 state = 0 |
115 elif state == 2: | 115 elif state == 2: |
116 if re.match("^ cmdsize 24$", otool_line): | 116 if re.match("^ cmdsize 24$", otool_line): |
117 state = 3 | 117 state = 3 |
118 else: | 118 else: |
119 state = 6 | 119 state = 6 |
120 elif state == 3: | 120 elif state == 3: |
121 uuid_match = re.match("^ uuid 0x(..) 0x(..) 0x(..) 0x(..) " | 121 # The UUID display format changed in the version of otool shipping |
122 "0x(..) 0x(..) 0x(..) 0x(..)$", | 122 # with the Xcode 3.2.2 prerelease. The new format is traditional: |
123 otool_line) | 123 # uuid 4D7135B2-9C56-C5F5-5F49-A994258E0955 |
124 if uuid_match: | 124 # The old format, from cctools-750 and older's otool, breaks the UUID |
125 state = 4 | 125 # up into a sequence of bytes: |
126 uuid = uuid_match.group(1) + uuid_match.group(2) + \ | 126 # uuid 0x4d 0x71 0x35 0xb2 0x9c 0x56 0xc5 0xf5 |
127 uuid_match.group(3) + uuid_match.group(4) + "-" + \ | 127 # 0x5f 0x49 0xa9 0x94 0x25 0x8e 0x09 0x55 |
128 uuid_match.group(5) + uuid_match.group(6) + "-" + \ | 128 new_uuid_match = re.match("^ uuid (.{8}-.{4}-.{4}-.{4}-.{12})$", |
129 uuid_match.group(7) + uuid_match.group(8) + "-" | 129 otool_line) |
| 130 if new_uuid_match: |
| 131 uuid = new_uuid_match.group(1) |
| 132 |
| 133 # Skip state 4, there is no second line to read. |
| 134 state = 5 |
130 else: | 135 else: |
131 state = 6 | 136 old_uuid_match = re.match("^ uuid 0x(..) 0x(..) 0x(..) 0x(..) " |
| 137 "0x(..) 0x(..) 0x(..) 0x(..)$", |
| 138 otool_line) |
| 139 if old_uuid_match: |
| 140 state = 4 |
| 141 uuid = old_uuid_match.group(1) + old_uuid_match.group(2) + \ |
| 142 old_uuid_match.group(3) + old_uuid_match.group(4) + "-" + \ |
| 143 old_uuid_match.group(5) + old_uuid_match.group(6) + "-" + \ |
| 144 old_uuid_match.group(7) + old_uuid_match.group(8) + "-" |
| 145 else: |
| 146 state = 6 |
132 elif state == 4: | 147 elif state == 4: |
133 uuid_match = re.match("^ 0x(..) 0x(..) 0x(..) 0x(..) " | 148 old_uuid_match = re.match("^ 0x(..) 0x(..) 0x(..) 0x(..) " |
134 "0x(..) 0x(..) 0x(..) 0x(..)$", | 149 "0x(..) 0x(..) 0x(..) 0x(..)$", |
135 otool_line) | 150 otool_line) |
136 if uuid_match: | 151 if old_uuid_match: |
137 state = 5 | 152 state = 5 |
138 uuid += uuid_match.group(1) + uuid_match.group(2) + "-" + \ | 153 uuid += old_uuid_match.group(1) + old_uuid_match.group(2) + "-" + \ |
139 uuid_match.group(3) + uuid_match.group(4) + \ | 154 old_uuid_match.group(3) + old_uuid_match.group(4) + \ |
140 uuid_match.group(5) + uuid_match.group(6) + \ | 155 old_uuid_match.group(5) + old_uuid_match.group(6) + \ |
141 uuid_match.group(7) + uuid_match.group(8) | 156 old_uuid_match.group(7) + old_uuid_match.group(8) |
142 else: | 157 else: |
143 state = 6 | 158 state = 6 |
144 | 159 |
145 if otool_cmd.wait() != 0: | 160 if otool_cmd.wait() != 0: |
146 state = 6 | 161 state = 6 |
147 | 162 |
148 if state == 5: | 163 if state == 5: |
149 uuids[arch] = uuid.upper() | 164 uuids[arch] = uuid.upper() |
150 | 165 |
151 if len(uuids) == 0: | 166 if len(uuids) == 0: |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 print >> sys.stderr, "Nothing to strip" | 332 print >> sys.stderr, "Nothing to strip" |
318 return 1 | 333 return 1 |
319 | 334 |
320 if not strip_and_make_fake_dsym(macho): | 335 if not strip_and_make_fake_dsym(macho): |
321 return 1 | 336 return 1 |
322 | 337 |
323 return 0 | 338 return 0 |
324 | 339 |
325 if __name__ == "__main__": | 340 if __name__ == "__main__": |
326 sys.exit(main(sys.argv)) | 341 sys.exit(main(sys.argv)) |
OLD | NEW |