Commit 566e1d72 authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

[ios] Add codesigning information in generated Xcode project

When using new build system, Xcode requires codesigning information
in the Xcode project to build and run the app (even if they are not
used since the build is done via ninja).

Add support for collecting those information when running "gn gen"
(this requires adding a new exception to exec_script but this cannot
be done at build time since the information is used to generate the
Xcode project when passing --ide=xcode to gen step of gn).

Bug: 1094890
Change-Id: I63dabb836355fb7e2324580d5610872ea4fc33f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2267099Reviewed-by: default avatarJochen Eisinger <jochen@chromium.org>
Reviewed-by: default avatarMike Dougherty <michaeldo@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782964}
parent 1997a426
......@@ -7,6 +7,7 @@ import codecs
import datetime
import fnmatch
import glob
import json
import os
import plistlib
import shutil
......@@ -95,6 +96,14 @@ class ProvisioningProfile(object):
def path(self):
return self._path
@property
def team_identifier(self):
return self._data.get('TeamIdentifier', [''])[0]
@property
def name(self):
return self._data.get('Name', '')
@property
def application_identifier_pattern(self):
return self._data.get('Entitlements', {}).get('application-identifier', '')
......@@ -511,6 +520,31 @@ class GenerateEntitlementsAction(Action):
entitlements.WriteTo(args.path)
class FindProvisioningProfileAction(Action):
"""Class implementing the find-codesign-identity action."""
name = 'find-provisioning-profile'
help = 'find provisioning profile for use by Xcode project generator'
@staticmethod
def _Register(parser):
parser.add_argument('--bundle-id',
'-b',
required=True,
help='bundle identifier')
@staticmethod
def _Execute(args):
provisioning_profile_info = {}
provisioning_profile = FindProvisioningProfile(args.bundle_id, False)
for key in ('team_identifier', 'name'):
if provisioning_profile:
provisioning_profile_info[key] = getattr(provisioning_profile, key)
else:
provisioning_profile_info[key] = ''
print(json.dumps(provisioning_profile_info))
def Main():
# Cache this codec so that plistlib can find it. See
# https://crbug.com/999461#c12 for more details.
......@@ -523,6 +557,7 @@ def Main():
CodeSignBundleAction,
CodeSignFileAction,
GenerateEntitlementsAction,
FindProvisioningProfileAction,
]
for action in actions:
......
......@@ -285,6 +285,16 @@ template("create_signed_bundle") {
_xcode_product_bundle_id = invoker.xcode_product_bundle_id
}
if (_xcode_product_bundle_id != "") {
_ios_provisioning_profile_info =
exec_script("//build/config/ios/codesign.py",
[
"find-provisioning-profile",
"-b=" + _xcode_product_bundle_id,
],
"json")
}
create_bundle(_target_name) {
forward_variables_from(invoker,
[
......@@ -313,6 +323,12 @@ template("create_signed_bundle") {
IPHONEOS_DEPLOYMENT_TARGET = ios_deployment_target
if (_xcode_product_bundle_id != "") {
PRODUCT_BUNDLE_IDENTIFIER = _xcode_product_bundle_id
if (defined(_ios_provisioning_profile_info)) {
CODE_SIGN_IDENTITY = "iPhone Developer"
DEVELOPMENT_TEAM = _ios_provisioning_profile_info.team_identifier
PROVISIONING_PROFILE_SPECIFIER = _ios_provisioning_profile_info.name
}
}
# If invoker has defined extra attributes, they override the defaults.
......
......@@ -16,6 +16,7 @@ build_dotfile_settings = {
"//build/config/gcc/gcc_version.gni",
"//build/config/host_byteorder.gni",
"//build/config/ios/ios_sdk.gni",
"//build/config/ios/rules.gni",
"//build/config/linux/BUILD.gn",
"//build/config/linux/pkg_config.gni",
"//build/config/linux/atk/BUILD.gn",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment