Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: build/mac/tweak_info_plist.py

Issue 10828228: Make the Mac Info.plist SCM keys generic (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change branch back to path Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/file_version_info_mac.mm ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 # enough to find out with "lsregister -dump). 94 # enough to find out with "lsregister -dump).
95 # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html 95 # http://lists.apple.com/archives/carbon-dev/2006/Jun/msg00139.html
96 # BUILD will always be an increasing value, so BUILD_PATH gives us something 96 # BUILD will always be an increasing value, so BUILD_PATH gives us something
97 # unique that meetings what LS wants. 97 # unique that meetings what LS wants.
98 plist['CFBundleVersion'] = bundle_version 98 plist['CFBundleVersion'] = bundle_version
99 99
100 # Return with no error. 100 # Return with no error.
101 return True 101 return True
102 102
103 103
104 def _DoSVNKeys(plist, add_keys): 104 def _DoSCMKeys(plist, add_keys):
105 """Adds the SVN information, visible in about:version, to property list. If 105 """Adds the SCM information, visible in about:version, to property list. If
106 |add_keys| is True, it will insert the keys, otherwise it will remove them.""" 106 |add_keys| is True, it will insert the keys, otherwise it will remove them."""
107 scm_path, scm_revision = None, None 107 scm_path, scm_revision = None, None
108 if add_keys: 108 if add_keys:
109 version_info = lastchange.FetchVersionInfo( 109 version_info = lastchange.FetchVersionInfo(
110 default_lastchange=None, directory=TOP) 110 default_lastchange=None, directory=TOP)
111 scm_path, scm_revision = version_info.url, version_info.revision 111 scm_path, scm_revision = version_info.url, version_info.revision
112 112
113 # See if the operation failed. 113 # See if the operation failed.
114 _RemoveKeys(plist, 'SVNRevision') 114 _RemoveKeys(plist, 'SCMRevision')
115 if scm_revision != None: 115 if scm_revision != None:
116 plist['SVNRevision'] = scm_revision 116 plist['SCMRevision'] = scm_revision
117 elif add_keys: 117 elif add_keys:
118 print >>sys.stderr, 'Could not determine svn revision. This may be OK.' 118 print >>sys.stderr, 'Could not determine SCM revision. This may be OK.'
119 119
120 if scm_path != None: 120 if scm_path != None:
121 plist['SVNPath'] = scm_path 121 plist['SCMPath'] = scm_path
122 else: 122 else:
123 _RemoveKeys(plist, 'SVNPath') 123 _RemoveKeys(plist, 'SCMPath')
124 124
125 125
126 def _DoPDFKeys(plist, add_keys): 126 def _DoPDFKeys(plist, add_keys):
127 """Adds PDF support to the document types list. If add_keys is True, it will 127 """Adds PDF support to the document types list. If add_keys is True, it will
128 add the type information dictionary. If it is False, it will remove it if 128 add the type information dictionary. If it is False, it will remove it if
129 present.""" 129 present."""
130 130
131 PDF_FILE_EXTENSION = 'pdf' 131 PDF_FILE_EXTENSION = 'pdf'
132 132
133 def __AddPDFKeys(sub_plist): 133 def __AddPDFKeys(sub_plist):
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 213
214 def Main(argv): 214 def Main(argv):
215 parser = optparse.OptionParser('%prog [options]') 215 parser = optparse.OptionParser('%prog [options]')
216 parser.add_option('--breakpad', dest='use_breakpad', action='store', 216 parser.add_option('--breakpad', dest='use_breakpad', action='store',
217 type='int', default=False, help='Enable Breakpad [1 or 0]') 217 type='int', default=False, help='Enable Breakpad [1 or 0]')
218 parser.add_option('--breakpad_uploads', dest='breakpad_uploads', 218 parser.add_option('--breakpad_uploads', dest='breakpad_uploads',
219 action='store', type='int', default=False, 219 action='store', type='int', default=False,
220 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]') 220 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]')
221 parser.add_option('--keystone', dest='use_keystone', action='store', 221 parser.add_option('--keystone', dest='use_keystone', action='store',
222 type='int', default=False, help='Enable Keystone [1 or 0]') 222 type='int', default=False, help='Enable Keystone [1 or 0]')
223 parser.add_option('--svn', dest='add_svn_info', action='store', type='int', 223 parser.add_option('--scm', dest='add_scm_info', action='store', type='int',
224 default=True, help='Add SVN metadata [1 or 0]') 224 default=True, help='Add SCM metadata [1 or 0]')
225 parser.add_option('--pdf', dest='add_pdf_support', action='store', type='int', 225 parser.add_option('--pdf', dest='add_pdf_support', action='store', type='int',
226 default=False, help='Add PDF file handler support [1 or 0]') 226 default=False, help='Add PDF file handler support [1 or 0]')
227 parser.add_option('--branding', dest='branding', action='store', 227 parser.add_option('--branding', dest='branding', action='store',
228 type='string', default=None, help='The branding of the binary') 228 type='string', default=None, help='The branding of the binary')
229 parser.add_option('--bundle_id', dest='bundle_identifier', 229 parser.add_option('--bundle_id', dest='bundle_identifier',
230 action='store', type='string', default=None, 230 action='store', type='string', default=None,
231 help='The bundle id of the binary') 231 help='The bundle id of the binary')
232 (options, args) = parser.parse_args(argv) 232 (options, args) = parser.parse_args(argv)
233 233
234 if len(args) > 0: 234 if len(args) > 0:
(...skipping 29 matching lines...) Expand all
264 264
265 # Only add Keystone in Release builds. 265 # Only add Keystone in Release builds.
266 if options.use_keystone and env['CONFIGURATION'] == 'Release': 266 if options.use_keystone and env['CONFIGURATION'] == 'Release':
267 if options.bundle_identifier is None: 267 if options.bundle_identifier is None:
268 print >>sys.stderr, 'Use of Keystone requires the bundle id.' 268 print >>sys.stderr, 'Use of Keystone requires the bundle id.'
269 return 1 269 return 1
270 _AddKeystoneKeys(plist, options.bundle_identifier) 270 _AddKeystoneKeys(plist, options.bundle_identifier)
271 else: 271 else:
272 _RemoveKeystoneKeys(plist) 272 _RemoveKeystoneKeys(plist)
273 273
274 # Adds or removes any SVN keys. 274 # Adds or removes any SCM keys.
275 _DoSVNKeys(plist, options.add_svn_info) 275 _DoSCMKeys(plist, options.add_scm_info)
276 276
277 # Adds or removes the PDF file handler entry. 277 # Adds or removes the PDF file handler entry.
278 _DoPDFKeys(plist, options.add_pdf_support) 278 _DoPDFKeys(plist, options.add_pdf_support)
279 279
280 # Now that all keys have been mutated, rewrite the file. 280 # Now that all keys have been mutated, rewrite the file.
281 temp_info_plist = tempfile.NamedTemporaryFile() 281 temp_info_plist = tempfile.NamedTemporaryFile()
282 plistlib.writePlist(plist, temp_info_plist.name) 282 plistlib.writePlist(plist, temp_info_plist.name)
283 283
284 # Info.plist will work perfectly well in any plist format, but traditionally 284 # Info.plist will work perfectly well in any plist format, but traditionally
285 # applications use xml1 for this, so convert it to ensure that it's valid. 285 # applications use xml1 for this, so convert it to ensure that it's valid.
286 proc = subprocess.Popen(['plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST, 286 proc = subprocess.Popen(['plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST,
287 temp_info_plist.name]) 287 temp_info_plist.name])
288 proc.wait() 288 proc.wait()
289 return proc.returncode 289 return proc.returncode
290 290
291 291
292 if __name__ == '__main__': 292 if __name__ == '__main__':
293 sys.exit(Main(sys.argv[1:])) 293 sys.exit(Main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « base/file_version_info_mac.mm ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698