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

Unified Diff: build/config/ios/rules.gni

Issue 1611363003: Add support for iOS application bundle to GN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-bundles
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: build/config/ios/rules.gni
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni
index c18c06554e94f6d62c573c2c1048e809c84ad0f1..ea517cf51b4d9def76644ebd0303523b27571be2 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.
+#
+# 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),
@@ -83,109 +45,210 @@ template("ios_app") {
forward_variables_from(invoker, [ "testonly" ])
- plist_gen_target_name = target_name + "_plist"
- bin_gen_target_name = target_name + "_bin"
- group_target_name = target_name
+ plist_gen_target_name = target_name + "__plist"
+ bin_gen_target_name = target_name + "__bin"
+ res_gen_target_name = target_name + "__res"
+ _target_name = target_name
# Generate the executable
executable(bin_gen_target_name) {
- visibility = [ ":$group_target_name" ]
-
- output_name = "${_app_name}.app/${_app_name}"
-
forward_variables_from(invoker,
[
"all_dependent_configs",
"allow_circular_includes_from",
+ "asmflags",
"cflags",
"cflags_c",
"cflags_cc",
- "cflags_objc",
"cflags_objcc",
- "configs",
"check_includes",
+ "configs",
"data",
"data_deps",
"defines",
+ "deps",
"include_dirs",
+ "inputs",
"ldflags",
+ "lib_dirs",
+ "libs",
+ "output_extension",
+ "output_name",
+ "precompiled_header",
+ "precompiled_source",
"public",
"public_configs",
"public_deps",
"sources",
])
- if (defined(invoker.libs)) {
- libs = invoker.libs
- } else {
+ visibility = [ ":$plist_gen_target_name" ]
+ output_name = "${_app_name}.app/${_app_name}"
+
+ if (!defined(invoker.libs)) {
libs = []
}
- libs += [
- "UIKit.framework",
- "QuartzCore.framework",
- "OpenGLES.framework",
- ]
+ libs += [ "UIKit.framework" ]
+ }
- if (defined(invoker.deps)) {
- deps = invoker.deps
- } else {
- deps = []
- }
- deps += [ ":$plist_gen_target_name" ]
+ # Copy resources.
+ copy_bundle_data(res_gen_target_name) {
+ forward_variables_from(invoker,
+ [
+ "bundle_data",
+ "deps",
+ "public_deps",
+ ])
+ visibility = [ ":$plist_gen_target_name" ]
+ 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",
- ]
+ visibility = [ ":$_target_name" ]
- 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 = [
+ ":$bin_gen_target_name",
+ ":$res_gen_target_name",
]
+
+ 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) {
+ forward_variables_from(invoker, [ "visibility" ])
+ 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",
]
}
} else {
# This avoids a potential unused variable warning in the caller.
+ entitlements_path = invoker.entitlements_path
entitlements_path = entitlements_path
+
+ group(target_name) {
+ forward_variables_from(invoker, [ "visibility" ])
+ deps = [
+ ":$plist_gen_target_name",
+ ]
+ }
}
+}
- # Top level group
- group(target_name) {
- deps = [
- ":$bin_gen_target_name",
- ":$plist_gen_target_name",
- ]
- if (invoker.code_signing_identity != "") {
- deps += [ ":$code_sign_gen_target_name" ]
+# Use this template to create test application bundle for iOS.
+#
+# 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") {
+ _app_name = target_name
+ if (defined(invoker.app_name)) {
+ _app_name = invoker.app_name
+ }
+
+ if (defined(invoker.test_data_files)) {
+ _copy_test_data_target_name = target_name + "__test_data"
+ copy(_copy_test_data_target_name) {
+ 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, "*")
+
+ app_name = _app_name
+ if (defined(invoker.test_data_files)) {
+ extra_deps = [ ":$_copy_test_data_target_name" ]
}
}
}

Powered by Google App Engine
This is Rietveld 408576698