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

Side by Side Diff: build/config/ios/codesign.py

Issue 2363953004: Ensure the sanitizer runtime library is copied to app bundle if enabled. (Closed)
Patch Set: Address reviewers comments. Created 4 years, 2 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
« no previous file with comments | « no previous file | build/config/ios/rules.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2016 The Chromium Authors. All rights reserved. 1 # Copyright 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import argparse 5 import argparse
6 import fnmatch 6 import fnmatch
7 import glob 7 import glob
8 import os 8 import os
9 import plistlib 9 import plistlib
10 import shutil 10 import shutil
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 else: 225 else:
226 app_identifier_prefix = '*.' 226 app_identifier_prefix = '*.'
227 entitlements.ExpandVariables({ 227 entitlements.ExpandVariables({
228 'CFBundleIdentifier': bundle_identifier, 228 'CFBundleIdentifier': bundle_identifier,
229 'AppIdentifierPrefix': app_identifier_prefix, 229 'AppIdentifierPrefix': app_identifier_prefix,
230 }) 230 })
231 return entitlements 231 return entitlements
232 232
233 233
234 class Action(object): 234 class Action(object):
235
236 """Class implementing one action supported by the script.""" 235 """Class implementing one action supported by the script."""
237 236
238 @classmethod 237 @classmethod
239 def Register(cls, subparsers): 238 def Register(cls, subparsers):
240 parser = subparsers.add_parser(cls.name, help=cls.help) 239 parser = subparsers.add_parser(cls.name, help=cls.help)
241 parser.set_defaults(func=cls._Execute) 240 parser.set_defaults(func=cls._Execute)
242 cls._Register(parser) 241 cls._Register(parser)
243 242
244 243
245 class CodeSignBundleAction(Action): 244 class CodeSignBundleAction(Action):
246
247 """Class implementing the code-sign-bundle action.""" 245 """Class implementing the code-sign-bundle action."""
248 246
249 name = 'code-sign-bundle' 247 name = 'code-sign-bundle'
250 help = 'perform code signature for a bundle' 248 help = 'perform code signature for a bundle'
251 249
252 @staticmethod 250 @staticmethod
253 def _Register(parser): 251 def _Register(parser):
254 parser.add_argument( 252 parser.add_argument(
255 '--entitlements', '-e', dest='entitlements_path', 253 '--entitlements', '-e', dest='entitlements_path',
256 help='path to the entitlements file to use') 254 help='path to the entitlements file to use')
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 codesign_extra_args.extend( 312 codesign_extra_args.extend(
315 ['--entitlements', temporary_entitlements_file.name]) 313 ['--entitlements', temporary_entitlements_file.name])
316 314
317 entitlements = GenerateEntitlements( 315 entitlements = GenerateEntitlements(
318 args.entitlements_path, provisioning_profile, bundle.identifier) 316 args.entitlements_path, provisioning_profile, bundle.identifier)
319 entitlements.WriteTo(temporary_entitlements_file.name) 317 entitlements.WriteTo(temporary_entitlements_file.name)
320 318
321 CodeSignBundle(bundle.path, args.identity, codesign_extra_args) 319 CodeSignBundle(bundle.path, args.identity, codesign_extra_args)
322 320
323 321
322 class CodeSignFileAction(Action):
323 """Class implementing code signature for a single file."""
324
325 name = 'code-sign-file'
326 help = 'code-sign a single file'
327
328 @staticmethod
329 def _Register(parser):
330 parser.add_argument(
331 'path', help='path to the file to codesign')
332 parser.add_argument(
333 '--identity', '-i', required=True,
334 help='identity to use to codesign')
335 parser.add_argument(
336 '--output', '-o',
337 help='if specified copy the file to that location before signing it')
338 parser.set_defaults(sign=True)
339
340 @staticmethod
341 def _Execute(args):
342 if not args.identity:
343 args.identity = '-'
344
345 install_path = args.path
346 if args.output:
347
348 if os.path.isfile(args.output):
349 os.unlink(args.output)
350 elif os.path.isdir(args.output):
351 shutil.rmtree(args.output)
352
353 if os.path.isfile(args.path):
354 shutil.copy(args.path, args.output)
355 elif os.path.isdir(args.path):
356 shutil.copytree(args.path, args.output)
357
358 install_path = args.output
359
360 CodeSignBundle(install_path, args.identity,
361 ['--deep', '--preserve-metadata=identifier,entitlements'])
362
363
324 class GenerateEntitlementsAction(Action): 364 class GenerateEntitlementsAction(Action):
325
326 """Class implementing the generate-entitlements action.""" 365 """Class implementing the generate-entitlements action."""
327 366
328 name = 'generate-entitlements' 367 name = 'generate-entitlements'
329 help = 'generate entitlements file' 368 help = 'generate entitlements file'
330 369
331 @staticmethod 370 @staticmethod
332 def _Register(parser): 371 def _Register(parser):
333 parser.add_argument( 372 parser.add_argument(
334 '--entitlements', '-e', dest='entitlements_path', 373 '--entitlements', '-e', dest='entitlements_path',
335 help='path to the entitlements file to use') 374 help='path to the entitlements file to use')
(...skipping 10 matching lines...) Expand all
346 provisioning_profile = FindProvisioningProfile(bundle_identifier, False) 385 provisioning_profile = FindProvisioningProfile(bundle_identifier, False)
347 entitlements = GenerateEntitlements( 386 entitlements = GenerateEntitlements(
348 args.entitlements_path, provisioning_profile, bundle_identifier) 387 args.entitlements_path, provisioning_profile, bundle_identifier)
349 entitlements.WriteTo(args.path) 388 entitlements.WriteTo(args.path)
350 389
351 390
352 def Main(): 391 def Main():
353 parser = argparse.ArgumentParser('codesign iOS bundles') 392 parser = argparse.ArgumentParser('codesign iOS bundles')
354 subparsers = parser.add_subparsers() 393 subparsers = parser.add_subparsers()
355 394
356 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]: 395 actions = [
396 CodeSignBundleAction,
397 CodeSignFileAction,
398 GenerateEntitlementsAction,
399 ]
400
401 for action in actions:
357 action.Register(subparsers) 402 action.Register(subparsers)
358 403
359 args = parser.parse_args() 404 args = parser.parse_args()
360 args.func(args) 405 args.func(args)
361 406
362 407
363 if __name__ == '__main__': 408 if __name__ == '__main__':
364 sys.exit(Main()) 409 sys.exit(Main())
OLDNEW
« no previous file with comments | « no previous file | build/config/ios/rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698