200 parser = optparse.OptionParser('%prog [options]')
201 parser.add_option(
202 '--breakpad',
203 dest='use_breakpad',
204 action='store',
205 type='int',
206 default=False,
207 help='Enable Breakpad [1 or 0]')
208 parser.add_option(
209 '--breakpad_uploads',
210 dest='breakpad_uploads',
211 action='store',
212 type='int',
213 default=False,
214 help='Enable Breakpad\'s uploading of crash dumps [1 or 0]')
215 parser.add_option(
216 '--keystone',
217 dest='use_keystone',
218 action='store',
219 type='int',
220 default=False,
221 help='Enable Keystone [1 or 0]')
222 parser.add_option(
223 '--scm',
224 dest='add_scm_info',
225 action='store',
226 type='int',
227 default=True,
228 help='Add SCM metadata [1 or 0]')
229 parser.add_option(
230 '--branding',
231 dest='branding',
232 action='store',
233 type='string',
234 default=None,
235 help='The branding of the binary')
236 parser.add_option(
237 '--bundle_id',
238 dest='bundle_identifier',
239 action='store',
240 type='string',
241 default=None,
242 help='The bundle id of the binary')
243 parser.add_option(
244 '--version',
245 dest='version',
246 action='store',
247 type='string',
248 default=None,
249 help='The version string [major.minor.build.patch]')
250 (options, args) = parser.parse_args(argv)
251
253 print(parser.get_usage(), file=sys.stderr)
254 return 1
255
256
257 DEST_INFO_PLIST = os.path.join(env['TARGET_BUILD_DIR'],
258 env['INFOPLIST_PATH'])
259 plist = plistlib.readPlist(DEST_INFO_PLIST)
260
261
262 if not _AddVersionKeys(plist, version=options.version):
263 return 2
264
265
266 if options.use_breakpad:
267 if options.branding is None:
268 print(
'Use of Breakpad requires branding.', file=sys.stderr)
269 return 1
270 _AddBreakpadKeys(plist, options.branding)
271 if options.breakpad_uploads:
272 plist['BreakpadURL'] = 'https://clients2.google.com/cr/report'
273 else:
274
275
276
277
278
279
280 plist['BreakpadURL'] = 'none'
281 else:
282 _RemoveBreakpadKeys(plist)
283
284
285 if options.use_keystone and env['CONFIGURATION'] == 'Release':
286 if options.bundle_identifier is None:
287 print(
'Use of Keystone requires the bundle id.', file=sys.stderr)
288 return 1
289 _AddKeystoneKeys(plist, options.bundle_identifier)
290 else:
291 _RemoveKeystoneKeys(plist)
292
293
294 if not _DoSCMKeys(plist, options.add_scm_info):
295 return 3
296
297
298 temp_info_plist = tempfile.NamedTemporaryFile()
299 plistlib.writePlist(plist, temp_info_plist.name)
300
301
302
303 proc = subprocess.Popen([
304 'plutil', '-convert', 'xml1', '-o', DEST_INFO_PLIST,
305 temp_info_plist.name
306 ])
307 proc.wait()
308 return proc.returncode
309
310
def print(*args, **kwargs)