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

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: Created 4 years, 10 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..4952b24bb51bb94f3b72226d8732cd128b30e5ff 100644
--- a/build/config/ios/rules.gni
+++ b/build/config/ios/rules.gni
@@ -2,190 +2,161 @@
# 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("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))
+# 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("ios_app") {
+ # The application name defaults to target_name.
+ _app_name = target_name
+ if (defined(invoker.app_name)) {
+ _app_name = invoker.app_name
+ }
- action(target_name) {
+ # Declare the name of the target creating the application bundle so that
+ # other targets can use it when setting "visibility". The target is named
+ # $target_name.app as it allows use to use the application name as argument
+ # to ninja during the build.
+ _create_app_bundle = target_name + ".app"
Dirk Pranke 2016/03/01 23:56:30 This is a bit confusing to me. Is _create_app_bund
sdefresne 2016/03/11 17:57:12 Done, but now I get the following error: $ ninja
+
+ # Declare the name of some target as they have circular dependency via
+ # "visibility" and "deps".
+ _generate_info_plist = target_name + "_generate_info_plist"
+ _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
+
+ # Perform variable substitutions in the Info.plist and convert it to
+ # binary1 format.
+ 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",
+ "$target_gen_dir/$target_name/Info.plist",
]
-
- 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",
- ])
+ 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=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)
}
-}
-# 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
+ # Informs that the generated Info.plist file needs to be copied into the
+ # application bundle.
+ bundle_data(_bundle_data_info_plist) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_create_app_bundle" ]
+ 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}"
+ # Declare the name of some target as they have circular dependency via
+ # "visibility" and "deps".
Dirk Pranke 2016/03/01 23:56:30 I would probably drop this comment as calling thin
sdefresne 2016/03/11 17:57:12 Done.
+ _generate_executable = target_name + "_generate_executable"
+ _bundle_data_executable = target_name + "_bundle_data_executable"
+ # Generates the application executable.
Dirk Pranke 2016/03/01 23:56:30 I would omit this comment.
sdefresne 2016/03/11 17:57:12 Done.
+ 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
-
+ # Informs that the application executable needs to be copied into the
+ # application bundle.
Dirk Pranke 2016/03/01 23:56:30 I'm not actually sure what you're trying to convey
sdefresne 2016/03/11 17:57:12 Done.
+ bundle_data(_bundle_data_executable) {
+ forward_variables_from(invoker, [ "testonly" ])
+ visibility = [ ":$_create_app_bundle" ]
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" ]
+ # Creates the application bundle.
+ create_bundle(_create_app_bundle) {
Dirk Pranke 2016/03/01 23:56:30 Can you just make this be create_bundle(target
sdefresne 2016/03/11 17:57:12 Done, but now I get the following error: $ ninja
+ 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
+ deps += [
+ ":$_bundle_data_executable",
+ ":$_bundle_data_info_plist",
+ ]
+
+ 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"
}
- # Top level group
+ # TODO(crbug.com/297668):
+ # - add support for codesigning,
+ # - implements //testing/iossim(//build/toolchain/mac:clang_x64) and then
Dirk Pranke 2016/03/01 23:56:30 Nit: s/implements/implement
sdefresne 2016/03/11 17:57:12 Done.
+ # add a depency to that target.
+
+ # This group target is there to alias the _create_app_bundle target using
+ # the name passed to the template.
group(target_name) {
+ forward_variables_from(invoker,
+ [
+ "testonly",
+ "visibility",
+ ])
deps = [
- ":$bin_gen_target_name",
- ":$plist_gen_target_name",
+ ":$_create_app_bundle",
]
- if (invoker.code_signing_identity != "") {
- deps += [ ":$code_sign_gen_target_name" ]
- }
}
}

Powered by Google App Engine
This is Rietveld 408576698