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

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

Issue 2231723002: Fix code signing for iOS bundle when targetting simulator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 help='identity to use to codesign') 261 help='identity to use to codesign')
262 parser.add_argument( 262 parser.add_argument(
263 '--binary', '-b', required=True, 263 '--binary', '-b', required=True,
264 help='path to the iOS bundle binary') 264 help='path to the iOS bundle binary')
265 parser.add_argument( 265 parser.add_argument(
266 '--framework', '-F', action='append', default=[], dest='frameworks', 266 '--framework', '-F', action='append', default=[], dest='frameworks',
267 help='install and resign system framework') 267 help='install and resign system framework')
268 parser.add_argument( 268 parser.add_argument(
269 '--disable-code-signature', action='store_false', dest='sign', 269 '--disable-code-signature', action='store_false', dest='sign',
270 help='disable code signature') 270 help='disable code signature')
271 parser.add_argument(
272 '--platform', '-t', required=True,
273 help='platform the signed bundle is targetting')
271 parser.set_defaults(sign=True) 274 parser.set_defaults(sign=True)
272 275
273 @staticmethod 276 @staticmethod
274 def _Execute(args): 277 def _Execute(args):
275 if not args.identity: 278 if not args.identity:
276 args.identity = '-' 279 args.identity = '-'
277 280
278 bundle = Bundle(args.path) 281 bundle = Bundle(args.path)
279 282
280 # Find mobile provisioning profile and embeds it into the bundle (if a code 283 # Find mobile provisioning profile and embeds it into the bundle (if a code
281 # signing identify has been provided, fails if no valid mobile provisioning 284 # signing identify has been provided, fails if no valid mobile provisioning
282 # is found). 285 # is found).
283 provisioning_profile_required = args.identity != '-' 286 provisioning_profile_required = args.identity != '-'
284 provisioning_profile = FindProvisioningProfile( 287 provisioning_profile = FindProvisioningProfile(
285 bundle.identifier, provisioning_profile_required) 288 bundle.identifier, provisioning_profile_required)
286 if provisioning_profile: 289 if provisioning_profile and args.platform != 'iphonesimulator':
287 provisioning_profile.Install(bundle) 290 provisioning_profile.Install(bundle)
288 291
289 # Delete existing code signature. 292 # Delete existing code signature.
290 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources') 293 signature_file = os.path.join(args.path, '_CodeSignature', 'CodeResources')
291 if os.path.isfile(signature_file): 294 if os.path.isfile(signature_file):
292 os.unlink(signature_file) 295 os.unlink(signature_file)
293 296
294 # Install system frameworks if requested. 297 # Install system frameworks if requested.
295 for framework_path in args.frameworks: 298 for framework_path in args.frameworks:
296 InstallSystemFramework(framework_path, args.path, args) 299 InstallSystemFramework(framework_path, args.path, args)
297 300
298 # Copy main binary into bundle. 301 # Copy main binary into bundle.
299 if os.path.isfile(bundle.binary_path): 302 if os.path.isfile(bundle.binary_path):
300 os.unlink(bundle.binary_path) 303 os.unlink(bundle.binary_path)
301 shutil.copy(args.binary, bundle.binary_path) 304 shutil.copy(args.binary, bundle.binary_path)
302 305
303 if not args.sign: 306 if not args.sign:
304 return 307 return
305 308
306 # Embeds entitlements into the code signature (if code signing identify has 309 # Embeds entitlements into the code signature (if code signing identify has
307 # been provided). 310 # been provided).
308 codesign_extra_args = [] 311 codesign_extra_args = []
309 if provisioning_profile: 312 if provisioning_profile and args.platform != 'iphonesimulator':
310 temporary_entitlements_file = tempfile.NamedTemporaryFile(suffix='.xcent') 313 temporary_entitlements_file = tempfile.NamedTemporaryFile(suffix='.xcent')
311 codesign_extra_args.extend( 314 codesign_extra_args.extend(
312 ['--entitlements', temporary_entitlements_file.name]) 315 ['--entitlements', temporary_entitlements_file.name])
313 316
314 entitlements = GenerateEntitlements( 317 entitlements = GenerateEntitlements(
315 args.entitlements_path, provisioning_profile, bundle.identifier) 318 args.entitlements_path, provisioning_profile, bundle.identifier)
316 entitlements.WriteTo(temporary_entitlements_file.name) 319 entitlements.WriteTo(temporary_entitlements_file.name)
317 320
318 CodeSignBundle(bundle.path, args.identity, codesign_extra_args) 321 CodeSignBundle(bundle.path, args.identity, codesign_extra_args)
319 322
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 355
353 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]: 356 for action in [ CodeSignBundleAction, GenerateEntitlementsAction ]:
354 action.Register(subparsers) 357 action.Register(subparsers)
355 358
356 args = parser.parse_args() 359 args = parser.parse_args()
357 args.func(args) 360 args.func(args)
358 361
359 362
360 if __name__ == '__main__': 363 if __name__ == '__main__':
361 sys.exit(Main()) 364 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