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

Side by Side 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: Rebase 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 ios_app_script = "//build/config/ios/ios_app.py" 5 import("//build/config/ios/ios_sdk.gni")
6 6
7 template("code_sign_ios") { 7 # TODO(crbug.com/297668): refactor this template to extract common behaviour
8 assert(defined(invoker.entitlements_path), 8 # between OS X and iOS bundle generation, then create a generic "app" template
9 "The path to the entitlements .xcent file") 9 # that forward to "executable" on all platform except iOS/OS X.
10 assert(defined(invoker.identity), "The code signing identity")
11 assert(defined(invoker.application_path), "The application to code sign")
12 assert(defined(invoker.deps))
13 10
14 action(target_name) { 11 # Template to build an application bundle for iOS.
12 #
13 # This should be used instead of "executable" built-in target type on iOS.
14 # As the template forward the generation of the application executable to
15 # an "executable" target, all arguments supported by "executable" targets
16 # are also supported by this template.
17 #
18 # Arguments
19 #
20 # app_name:
21 # (optional) string, name of the generated application, if omitted,
22 # defaults to the target_name.
23 #
24 # extra_substitutions:
25 # (optional) list of string in "key=value" format, each value will
26 # be used as an additional variable substitution rule when generating
27 # the application Info.plist
28 #
29 # info_plist:
30 # path to the template to use to generate the application Info.plist
31 # by performing variable substitutions.
32 #
33 # For more information, see "gn help executable".
34 template("app") {
35 assert(defined(invoker.info_plist),
36 "info_plist must be specified for target $target_name")
37
38 _app_name = target_name
39 _target_name = target_name
40 if (defined(invoker.app_name)) {
41 _app_name = invoker.app_name
42 }
43
44 _generate_info_plist = target_name + "_generate_info_plist"
45 _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
46
47 action(_generate_info_plist) {
48 visibility = [ ":$_bundle_data_info_plist" ]
49 script = "//build/config/ios/ios_gen_plist.py"
15 sources = [ 50 sources = [
16 invoker.entitlements_path, 51 "//build/config/ios/BuildInfo.plist",
52 invoker.info_plist,
17 ] 53 ]
54 outputs = [
55 "$target_gen_dir/$target_name/Info.plist",
56 ]
57 extra_args = []
58 if (defined(invoker.extra_substitutions)) {
59 foreach(substitution, invoker.extra_substitutions) {
60 extra_args += [ "-s=$substitution" ]
61 }
62 }
63 args = extra_args + [
64 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
65 "-s=EXECUTABLE_NAME=$_app_name",
66 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0",
67 "-s=IOS_DEPLOYMENT_TARGET=$ios_deployment_target",
68 "-s=IOS_PLATFORM_BUILD=$ios_platform_build",
69 "-s=IOS_PLATFORM_NAME=$ios_sdk_name",
70 "-s=IOS_PLATFORM_VERSION=$ios_sdk_version",
71 "-s=IOS_SDK_BUILD=$ios_sdk_build",
72 "-s=IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version",
73 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
74 "-s=PRODUCT_NAME=$_app_name",
75 "-s=XCODE_BUILD=$xcode_build",
76 "-s=XCODE_VERSION=$xcode_version",
77 "-o=" + rebase_path(outputs[0], root_build_dir),
78 ] + rebase_path(sources, root_build_dir)
brettw 2016/03/15 18:02:29 This is still probably within the command-line len
sdefresne 2016/03/16 09:58:49 I was planning to do it (see custom ArgumentParser
79 }
18 80
19 _application_path = invoker.application_path 81 bundle_data(_bundle_data_info_plist) {
82 forward_variables_from(invoker, [ "testonly" ])
83 visibility = [ ":$_target_name" ]
84 sources = get_target_outputs(":$_generate_info_plist")
85 outputs = [
86 "{{bundle_root_dir}}/Info.plist",
87 ]
88 public_deps = [
89 ":$_generate_info_plist",
90 ]
91 }
20 92
21 script = ios_app_script 93 _generate_executable = target_name + "_generate_executable"
94 _bundle_data_executable = target_name + "_bundle_data_executable"
22 95
96 executable(_generate_executable) {
97 visibility = [ ":$_bundle_data_executable" ]
98 forward_variables_from(invoker,
99 "*",
100 [
101 "app_name",
brettw 2016/03/15 18:02:29 I don't know if you saw the other code review but
sdefresne 2016/03/16 09:58:49 Yeah, I've seen the CL and have a pending CL to us
102 "code_signing_identity",
103 "data_deps",
104 "entitlements_path",
105 "info_plist",
106 "visibility",
107 ])
108
109 output_name = rebase_path("$target_gen_dir/$_app_name", root_build_dir)
110 if (!defined(libs)) {
111 libs = []
112 }
113 libs += [ "UIKit.framework" ]
114 }
115
116 bundle_data(_bundle_data_executable) {
117 forward_variables_from(invoker, [ "testonly" ])
118 visibility = [ ":$_target_name" ]
119 sources = [
120 "$target_gen_dir/$_app_name",
121 ]
23 outputs = [ 122 outputs = [
24 "$_application_path/_CodeSignature/CodeResources", 123 "{{bundle_executable_dir}}/$_app_name",
25 ] 124 ]
125 public_deps = [
126 ":$_generate_executable",
127 ]
128 }
26 129
27 args = [ 130 create_bundle(target_name) {
28 "codesign",
29 "-p",
30 rebase_path(invoker.application_path, root_build_dir),
31 "-i",
32 invoker.identity,
33 "-e",
34 rebase_path(invoker.entitlements_path, root_build_dir),
35 ]
36
37 forward_variables_from(invoker, 131 forward_variables_from(invoker,
38 [ 132 [
133 "data_deps",
39 "deps", 134 "deps",
40 "public_deps", 135 "public_deps",
41 "testonly", 136 "testonly",
137 "visibility",
42 ]) 138 ])
43 }
44 }
45 139
46 # TODO(GYP), TODO(dpranke): Should this be part of ios_app? 140 if (!defined(deps)) {
47 template("resource_copy_ios") { 141 deps = []
48 assert(defined(invoker.resources), 142 }
49 "The source list of resources to copy over") 143 deps += [
50 assert(defined(invoker.bundle_directory), 144 ":$_bundle_data_executable",
51 "The directory within the bundle to place the sources in") 145 ":$_bundle_data_info_plist",
52 assert(defined(invoker.app_name), "The name of the application") 146 ]
53 147
54 _bundle_directory = invoker.bundle_directory 148 bundle_root_dir = "$root_out_dir/$_app_name.app"
55 _app_name = invoker.app_name 149 bundle_resources_dir = bundle_root_dir
56 _resources = invoker.resources 150 bundle_executable_dir = bundle_root_dir
57 151 bundle_plugins_dir = "$bundle_root_dir/Plugins"
58 copy(target_name) {
59 set_sources_assignment_filter([])
60 sources = _resources
61 outputs = [
62 "$root_build_dir/$_app_name.app/$_bundle_directory/{{source_file_part}}",
63 ]
64 }
65 }
66
67 template("ios_app") {
68 assert(defined(invoker.deps),
69 "Dependencies must be specified for $target_name")
70 assert(defined(invoker.info_plist),
71 "The application plist file must be specified for $target_name")
72 assert(defined(invoker.entitlements_path),
73 "The entitlements path must be specified for $target_name")
74 assert(defined(invoker.code_signing_identity),
75 "The code_signing_identity must be specified for $target_name")
76
77 # We just create a variable so we can use the same in interpolation
78 if (defined(invoker.app_name)) {
79 _app_name = invoker.app_name
80 } else {
81 _app_name = target_name
82 } 152 }
83 153
84 forward_variables_from(invoker, [ "testonly" ]) 154 # TODO(crbug.com/297668):
85 155 # - add support for codesigning,
86 plist_gen_target_name = target_name + "_plist" 156 # - find a way to make "ninja -C out/Default base_unittests.app" work as
87 bin_gen_target_name = target_name + "_bin" 157 # an alias to "ninja -C out/Default base_unittests" (for convenience
88 group_target_name = target_name 158 # and compatibility with gyp),
89 159 # - implement //testing/iossim(//build/toolchain/mac:clang_x64) and then
90 # Generate the executable 160 # add a depency to that target.
91 executable(bin_gen_target_name) {
92 visibility = [ ":$group_target_name" ]
93
94 output_name = "${_app_name}.app/${_app_name}"
95
96 forward_variables_from(invoker,
97 [
98 "all_dependent_configs",
99 "allow_circular_includes_from",
100 "cflags",
101 "cflags_c",
102 "cflags_cc",
103 "cflags_objc",
104 "cflags_objcc",
105 "configs",
106 "check_includes",
107 "data",
108 "data_deps",
109 "defines",
110 "include_dirs",
111 "ldflags",
112 "public",
113 "public_configs",
114 "public_deps",
115 "sources",
116 ])
117
118 if (defined(invoker.libs)) {
119 libs = invoker.libs
120 } else {
121 libs = []
122 }
123 libs += [
124 "UIKit.framework",
125 "QuartzCore.framework",
126 "OpenGLES.framework",
127 ]
128
129 if (defined(invoker.deps)) {
130 deps = invoker.deps
131 } else {
132 deps = []
133 }
134 deps += [ ":$plist_gen_target_name" ]
135 }
136
137 # Process the Info.plist
138 action(plist_gen_target_name) {
139 visibility = [
140 ":$group_target_name",
141 ":$bin_gen_target_name",
142 ]
143
144 script = ios_app_script
145
146 sources = [
147 invoker.info_plist,
148 ]
149 outputs = [
150 "$root_build_dir/${_app_name}.app/Info.plist",
151 ]
152
153 args = [
154 "plist",
155 "-i",
156 rebase_path(invoker.info_plist, root_build_dir),
157 "-o",
158 rebase_path("$root_build_dir/${_app_name}.app"),
159 ]
160 }
161
162 # Perform Code Signing
163 entitlements_path = invoker.entitlements_path
164 if (invoker.code_signing_identity != "") {
165 code_sign_gen_target_name = target_name + "_codesign"
166 code_sign_ios(code_sign_gen_target_name) {
167 visibility = [ ":$target_name" ]
168
169 identity = invoker.code_signing_identity
170 application_path = "$root_build_dir/$app_name.app"
171 deps = [
172 ":$bin_gen_target_name",
173 ":$plist_gen_target_name",
174 ]
175 }
176 } else {
177 # This avoids a potential unused variable warning in the caller.
178 entitlements_path = entitlements_path
179 }
180
181 # Top level group
182 group(target_name) {
183 forward_variables_from(invoker, [ "visibility" ])
184 deps = [
185 ":$bin_gen_target_name",
186 ":$plist_gen_target_name",
187 ]
188 if (invoker.code_signing_identity != "") {
189 deps += [ ":$code_sign_gen_target_name" ]
190 }
191 }
192 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698