OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 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 # | 7 # |
8 # Xcode supports build variable substitutions and CPP; sadly, that doesn't work | 8 # Xcode supports build variable substitutions and CPP; sadly, that doesn't work |
9 # because: | 9 # because: |
10 # | 10 # |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 tag_keys = [] | 196 tag_keys = [] |
197 for tag_suffix in _TagSuffixes(): | 197 for tag_suffix in _TagSuffixes(): |
198 tag_keys.append('KSChannelID' + tag_suffix) | 198 tag_keys.append('KSChannelID' + tag_suffix) |
199 _RemoveKeys(plist, *tag_keys) | 199 _RemoveKeys(plist, *tag_keys) |
200 | 200 |
201 | 201 |
202 def Main(argv): | 202 def Main(argv): |
203 parser = optparse.OptionParser('%prog [options]') | 203 parser = optparse.OptionParser('%prog [options]') |
204 parser.add_option('--plist', dest='plist_path', action='store', | 204 parser.add_option('--plist', dest='plist_path', action='store', |
205 type='string', default=None, help='The path of the plist to tweak.') | 205 type='string', default=None, help='The path of the plist to tweak.') |
| 206 parser.add_option('--output', dest='plist_output', action='store', |
| 207 type='string', default=None, help='If specified, the path to output ' + \ |
| 208 'the tweaked plist, rather than overwriting the input.') |
206 parser.add_option('--breakpad', dest='use_breakpad', action='store', | 209 parser.add_option('--breakpad', dest='use_breakpad', action='store', |
207 type='int', default=False, help='Enable Breakpad [1 or 0]') | 210 type='int', default=False, help='Enable Breakpad [1 or 0]') |
208 parser.add_option('--breakpad_uploads', dest='breakpad_uploads', | 211 parser.add_option('--breakpad_uploads', dest='breakpad_uploads', |
209 action='store', type='int', default=False, | 212 action='store', type='int', default=False, |
210 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]') | 213 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]') |
211 parser.add_option('--keystone', dest='use_keystone', action='store', | 214 parser.add_option('--keystone', dest='use_keystone', action='store', |
212 type='int', default=False, help='Enable Keystone [1 or 0]') | 215 type='int', default=False, help='Enable Keystone [1 or 0]') |
213 parser.add_option('--scm', dest='add_scm_info', action='store', type='int', | 216 parser.add_option('--scm', dest='add_scm_info', action='store', type='int', |
214 default=True, help='Add SCM metadata [1 or 0]') | 217 default=True, help='Add SCM metadata [1 or 0]') |
215 parser.add_option('--branding', dest='branding', action='store', | 218 parser.add_option('--branding', dest='branding', action='store', |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 # Adds or removes any SCM keys. | 270 # Adds or removes any SCM keys. |
268 if not _DoSCMKeys(plist, options.add_scm_info): | 271 if not _DoSCMKeys(plist, options.add_scm_info): |
269 return 3 | 272 return 3 |
270 | 273 |
271 # Now that all keys have been mutated, rewrite the file. | 274 # Now that all keys have been mutated, rewrite the file. |
272 temp_info_plist = tempfile.NamedTemporaryFile() | 275 temp_info_plist = tempfile.NamedTemporaryFile() |
273 plistlib.writePlist(plist, temp_info_plist.name) | 276 plistlib.writePlist(plist, temp_info_plist.name) |
274 | 277 |
275 # Info.plist will work perfectly well in any plist format, but traditionally | 278 # Info.plist will work perfectly well in any plist format, but traditionally |
276 # applications use xml1 for this, so convert it to ensure that it's valid. | 279 # applications use xml1 for this, so convert it to ensure that it's valid. |
| 280 output_path = options.plist_path |
| 281 if options.plist_output is not None: |
| 282 output_path = options.plist_output |
277 proc = subprocess.Popen(['plutil', '-convert', 'xml1', | 283 proc = subprocess.Popen(['plutil', '-convert', 'xml1', |
278 '-o', options.plist_path, | 284 '-o', output_path, |
279 temp_info_plist.name]) | 285 temp_info_plist.name]) |
280 proc.wait() | 286 proc.wait() |
281 return proc.returncode | 287 return proc.returncode |
282 | 288 |
283 | 289 |
284 if __name__ == '__main__': | 290 if __name__ == '__main__': |
285 sys.exit(Main(sys.argv[1:])) | 291 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |