Chromium Code Reviews| Index: build/config/ios/rules.gni |
| diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni |
| index c18c06554e94f6d62c573c2c1048e809c84ad0f1..5b6a348f6ba64e78a54f66d344208b32337ba68c 100644 |
| --- a/build/config/ios/rules.gni |
| +++ b/build/config/ios/rules.gni |
| @@ -2,71 +2,33 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -ios_app_script = "//build/config/ios/ios_app.py" |
| - |
| -template("code_sign_ios") { |
| - assert(defined(invoker.entitlements_path), |
| - "The path to the entitlements .xcent file") |
| - assert(defined(invoker.identity), "The code signing identity") |
| - assert(defined(invoker.application_path), "The application to code sign") |
| - assert(defined(invoker.deps)) |
| - |
| - action(target_name) { |
| - sources = [ |
| - invoker.entitlements_path, |
| - ] |
| - |
| - _application_path = invoker.application_path |
| - |
| - script = ios_app_script |
| - |
| - outputs = [ |
| - "$_application_path/_CodeSignature/CodeResources", |
| - ] |
| - |
| - args = [ |
| - "codesign", |
| - "-p", |
| - rebase_path(invoker.application_path, root_build_dir), |
| - "-i", |
| - invoker.identity, |
| - "-e", |
| - rebase_path(invoker.entitlements_path, root_build_dir), |
| - ] |
| - |
| - forward_variables_from(invoker, |
| - [ |
| - "deps", |
| - "public_deps", |
| - "testonly", |
| - ]) |
| - } |
| -} |
| - |
| -# TODO(GYP), TODO(dpranke): Should this be part of ios_app? |
| -template("resource_copy_ios") { |
| - assert(defined(invoker.resources), |
| - "The source list of resources to copy over") |
| - assert(defined(invoker.bundle_directory), |
| - "The directory within the bundle to place the sources in") |
| - assert(defined(invoker.app_name), "The name of the application") |
| - |
| - _bundle_directory = invoker.bundle_directory |
| - _app_name = invoker.app_name |
| - _resources = invoker.resources |
| - |
| - copy(target_name) { |
| - set_sources_assignment_filter([]) |
| - sources = _resources |
| - outputs = [ |
| - "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}", |
| - ] |
| - } |
| -} |
| +import("//build/config/ios/ios_sdk.gni") |
| +# Use this template to create application bundle for iOS. |
|
Dirk Pranke
2016/01/29 00:54:25
nit: "create an application bundle"
sdefresne
2016/02/05 10:20:00
Ack.
|
| +# |
| +# Arguments: |
| +# |
| +# info_plist |
| +# Path to the application Info.plist template (variable substitution |
| +# will be performed). |
| +# |
| +# entitlements_path |
| +# Path to the application entitlements .xcent. |
| +# |
| +# code_signing_identity |
| +# Identity to use for signing the application, if signing is enabled. |
| +# |
| +# app_name (optional) |
| +# Name of the application, defaults to ${target_name}. |
| +# |
| +# extra_substitutions (optional) |
| +# List of string in "key=value" format. Each correspond to variable |
| +# substitution to perform when compiling the Info.plist template. |
| +# |
| +# The template uses an "executable" target under the hood and forwards to it |
| +# all the arguments it supports. Look at "executable" documentation for more |
| +# information. |
| template("ios_app") { |
| - assert(defined(invoker.deps), |
| - "Dependencies must be specified for $target_name") |
| assert(defined(invoker.info_plist), |
| "The application plist file must be specified for $target_name") |
| assert(defined(invoker.entitlements_path), |
| @@ -81,111 +43,229 @@ template("ios_app") { |
| _app_name = target_name |
| } |
| - forward_variables_from(invoker, [ "testonly" ]) |
| - |
| - plist_gen_target_name = target_name + "_plist" |
| - bin_gen_target_name = target_name + "_bin" |
| - group_target_name = target_name |
| + # Copy target_name so that it can be used in sub-targets. |
| + _target_name = target_name |
| # Generate the executable |
| - executable(bin_gen_target_name) { |
| - visibility = [ ":$group_target_name" ] |
| + executable(_target_name + ".binary") { |
| + forward_variables_from(invoker, |
| + "*", |
| + [ |
| + "app_name", |
| + "code_signing_identity", |
| + "entitlements_path", |
| + "extra_deps", |
| + "extra_substitutions", |
| + "info_plist", |
| + "output_name", |
| + "visibility", |
| + ]) |
| + |
| + visibility = [ ":$_target_name.plist" ] |
| + output_name = "$_app_name.app/$_app_name" |
| - output_name = "${_app_name}.app/${_app_name}" |
| + if (!defined(invoker.libs)) { |
| + libs = [] |
| + } |
| + libs += [ "UIKit.framework" ] |
| + } |
| + # Copy resources. |
| + copy_bundle_data(_target_name + ".bundle") { |
| forward_variables_from(invoker, |
| [ |
| - "all_dependent_configs", |
| - "allow_circular_includes_from", |
| - "cflags", |
| - "cflags_c", |
| - "cflags_cc", |
| - "cflags_objc", |
| - "cflags_objcc", |
| - "configs", |
| - "check_includes", |
| - "data", |
| - "data_deps", |
| - "defines", |
| - "include_dirs", |
| - "ldflags", |
| - "public", |
| - "public_configs", |
| + "bundle_data", |
| + "deps", |
| "public_deps", |
| - "sources", |
| + "testonly", |
| ]) |
| - if (defined(invoker.libs)) { |
| - libs = invoker.libs |
| - } else { |
| - libs = [] |
| - } |
| - libs += [ |
| - "UIKit.framework", |
| - "QuartzCore.framework", |
| - "OpenGLES.framework", |
| - ] |
| + # .xcassets needs to be compiled into a .car files so omit them from the |
| + # list of files to copy into the application bundle. |
| + bundle_data_filter = [ "*.xcassets" ] |
| - if (defined(invoker.deps)) { |
| - deps = invoker.deps |
| - } else { |
| - deps = [] |
| - } |
| - deps += [ ":$plist_gen_target_name" ] |
| + visibility = [ ":$_target_name.plist" ] |
| + outputs = [ |
| + "$root_build_dir/$_app_name.app/{{source_file_part}}", |
| + ] |
| } |
| # Process the Info.plist |
| - action(plist_gen_target_name) { |
| - visibility = [ |
| - ":$group_target_name", |
| - ":$bin_gen_target_name", |
| - ] |
| + action(_target_name + ".plist") { |
| + forward_variables_from(invoker, [ "testonly" ]) |
| + |
| + if (invoker.code_signing_identity == "") { |
| + visibility = [ ":$_app_name.app" ] |
| + } else { |
| + visibility = [ ":$_target_name.codesign" ] |
| + } |
| - script = ios_app_script |
| + generated_info_plist = "$root_build_dir/$_app_name.app/Info.plist" |
| + script = "//build/config/ios/ios_gen_plist.py" |
| + outputs = [ |
| + generated_info_plist, |
| + ] |
| sources = [ |
| + "//build/config/ios/BuildInfo.plist", |
| invoker.info_plist, |
| ] |
| - outputs = [ |
| - "$root_build_dir/${_app_name}.app/Info.plist", |
| - ] |
| - args = [ |
| - "plist", |
| - "-i", |
| - rebase_path(invoker.info_plist, root_build_dir), |
| - "-o", |
| - rebase_path("$root_build_dir/${_app_name}.app"), |
| + extra_args = [] |
| + if (defined(invoker.extra_substitutions)) { |
| + foreach(substitution, invoker.extra_substitutions) { |
| + extra_args += [ "-s=$substitution" ] |
| + } |
| + } |
| + |
| + args = extra_args + [ |
| + "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", |
| + "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform", |
| + "-s=IOS_SDK_NAME=$ios_sdk_name", |
| + "-s=IOS_SDK_BUILD=$ios_sdk_version", |
| + "-s=XCODE_VERSION=$xcode_version", |
| + "-s=XCODE_BUILD=$xcode_build", |
| + "-s=PRODUCT_NAME=$_app_name", |
| + "-s=EXECUTABLE_NAME=$_app_name", |
| + "-o=" + rebase_path(generated_info_plist), |
| + ] + rebase_path(sources) |
| + |
| + deps = [ |
| + ":$_target_name.binary", |
| + ":$_target_name.bundle", |
| ] |
| + |
| + if (defined(invoker.extra_deps)) { |
| + deps += invoker.extra_deps |
| + } |
| } |
| - # Perform Code Signing |
| - entitlements_path = invoker.entitlements_path |
| + # Perform code signature if needed. Since this require the application |
| + # bundle to be complete, this targets depends on the action generating |
| + # the Info.plist file, since this introduces a hard dependency (and as |
| + # it depends on the other targets, this ensure the bundle is complete). |
| if (invoker.code_signing_identity != "") { |
| - code_sign_gen_target_name = target_name + "_codesign" |
| - code_sign_ios(code_sign_gen_target_name) { |
| - visibility = [ ":$target_name" ] |
| + action(_target_name + ".codesign") { |
| + forward_variables_from(invoker, [ "testonly" ]) |
| + |
| + visibility = [ ":$_app_name.app" ] |
| + script = "//build/config/ios/ios_code_sign.py" |
| + |
| + sources = [ |
| + entitlements_path, |
| + ] |
| + outputs = [ |
| + "$root_build_dir/$app_name.app/_CodeSignature/CodeResources", |
| + ] |
| + |
| + args = [ |
| + "-i=" + invoker.code_signing_identity, |
| + "-p=" + rebase_path("$root_build_dir/$app_name.app", root_build_dir), |
| + "-e=" + rebase_path(invoker.entitlements_path, root_build_dir), |
| + ] |
| - identity = invoker.code_signing_identity |
| - application_path = "$root_build_dir/$app_name.app" |
| deps = [ |
| - ":$bin_gen_target_name", |
| - ":$plist_gen_target_name", |
| + ":$_target_name.plist", |
| ] |
| } |
| } else { |
| # This avoids a potential unused variable warning in the caller. |
| + entitlements_path = invoker.entitlements_path |
| entitlements_path = entitlements_path |
| } |
| - # Top level group |
| - group(target_name) { |
| + # Intermediate targets that allows to build the application by its name. |
| + group(_app_name + ".app") { |
| + forward_variables_from(invoker, [ "testonly" ]) |
| + |
| + visibility = [ ":$_target_name" ] |
| + if (invoker.code_signing_identity != "") { |
| + deps = [ |
| + ":$_target_name.codesign", |
| + ] |
| + } else { |
| + deps = [ |
| + ":$_target_name.plist", |
| + ] |
| + } |
| + } |
| + |
| + group(_target_name) { |
| + forward_variables_from(invoker, |
| + [ |
| + "public_deps", |
| + "testonly", |
| + "visibility", |
| + ]) |
| deps = [ |
| - ":$bin_gen_target_name", |
| - ":$plist_gen_target_name", |
| + ":$_app_name.app", |
| ] |
| - if (invoker.code_signing_identity != "") { |
| - deps += [ ":$code_sign_gen_target_name" ] |
| + } |
| +} |
| + |
| +# Use this template to create test application bundle for iOS. |
|
Dirk Pranke
2016/01/29 00:54:25
nit "create a test" ?
sdefresne
2016/02/05 10:20:00
Ack.
|
| +# |
| +# Arguments: |
| +# |
| +# bundle_test_name (optional) |
| +# String to use as bundle identifier in the Info.plist. Default to |
| +# ${app_name}. |
| +# |
| +# test_data_files (optional) |
| +# List of file to copy in the application bundle. The path in the |
| +# bundle will be the same as the path from the source root, unless |
| +# test_data_prefix is defined. |
| +# |
| +# test_data_prefix (optional) |
| +# If defined, ${test_data_files} will be copied to this directory |
| +# relative to the application bundle instead of a path relative to |
| +# source root. |
| +# |
| +# info_plist (optional) |
| +# Path to the application Info.plist template (variable substitution |
| +# will be performed). |
| +# |
| +# entitlements_path (optional) |
| +# Path to the application entitlements .xcent. |
| +# |
| +# code_signing_identity (optional) |
| +# Identity to use for signing the application, if signing is enabled. |
| +# |
| +# app_name (optional) |
| +# Name of the application, defaults to ${target_name}. |
| +# |
| +# extra_substitutions (optional) |
| +# List of string in "key=value" format. Each correspond to variable |
| +# substitution to perform when compiling the Info.plist template. |
| +# |
| +# The template uses an "ios_app" target under the hood and forwards to it |
| +# all the arguments it supports. Look at "executable" documentation for more |
| +# information. |
| +template("ios_test_app") { |
| + # Copy target_name so that it can be used in sub-targets. |
| + _target_name = target_name |
| + |
| + if (defined(invoker.test_data_files)) { |
| + if (defined(invoker.app_name)) { |
| + _app_name = invoker.app_name |
| + } else { |
| + _app_name = _target_name |
| + } |
| + |
| + copy(_target_name + ".testdata") { |
|
Dirk Pranke
2016/02/10 01:18:13
we don't usually use periods in target names; copy
|
| + sources = invoker.test_data_files |
| + outputs = [ |
| + "$root_build_dir/$_app_name.app/{{source_root_relative_dir}}/" + |
| + "{{source_file_part}}", |
| + ] |
| + } |
| + } |
| + |
| + ios_app(_target_name) { |
| + forward_variables_from(invoker, "*") |
| + |
| + if (defined(invoker.test_data_files)) { |
| + extra_deps = [ ":$_target_name.testdata" ] |
| } |
| } |
| } |