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

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

Issue 1752873002: Use bundle_data and create_bundle to add support for iOS app bundle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gn-create-bundle
Patch Set: Remove conditional around bundle_data, use response_file_contents, clean description of compile_xca… Created 4 years, 9 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
« no previous file with comments | « build/config/ios/ios_sdk.py ('k') | build/toolchain/mac/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/config/ios/rules.gni
diff --git a/build/config/ios/rules.gni b/build/config/ios/rules.gni
index 7d9cfa204cd4d351a5fc0419714941188a81a916..d4898cda03fe00267c13bde18d84ac7bea0419c8 100644
--- a/build/config/ios/rules.gni
+++ b/build/config/ios/rules.gni
@@ -2,191 +2,162 @@
# 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")
+
+# TODO(crbug.com/297668): refactor this template to extract common behaviour
+# between OS X and iOS bundle generation, then create a generic "app" template
+# that forward to "executable" on all platform except iOS/OS X.
+
+# Template to build an application bundle for iOS.
+#
+# This should be used instead of "executable" built-in target type on iOS.
+# As the template forward the generation of the application executable to
+# an "executable" target, all arguments supported by "executable" targets
+# are also supported by this template.
+#
+# Arguments
+#
+# app_name:
+# (optional) string, name of the generated application, if omitted,
+# defaults to the target_name.
+#
+# extra_substitutions:
+# (optional) list of string in "key=value" format, each value will
+# be used as an additional variable substitution rule when generating
+# the application Info.plist
+#
+# info_plist:
+# path to the template to use to generate the application Info.plist
+# by performing variable substitutions.
+#
+# For more information, see "gn help executable".
+template("app") {
+ assert(defined(invoker.info_plist),
+ "info_plist must be specified for target $target_name")
-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))
+ _app_name = target_name
+ _target_name = target_name
+ if (defined(invoker.app_name)) {
+ _app_name = invoker.app_name
+ }
- action(target_name) {
+ _generate_info_plist = target_name + "_generate_info_plist"
+ _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
+
+ action(_generate_info_plist) {
+ visibility = [ ":$_bundle_data_info_plist" ]
+ script = "//build/config/ios/ios_gen_plist.py"
sources = [
- invoker.entitlements_path,
+ "//build/config/ios/BuildInfo.plist",
+ invoker.info_plist,
]
-
- _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),
+ "$target_gen_dir/$target_name/Info.plist",
]
-
- forward_variables_from(invoker,
- [
- "deps",
- "public_deps",
- "testonly",
- ])
+ extra_args = []
+ if (defined(invoker.extra_substitutions)) {
+ foreach(substitution, invoker.extra_substitutions) {
+ extra_args += [ "-s=$substitution" ]
+ }
+ }
+ response_file_contents =
+ extra_args + [
+ "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
+ "-s=EXECUTABLE_NAME=$_app_name",
+ "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
+ "-s=IOS_DEPLOYMENT_TARGET=$ios_deployment_target",
+ "-s=IOS_PLATFORM_BUILD=$ios_platform_build",
+ "-s=IOS_PLATFORM_NAME=$ios_sdk_name",
+ "-s=IOS_PLATFORM_VERSION=$ios_sdk_version",
+ "-s=IOS_SDK_BUILD=$ios_sdk_build",
+ "-s=IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version",
+ "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
+ "-s=PRODUCT_NAME=$_app_name",
+ "-s=XCODE_BUILD=$xcode_build",
+ "-s=XCODE_VERSION=$xcode_version",
+ "-o=" + rebase_path(outputs[0], root_build_dir),
+ ] + rebase_path(sources, root_build_dir)
+ args = [ "@{{response_file_name}}" ]
}
-}
-
-# 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
+ bundle_data(_bundle_data_info_plist) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
+ sources = get_target_outputs(":$_generate_info_plist")
outputs = [
- "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}",
+ "{{bundle_root_dir}}/Info.plist",
+ ]
+ public_deps = [
+ ":$_generate_info_plist",
]
}
-}
-
-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),
- "The entitlements path must be specified for $target_name")
- assert(defined(invoker.code_signing_identity),
- "The code_signing_identity must be specified for $target_name")
-
- # We just create a variable so we can use the same in interpolation
- if (defined(invoker.app_name)) {
- _app_name = invoker.app_name
- } else {
- _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
- # Generate the executable
- executable(bin_gen_target_name) {
- visibility = [ ":$group_target_name" ]
-
- output_name = "${_app_name}.app/${_app_name}"
+ _generate_executable = target_name + "_generate_executable"
+ _bundle_data_executable = target_name + "_bundle_data_executable"
+ executable(_generate_executable) {
+ visibility = [ ":$_bundle_data_executable" ]
forward_variables_from(invoker,
+ "*",
[
- "all_dependent_configs",
- "allow_circular_includes_from",
- "cflags",
- "cflags_c",
- "cflags_cc",
- "cflags_objc",
- "cflags_objcc",
- "configs",
- "check_includes",
- "data",
+ "app_name",
+ "code_signing_identity",
"data_deps",
- "defines",
- "include_dirs",
- "ldflags",
- "public",
- "public_configs",
- "public_deps",
- "sources",
+ "entitlements_path",
+ "info_plist",
+ "visibility",
])
- if (defined(invoker.libs)) {
- libs = invoker.libs
- } else {
+ output_name = rebase_path("$target_gen_dir/$_app_name", root_build_dir)
+ if (!defined(libs)) {
libs = []
}
- libs += [
- "UIKit.framework",
- "QuartzCore.framework",
- "OpenGLES.framework",
- ]
-
- if (defined(invoker.deps)) {
- deps = invoker.deps
- } else {
- deps = []
- }
- deps += [ ":$plist_gen_target_name" ]
+ libs += [ "UIKit.framework" ]
}
- # Process the Info.plist
- action(plist_gen_target_name) {
- visibility = [
- ":$group_target_name",
- ":$bin_gen_target_name",
- ]
-
- script = ios_app_script
-
+ bundle_data(_bundle_data_executable) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_target_name" ]
sources = [
- invoker.info_plist,
+ "$target_gen_dir/$_app_name",
]
outputs = [
- "$root_build_dir/${_app_name}.app/Info.plist",
+ "{{bundle_executable_dir}}/$_app_name",
]
-
- args = [
- "plist",
- "-i",
- rebase_path(invoker.info_plist, root_build_dir),
- "-o",
- rebase_path("$root_build_dir/${_app_name}.app"),
+ public_deps = [
+ ":$_generate_executable",
]
}
- # Perform Code Signing
- entitlements_path = invoker.entitlements_path
- if (invoker.code_signing_identity != "") {
- code_sign_gen_target_name = target_name + "_codesign"
- code_sign_ios(code_sign_gen_target_name) {
- visibility = [ ":$target_name" ]
+ create_bundle(target_name) {
+ forward_variables_from(invoker,
+ [
+ "data_deps",
+ "deps",
+ "public_deps",
+ "testonly",
+ "visibility",
+ ])
- identity = invoker.code_signing_identity
- application_path = "$root_build_dir/$app_name.app"
- deps = [
- ":$bin_gen_target_name",
- ":$plist_gen_target_name",
- ]
+ if (!defined(deps)) {
+ deps = []
}
- } else {
- # This avoids a potential unused variable warning in the caller.
- entitlements_path = entitlements_path
- }
-
- # Top level group
- group(target_name) {
- forward_variables_from(invoker, [ "visibility" ])
- deps = [
- ":$bin_gen_target_name",
- ":$plist_gen_target_name",
+ deps += [
+ ":$_bundle_data_executable",
+ ":$_bundle_data_info_plist",
]
- if (invoker.code_signing_identity != "") {
- deps += [ ":$code_sign_gen_target_name" ]
- }
+
+ bundle_root_dir = "$root_out_dir/$_app_name.app"
+ bundle_resources_dir = bundle_root_dir
+ bundle_executable_dir = bundle_root_dir
+ bundle_plugins_dir = "$bundle_root_dir/Plugins"
}
+
+ # TODO(crbug.com/297668):
+ # - add support for codesigning,
+ # - find a way to make "ninja -C out/Default base_unittests.app" work as
+ # an alias to "ninja -C out/Default base_unittests" (for convenience
+ # and compatibility with gyp),
+ # - implement //testing/iossim(//build/toolchain/mac:clang_x64) and then
+ # add a depency to that target.
}
« no previous file with comments | « build/config/ios/ios_sdk.py ('k') | build/toolchain/mac/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698