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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 | 120 |
121 # Parse the given version number, that should be in MAJOR.MINOR.BUILD.PATCH | 121 # Parse the given version number, that should be in MAJOR.MINOR.BUILD.PATCH |
122 # format (where each value is a number). Note that str.isdigit() returns | 122 # format (where each value is a number). Note that str.isdigit() returns |
123 # True if the string is composed only of digits (and thus match \d+ regexp). | 123 # True if the string is composed only of digits (and thus match \d+ regexp). |
124 groups = version.split('.') | 124 groups = version.split('.') |
125 if len(groups) != 4 or not all(element.isdigit() for element in groups): | 125 if len(groups) != 4 or not all(element.isdigit() for element in groups): |
126 print >>sys.stderr, 'Invalid version string specified: "%s"' % version | 126 print >>sys.stderr, 'Invalid version string specified: "%s"' % version |
127 return False | 127 return False |
128 values = dict(zip(('MAJOR', 'MINOR', 'BUILD', 'PATCH'), groups)) | 128 values = dict(zip(('MAJOR', 'MINOR', 'BUILD', 'PATCH'), groups)) |
129 | 129 |
130 for key in ('CFBundleVersion', 'CFBundleShortVersionString'): | 130 for key in version_format_for_key: |
131 plist[key] = _GetVersion(version_format_for_key[key], values, overrides) | 131 plist[key] = _GetVersion(version_format_for_key[key], values, overrides) |
132 | 132 |
133 # Return with no error. | 133 # Return with no error. |
134 return True | 134 return True |
135 | 135 |
136 | 136 |
137 def _DoSCMKeys(plist, add_keys): | 137 def _DoSCMKeys(plist, add_keys): |
138 """Adds the SCM information, visible in about:version, to property list. If | 138 """Adds the SCM information, visible in about:version, to property list. If |
139 |add_keys| is True, it will insert the keys, otherwise it will remove them.""" | 139 |add_keys| is True, it will insert the keys, otherwise it will remove them.""" |
140 scm_revision = None | 140 scm_revision = None |
(...skipping 16 matching lines...) Expand all Loading... | |
157 | 157 |
158 return True | 158 return True |
159 | 159 |
160 | 160 |
161 def _AddBreakpadKeys(plist, branding, platform): | 161 def _AddBreakpadKeys(plist, branding, platform): |
162 """Adds the Breakpad keys. This must be called AFTER _AddVersionKeys() and | 162 """Adds the Breakpad keys. This must be called AFTER _AddVersionKeys() and |
163 also requires the |branding| argument.""" | 163 also requires the |branding| argument.""" |
164 plist['BreakpadReportInterval'] = '3600' # Deliberately a string. | 164 plist['BreakpadReportInterval'] = '3600' # Deliberately a string. |
165 plist['BreakpadProduct'] = '%s_%s' % (branding, platform) | 165 plist['BreakpadProduct'] = '%s_%s' % (branding, platform) |
166 plist['BreakpadProductDisplay'] = branding | 166 plist['BreakpadProductDisplay'] = branding |
167 plist['BreakpadVersion'] = plist['CFBundleShortVersionString'] | |
168 # These are both deliberately strings and not boolean. | 167 # These are both deliberately strings and not boolean. |
169 plist['BreakpadSendAndExit'] = 'YES' | 168 plist['BreakpadSendAndExit'] = 'YES' |
170 plist['BreakpadSkipConfirm'] = 'YES' | 169 plist['BreakpadSkipConfirm'] = 'YES' |
171 | 170 |
172 | 171 |
173 def _RemoveBreakpadKeys(plist): | 172 def _RemoveBreakpadKeys(plist): |
174 """Removes any set Breakpad keys.""" | 173 """Removes any set Breakpad keys.""" |
175 _RemoveKeys(plist, | 174 _RemoveKeys(plist, |
176 'BreakpadURL', | 175 'BreakpadURL', |
177 'BreakpadReportInterval', | 176 'BreakpadReportInterval', |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 # BUILD will always be an increasing value, so BUILD_PATH gives us | 301 # BUILD will always be an increasing value, so BUILD_PATH gives us |
303 # something unique that meetings what LS wants. | 302 # something unique that meetings what LS wants. |
304 'CFBundleVersion': '@BUILD@.@PATCH@', | 303 'CFBundleVersion': '@BUILD@.@PATCH@', |
305 } | 304 } |
306 else: | 305 else: |
307 version_format_for_key = { | 306 version_format_for_key = { |
308 'CFBundleShortVersionString': '@MAJOR@.@BUILD@.@PATCH@', | 307 'CFBundleShortVersionString': '@MAJOR@.@BUILD@.@PATCH@', |
309 'CFBundleVersion': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' | 308 'CFBundleVersion': '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' |
310 } | 309 } |
311 | 310 |
311 if options.use_breakpad: | |
312 version_format_for_key['BreakpadVersion'] = \ | |
sdefresne
2016/07/08 07:50:41
Are you sure we also want to do this on mac? I thi
Olivier
2016/07/08 07:58:02
On mac, ShortVersion is '@MAJOR@.@MINOR@.@BUILD@.@
sdefresne
2016/07/08 08:00:46
Ack.
rohitrao (ping after 24h)
2016/07/08 10:41:05
Let's have Mark take a look to be sure.
| |
313 '@MAJOR@.@MINOR@.@BUILD@.@PATCH@' | |
314 | |
312 # Insert the product version. | 315 # Insert the product version. |
313 if not _AddVersionKeys( | 316 if not _AddVersionKeys( |
314 plist, version_format_for_key, version=options.version, | 317 plist, version_format_for_key, version=options.version, |
315 overrides=overrides): | 318 overrides=overrides): |
316 return 2 | 319 return 2 |
317 | 320 |
318 # Add Breakpad if configured to do so. | 321 # Add Breakpad if configured to do so. |
319 if options.use_breakpad: | 322 if options.use_breakpad: |
320 if options.branding is None: | 323 if options.branding is None: |
321 print >>sys.stderr, 'Use of Breakpad requires branding.' | 324 print >>sys.stderr, 'Use of Breakpad requires branding.' |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 with tempfile.NamedTemporaryFile() as temp_info_plist: | 361 with tempfile.NamedTemporaryFile() as temp_info_plist: |
359 plistlib.writePlist(plist, temp_info_plist.name) | 362 plistlib.writePlist(plist, temp_info_plist.name) |
360 | 363 |
361 # Convert Info.plist to the format requested by the --format flag. Any | 364 # Convert Info.plist to the format requested by the --format flag. Any |
362 # format would work on Mac but iOS requires specific format. | 365 # format would work on Mac but iOS requires specific format. |
363 return _ConvertPlist(temp_info_plist.name, output_path, options.format) | 366 return _ConvertPlist(temp_info_plist.name, output_path, options.format) |
364 | 367 |
365 | 368 |
366 if __name__ == '__main__': | 369 if __name__ == '__main__': |
367 sys.exit(Main(sys.argv[1:])) | 370 sys.exit(Main(sys.argv[1:])) |
OLD | NEW |