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

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

Issue 1606553002: Add support for Mac/iOS application bundles to GN tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: base_unittests builds and pass all tests with GN 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..09253f3ec621bde26d7226d39e2feb3d0c723684 100644
--- a/build/config/ios/rules.gni
+++ b/build/config/ios/rules.gni
@@ -2,8 +2,12 @@
# 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"
+import("//build/config/ios/ios_sdk.gni")
+# Template to code sign an iOS application.
+#
+# TODO(sdefresne): document or inline into "ios_app" template if the template
+# is not used anywhere else.
template("code_sign_ios") {
assert(defined(invoker.entitlements_path),
"The path to the entitlements .xcent file")
@@ -18,7 +22,7 @@ template("code_sign_ios") {
_application_path = invoker.application_path
- script = ios_app_script
+ script = "//build/config/ios/ios_code_sign.py"
outputs = [
"$_application_path/_CodeSignature/CodeResources",
@@ -43,30 +47,31 @@ template("code_sign_ios") {
}
}
-# 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}}",
- ]
- }
-}
-
+# 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_pattern_substitution (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,14 +88,14 @@ template("ios_app") {
forward_variables_from(invoker, [ "testonly" ])
- plist_gen_target_name = target_name + "_plist"
- bin_gen_target_name = target_name + "_bin"
+ plist_gen_target_name = target_name + "__plist"
+ bin_gen_target_name = target_name + "__bin"
+ res_gen_target_name = target_name + "__res"
group_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,
@@ -102,33 +107,27 @@ template("ios_app") {
"cflags_cc",
"cflags_objc",
"cflags_objcc",
- "configs",
"check_includes",
+ "configs",
"data",
"data_deps",
"defines",
+ "deps",
"include_dirs",
"ldflags",
+ "libs",
"public",
"public_configs",
"public_deps",
"sources",
])
- if (defined(invoker.libs)) {
- libs = invoker.libs
- } else {
+ if (!defined(invoker.libs)) {
libs = []
}
- libs += [
- "UIKit.framework",
- "QuartzCore.framework",
- "OpenGLES.framework",
- ]
+ libs += [ "UIKit.framework" ]
- if (defined(invoker.deps)) {
- deps = invoker.deps
- } else {
+ if (!defined(invoker.deps)) {
deps = []
}
deps += [ ":$plist_gen_target_name" ]
@@ -141,21 +140,42 @@ template("ios_app") {
":$bin_gen_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_pattern_substitution)) {
+ foreach(substitution, invoker.extra_pattern_substitution) {
+ 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)
+ }
+
+ # Copy resources.
+ copy_bundle_data(res_gen_target_name) {
+ deps = invoker.deps
+ outputs = [
+ "$root_build_dir/$_app_name.app/{{source_file_part}}",
]
}
@@ -171,6 +191,7 @@ template("ios_app") {
deps = [
":$bin_gen_target_name",
":$plist_gen_target_name",
+ ":$res_gen_target_name",
]
}
} else {
@@ -183,9 +204,144 @@ template("ios_app") {
deps = [
":$bin_gen_target_name",
":$plist_gen_target_name",
+ ":$res_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_pattern_substitution (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
+ }
+
+ _has_test_data = defined(invoker.test_data_files)
+ if (_has_test_data) {
+ _copy_test_data_target_name = target_name + "__test_data"
+ _copy_test_data_target_dir = "$root_build_dir/$_app_name.app"
+ if (defined(invoker.test_data_prefix)) {
+ _copy_test_data_target_dir += "/${invoker.test_data_prefix}"
+ } else {
+ _copy_test_data_target_dir += "/{{source_root_relative_dir}}"
+ }
+
+ copy(_copy_test_data_target_name) {
+ sources = invoker.test_data_files
+ outputs = [
+ "$_copy_test_data_target_dir/{{source_file_part}}",
+ ]
+ }
+ }
+
+ _default_bundle_config_name = target_name + "__config"
+ _default_bundle_target_name = target_name + "__bundle"
+ config(_default_bundle_config_name) {
+ bundle_data = [ "//testing/gtest_ios/Default.png" ]
+ }
+
+ group(_default_bundle_target_name) {
+ all_dependent_configs = [ ":$_default_bundle_config_name" ]
+ }
+
+ ios_app(target_name) {
+ app_name = _app_name
+ testonly = true
+
+ _bundle_test_name = _app_name
+ if (defined(invoker.bundle_test_name)) {
+ _bundle_test_name = invoker.bundle_test_name
+ }
+
+ extra_pattern_substitution = [ "BUNDLE_ID_TEST_NAME=$_bundle_test_name" ]
+
+ entitlements_path = ""
+ if (defined(invoker.entitlements_path)) {
+ entitlements_path = invoker.entitlements_path
+ }
+
+ info_plist = "//testing/gtest_ios/unittest-Info.plist"
+ if (defined(invoker.info_plist)) {
+ info_plist = invoker.info_plist
+ }
+
+ code_signing_identity = ios_code_signing_identity
+ if (defined(invoker.code_signing_identity)) {
+ code_signing_identity = invoker.code_signing_identity
+ }
+
+ forward_variables_from(invoker,
+ [
+ "all_dependent_configs",
+ "allow_circular_includes_from",
+ "cflags",
+ "cflags_c",
+ "cflags_cc",
+ "cflags_objc",
+ "cflags_objcc",
+ "check_includes",
+ "configs",
+ "data",
+ "data_deps",
+ "defines",
+ "deps",
+ "include_dirs",
+ "ldflags",
+ "libs",
+ "output_extension",
+ "public",
+ "public_configs",
+ "public_deps",
+ "sources",
+ "visibility",
+ ])
+
+ if (!defined(invoker.deps)) {
+ deps = []
+ }
+ if (_has_test_data) {
+ deps += [ ":$_copy_test_data_target_name" ]
+ }
+ deps += [ ":$_default_bundle_target_name" ]
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698