@@ -52,7 +52,8 @@ def _GetOutputNoError(args):
52
52
the child (like file not found), the exception will be caught and (None, 1)
53
53
will be returned to mimic quiet failure."""
54
54
try :
55
- proc = subprocess .Popen (args , stdout = subprocess .PIPE ,
55
+ proc = subprocess .Popen (args ,
56
+ stdout = subprocess .PIPE ,
56
57
stderr = subprocess .PIPE )
57
58
except OSError :
58
59
return (None , 1 )
@@ -101,17 +102,18 @@ def _GetVersion(version_format, values, overrides=None):
101
102
return result
102
103
103
104
104
- def _AddVersionKeys (
105
- plist , version_format_for_key , version = None , overrides = None ):
105
+ def _AddVersionKeys (plist , version_format_for_key , version = None ,
106
+ overrides = None ):
106
107
"""Adds the product version number into the plist. Returns True on success and
107
108
False on error. The error will be printed to stderr."""
108
109
if not version :
109
110
# Pull in the Chrome version number.
110
111
VERSION_TOOL = os .path .join (TOP , 'build/util/version.py' )
111
112
VERSION_FILE = os .path .join (TOP , 'chrome/VERSION' )
112
113
(stdout , retval ) = _GetOutput ([
113
- VERSION_TOOL , '-f' , VERSION_FILE ,
114
- '-t' , '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' ])
114
+ VERSION_TOOL , '-f' , VERSION_FILE , '-t' ,
115
+ '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
116
+ ])
115
117
116
118
# If the command finished with a non-zero return code, then report the
117
119
# error up.
@@ -144,8 +146,8 @@ def _DoSCMKeys(plist, add_keys):
144
146
# Pull in the Chrome revision number.
145
147
VERSION_TOOL = os .path .join (TOP , 'build/util/version.py' )
146
148
LASTCHANGE_FILE = os .path .join (TOP , 'build/util/LASTCHANGE' )
147
- (stdout , retval ) = _GetOutput ([ VERSION_TOOL , '-f' , LASTCHANGE_FILE , '-t' ,
148
- '@LASTCHANGE@' ])
149
+ (stdout , retval ) = _GetOutput (
150
+ [ VERSION_TOOL , '-f' , LASTCHANGE_FILE , '-t' , '@LASTCHANGE@' ])
149
151
if retval :
150
152
return False
151
153
scm_revision = stdout .rstrip ()
@@ -178,20 +180,15 @@ def _AddBreakpadKeys(plist, branding, platform, staging):
178
180
179
181
def _RemoveBreakpadKeys (plist ):
180
182
"""Removes any set Breakpad keys."""
181
- _RemoveKeys (plist ,
182
- 'BreakpadURL' ,
183
- 'BreakpadReportInterval' ,
184
- 'BreakpadProduct' ,
185
- 'BreakpadProductDisplay' ,
186
- 'BreakpadVersion' ,
187
- 'BreakpadSendAndExit' ,
188
- 'BreakpadSkipConfirm' )
183
+ _RemoveKeys (plist , 'BreakpadURL' , 'BreakpadReportInterval' , 'BreakpadProduct' ,
184
+ 'BreakpadProductDisplay' , 'BreakpadVersion' ,
185
+ 'BreakpadSendAndExit' , 'BreakpadSkipConfirm' )
189
186
190
187
191
188
def _TagSuffixes ():
192
189
# Keep this list sorted in the order that tag suffix components are to
193
190
# appear in a tag value. That is to say, it should be sorted per ASCII.
194
- components = ('full' ,)
191
+ components = ('full' , )
195
192
assert tuple (sorted (components )) == components
196
193
197
194
components_len = len (components )
@@ -221,10 +218,7 @@ def _AddKeystoneKeys(plist, bundle_identifier):
221
218
222
219
def _RemoveKeystoneKeys (plist ):
223
220
"""Removes any set Keystone keys."""
224
- _RemoveKeys (plist ,
225
- 'KSVersion' ,
226
- 'KSProductID' ,
227
- 'KSUpdateURL' )
221
+ _RemoveKeys (plist , 'KSVersion' , 'KSProductID' , 'KSUpdateURL' )
228
222
229
223
tag_keys = []
230
224
for tag_suffix in _TagSuffixes ():
@@ -234,36 +228,72 @@ def _RemoveKeystoneKeys(plist):
234
228
235
229
def Main (argv ):
236
230
parser = optparse .OptionParser ('%prog [options]' )
237
- parser .add_option ('--plist' , dest = 'plist_path' , action = 'store' ,
238
- type = 'string' , default = None , help = 'The path of the plist to tweak.' )
231
+ parser .add_option ('--plist' ,
232
+ dest = 'plist_path' ,
233
+ action = 'store' ,
234
+ type = 'string' ,
235
+ default = None ,
236
+ help = 'The path of the plist to tweak.' )
239
237
parser .add_option ('--output' , dest = 'plist_output' , action = 'store' ,
240
238
type = 'string' , default = None , help = 'If specified, the path to output ' + \
241
239
'the tweaked plist, rather than overwriting the input.' )
242
- parser .add_option ('--breakpad' , dest = 'use_breakpad' , action = 'store' ,
243
- type = 'int' , default = False , help = 'Enable Breakpad [1 or 0]' )
244
- parser .add_option ('--breakpad_staging' , dest = 'use_breakpad_staging' ,
245
- action = 'store_true' , default = False ,
240
+ parser .add_option ('--breakpad' ,
241
+ dest = 'use_breakpad' ,
242
+ action = 'store' ,
243
+ type = 'int' ,
244
+ default = False ,
245
+ help = 'Enable Breakpad [1 or 0]' )
246
+ parser .add_option (
247
+ '--breakpad_staging' ,
248
+ dest = 'use_breakpad_staging' ,
249
+ action = 'store_true' ,
250
+ default = False ,
246
251
help = 'Use staging breakpad to upload reports. Ignored if --breakpad=0.' )
247
- parser .add_option ('--keystone' , dest = 'use_keystone' , action = 'store' ,
248
- type = 'int' , default = False , help = 'Enable Keystone [1 or 0]' )
249
- parser .add_option ('--scm' , dest = 'add_scm_info' , action = 'store' , type = 'int' ,
250
- default = True , help = 'Add SCM metadata [1 or 0]' )
251
- parser .add_option ('--branding' , dest = 'branding' , action = 'store' ,
252
- type = 'string' , default = None , help = 'The branding of the binary' )
253
- parser .add_option ('--bundle_id' , dest = 'bundle_identifier' ,
254
- action = 'store' , type = 'string' , default = None ,
255
- help = 'The bundle id of the binary' )
256
- parser .add_option ('--platform' , choices = ('ios' , 'mac' ), default = 'mac' ,
257
- help = 'The target platform of the bundle' )
258
- parser .add_option ('--version-overrides' , action = 'append' ,
252
+ parser .add_option ('--keystone' ,
253
+ dest = 'use_keystone' ,
254
+ action = 'store' ,
255
+ type = 'int' ,
256
+ default = False ,
257
+ help = 'Enable Keystone [1 or 0]' )
258
+ parser .add_option ('--scm' ,
259
+ dest = 'add_scm_info' ,
260
+ action = 'store' ,
261
+ type = 'int' ,
262
+ default = True ,
263
+ help = 'Add SCM metadata [1 or 0]' )
264
+ parser .add_option ('--branding' ,
265
+ dest = 'branding' ,
266
+ action = 'store' ,
267
+ type = 'string' ,
268
+ default = None ,
269
+ help = 'The branding of the binary' )
270
+ parser .add_option ('--bundle_id' ,
271
+ dest = 'bundle_identifier' ,
272
+ action = 'store' ,
273
+ type = 'string' ,
274
+ default = None ,
275
+ help = 'The bundle id of the binary' )
276
+ parser .add_option ('--platform' ,
277
+ choices = ('ios' , 'mac' ),
278
+ default = 'mac' ,
279
+ help = 'The target platform of the bundle' )
280
+ parser .add_option (
281
+ '--version-overrides' ,
282
+ action = 'append' ,
259
283
help = 'Key-value pair to override specific component of version '
260
- 'like key=value (can be passed multiple time to configure '
261
- 'more than one override)' )
262
- parser .add_option ('--format' , choices = ('binary1' , 'xml1' , 'json' ),
263
- default = 'xml1' , help = 'Format to use when writing property list '
264
- '(default: %(default)s)' )
265
- parser .add_option ('--version' , dest = 'version' , action = 'store' , type = 'string' ,
266
- default = None , help = 'The version string [major.minor.build.patch]' )
284
+ 'like key=value (can be passed multiple time to configure '
285
+ 'more than one override)' )
286
+ parser .add_option ('--format' ,
287
+ choices = ('binary1' , 'xml1' , 'json' ),
288
+ default = 'xml1' ,
289
+ help = 'Format to use when writing property list '
290
+ '(default: %(default)s)' )
291
+ parser .add_option ('--version' ,
292
+ dest = 'version' ,
293
+ action = 'store' ,
294
+ type = 'string' ,
295
+ default = None ,
296
+ help = 'The version string [major.minor.build.patch]' )
267
297
(options , args ) = parser .parse_args (argv )
268
298
269
299
if len (args ) > 0 :
@@ -297,32 +327,33 @@ def Main(argv):
297
327
298
328
if options .platform == 'mac' :
299
329
version_format_for_key = {
300
- # Add public version info so "Get Info" works.
301
- 'CFBundleShortVersionString' : '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' ,
302
-
303
- # Honor the 429496.72.95 limit. The maximum comes from splitting 2^32 - 1
304
- # into 6, 2, 2 digits. The limitation was present in Tiger, but it could
305
- # have been fixed in later OS release, but hasn't been tested (it's easy
306
- # enough to find out with "lsregister -dump).
307
- # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
308
- # BUILD will always be an increasing value, so BUILD_PATH gives us
309
- # something unique that meetings what LS wants.
310
- 'CFBundleVersion' : '@BUILD@.@PATCH@' ,
330
+ # Add public version info so "Get Info" works.
331
+ 'CFBundleShortVersionString' : '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' ,
332
+
333
+ # Honor the 429496.72.95 limit. The maximum comes from splitting
334
+ # 2^32 - 1 into 6, 2, 2 digits. The limitation was present in Tiger,
335
+ # but it could have been fixed in later OS release, but hasn't been
336
+ # tested (it's easy enough to find out with "lsregister -dump).
337
+ # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
338
+ # BUILD will always be an increasing value, so BUILD_PATH gives us
339
+ # something unique that meetings what LS wants.
340
+ 'CFBundleVersion' : '@BUILD@.@PATCH@' ,
311
341
}
312
342
else :
313
343
version_format_for_key = {
314
- 'CFBundleShortVersionString' : '@MAJOR@.@BUILD@.@PATCH@' ,
315
- 'CFBundleVersion' : '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
344
+ 'CFBundleShortVersionString' : '@MAJOR@.@BUILD@.@PATCH@' ,
345
+ 'CFBundleVersion' : '@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
316
346
}
317
347
318
348
if options .use_breakpad :
319
349
version_format_for_key ['BreakpadVersion' ] = \
320
350
'@MAJOR@.@MINOR@.@BUILD@.@PATCH@'
321
351
322
352
# Insert the product version.
323
- if not _AddVersionKeys (
324
- plist , version_format_for_key , version = options .version ,
325
- overrides = overrides ):
353
+ if not _AddVersionKeys (plist ,
354
+ version_format_for_key ,
355
+ version = options .version ,
356
+ overrides = overrides ):
326
357
return 2
327
358
328
359
# Add Breakpad if configured to do so.
@@ -334,7 +365,7 @@ def Main(argv):
334
365
# to the platform as known by breakpad.
335
366
platform = {'mac' : 'Mac' , 'ios' : 'iOS' }[options .platform ]
336
367
_AddBreakpadKeys (plist , options .branding , platform ,
337
- options .use_breakpad_staging )
368
+ options .use_breakpad_staging )
338
369
else :
339
370
_RemoveBreakpadKeys (plist )
340
371
0 commit comments