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

Side by Side 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: Filter .xcassets from the copy_bundle_data step 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 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 # Use this template to create application bundle for iOS.
Dirk Pranke 2016/01/29 00:54:25 nit: "create an application bundle"
sdefresne 2016/02/05 10:20:00 Ack.
8 assert(defined(invoker.entitlements_path), 8 #
9 "The path to the entitlements .xcent file") 9 # Arguments:
10 assert(defined(invoker.identity), "The code signing identity") 10 #
11 assert(defined(invoker.application_path), "The application to code sign") 11 # info_plist
12 assert(defined(invoker.deps)) 12 # Path to the application Info.plist template (variable substitution
13 13 # will be performed).
14 action(target_name) { 14 #
15 sources = [ 15 # entitlements_path
16 invoker.entitlements_path, 16 # Path to the application entitlements .xcent.
17 ] 17 #
18 18 # code_signing_identity
19 _application_path = invoker.application_path 19 # Identity to use for signing the application, if signing is enabled.
20 20 #
21 script = ios_app_script 21 # app_name (optional)
22 22 # Name of the application, defaults to ${target_name}.
23 outputs = [ 23 #
24 "$_application_path/_CodeSignature/CodeResources", 24 # extra_substitutions (optional)
25 ] 25 # List of string in "key=value" format. Each correspond to variable
26 26 # substitution to perform when compiling the Info.plist template.
27 args = [ 27 #
28 "codesign", 28 # The template uses an "executable" target under the hood and forwards to it
29 "-p", 29 # all the arguments it supports. Look at "executable" documentation for more
30 rebase_path(invoker.application_path, root_build_dir), 30 # information.
31 "-i",
32 invoker.identity,
33 "-e",
34 rebase_path(invoker.entitlements_path, root_build_dir),
35 ]
36
37 forward_variables_from(invoker,
38 [
39 "deps",
40 "public_deps",
41 "testonly",
42 ])
43 }
44 }
45
46 # TODO(GYP), TODO(dpranke): Should this be part of ios_app?
47 template("resource_copy_ios") {
48 assert(defined(invoker.resources),
49 "The source list of resources to copy over")
50 assert(defined(invoker.bundle_directory),
51 "The directory within the bundle to place the sources in")
52 assert(defined(invoker.app_name), "The name of the application")
53
54 _bundle_directory = invoker.bundle_directory
55 _app_name = invoker.app_name
56 _resources = invoker.resources
57
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") { 31 template("ios_app") {
68 assert(defined(invoker.deps),
69 "Dependencies must be specified for $target_name")
70 assert(defined(invoker.info_plist), 32 assert(defined(invoker.info_plist),
71 "The application plist file must be specified for $target_name") 33 "The application plist file must be specified for $target_name")
72 assert(defined(invoker.entitlements_path), 34 assert(defined(invoker.entitlements_path),
73 "The entitlements path must be specified for $target_name") 35 "The entitlements path must be specified for $target_name")
74 assert(defined(invoker.code_signing_identity), 36 assert(defined(invoker.code_signing_identity),
75 "The code_signing_identity must be specified for $target_name") 37 "The code_signing_identity must be specified for $target_name")
76 38
77 # We just create a variable so we can use the same in interpolation 39 # We just create a variable so we can use the same in interpolation
78 if (defined(invoker.app_name)) { 40 if (defined(invoker.app_name)) {
79 _app_name = invoker.app_name 41 _app_name = invoker.app_name
80 } else { 42 } else {
81 _app_name = target_name 43 _app_name = target_name
82 } 44 }
83 45
84 forward_variables_from(invoker, [ "testonly" ]) 46 # Copy target_name so that it can be used in sub-targets.
85 47 _target_name = target_name
86 plist_gen_target_name = target_name + "_plist"
87 bin_gen_target_name = target_name + "_bin"
88 group_target_name = target_name
89 48
90 # Generate the executable 49 # Generate the executable
91 executable(bin_gen_target_name) { 50 executable(_target_name + ".binary") {
92 visibility = [ ":$group_target_name" ] 51 forward_variables_from(invoker,
93 52 "*",
94 output_name = "${_app_name}.app/${_app_name}" 53 [
95 54 "app_name",
55 "code_signing_identity",
56 "entitlements_path",
57 "extra_deps",
58 "extra_substitutions",
59 "info_plist",
60 "output_name",
61 "visibility",
62 ])
63
64 visibility = [ ":$_target_name.plist" ]
65 output_name = "$_app_name.app/$_app_name"
66
67 if (!defined(invoker.libs)) {
68 libs = []
69 }
70 libs += [ "UIKit.framework" ]
71 }
72
73 # Copy resources.
74 copy_bundle_data(_target_name + ".bundle") {
96 forward_variables_from(invoker, 75 forward_variables_from(invoker,
97 [ 76 [
98 "all_dependent_configs", 77 "bundle_data",
99 "allow_circular_includes_from", 78 "deps",
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", 79 "public_deps",
115 "sources", 80 "testonly",
116 ]) 81 ])
117 82
118 if (defined(invoker.libs)) { 83 # .xcassets needs to be compiled into a .car files so omit them from the
119 libs = invoker.libs 84 # list of files to copy into the application bundle.
85 bundle_data_filter = [ "*.xcassets" ]
86
87 visibility = [ ":$_target_name.plist" ]
88 outputs = [
89 "$root_build_dir/$_app_name.app/{{source_file_part}}",
90 ]
91 }
92
93 # Process the Info.plist
94 action(_target_name + ".plist") {
95 forward_variables_from(invoker, [ "testonly" ])
96
97 if (invoker.code_signing_identity == "") {
98 visibility = [ ":$_app_name.app" ]
120 } else { 99 } else {
121 libs = [] 100 visibility = [ ":$_target_name.codesign" ]
122 } 101 }
123 libs += [ 102
124 "UIKit.framework", 103 generated_info_plist = "$root_build_dir/$_app_name.app/Info.plist"
125 "QuartzCore.framework", 104
126 "OpenGLES.framework", 105 script = "//build/config/ios/ios_gen_plist.py"
127 ] 106 outputs = [
128 107 generated_info_plist,
129 if (defined(invoker.deps)) { 108 ]
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 = [ 109 sources = [
110 "//build/config/ios/BuildInfo.plist",
147 invoker.info_plist, 111 invoker.info_plist,
148 ] 112 ]
149 outputs = [ 113
150 "$root_build_dir/${_app_name}.app/Info.plist", 114 extra_args = []
151 ] 115 if (defined(invoker.extra_substitutions)) {
152 116 foreach(substitution, invoker.extra_substitutions) {
153 args = [ 117 extra_args += [ "-s=$substitution" ]
154 "plist", 118 }
155 "-i", 119 }
156 rebase_path(invoker.info_plist, root_build_dir), 120
157 "-o", 121 args = extra_args + [
158 rebase_path("$root_build_dir/${_app_name}.app"), 122 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
159 ] 123 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
160 } 124 "-s=IOS_SDK_NAME=$ios_sdk_name",
161 125 "-s=IOS_SDK_BUILD=$ios_sdk_version",
162 # Perform Code Signing 126 "-s=XCODE_VERSION=$xcode_version",
163 entitlements_path = invoker.entitlements_path 127 "-s=XCODE_BUILD=$xcode_build",
128 "-s=PRODUCT_NAME=$_app_name",
129 "-s=EXECUTABLE_NAME=$_app_name",
130 "-o=" + rebase_path(generated_info_plist),
131 ] + rebase_path(sources)
132
133 deps = [
134 ":$_target_name.binary",
135 ":$_target_name.bundle",
136 ]
137
138 if (defined(invoker.extra_deps)) {
139 deps += invoker.extra_deps
140 }
141 }
142
143 # Perform code signature if needed. Since this require the application
144 # bundle to be complete, this targets depends on the action generating
145 # the Info.plist file, since this introduces a hard dependency (and as
146 # it depends on the other targets, this ensure the bundle is complete).
164 if (invoker.code_signing_identity != "") { 147 if (invoker.code_signing_identity != "") {
165 code_sign_gen_target_name = target_name + "_codesign" 148 action(_target_name + ".codesign") {
166 code_sign_ios(code_sign_gen_target_name) { 149 forward_variables_from(invoker, [ "testonly" ])
167 visibility = [ ":$target_name" ] 150
168 151 visibility = [ ":$_app_name.app" ]
169 identity = invoker.code_signing_identity 152 script = "//build/config/ios/ios_code_sign.py"
170 application_path = "$root_build_dir/$app_name.app" 153
154 sources = [
155 entitlements_path,
156 ]
157 outputs = [
158 "$root_build_dir/$app_name.app/_CodeSignature/CodeResources",
159 ]
160
161 args = [
162 "-i=" + invoker.code_signing_identity,
163 "-p=" + rebase_path("$root_build_dir/$app_name.app", root_build_dir),
164 "-e=" + rebase_path(invoker.entitlements_path, root_build_dir),
165 ]
166
171 deps = [ 167 deps = [
172 ":$bin_gen_target_name", 168 ":$_target_name.plist",
173 ":$plist_gen_target_name",
174 ] 169 ]
175 } 170 }
176 } else { 171 } else {
177 # This avoids a potential unused variable warning in the caller. 172 # This avoids a potential unused variable warning in the caller.
173 entitlements_path = invoker.entitlements_path
178 entitlements_path = entitlements_path 174 entitlements_path = entitlements_path
179 } 175 }
180 176
181 # Top level group 177 # Intermediate targets that allows to build the application by its name.
182 group(target_name) { 178 group(_app_name + ".app") {
179 forward_variables_from(invoker, [ "testonly" ])
180
181 visibility = [ ":$_target_name" ]
182 if (invoker.code_signing_identity != "") {
183 deps = [
184 ":$_target_name.codesign",
185 ]
186 } else {
187 deps = [
188 ":$_target_name.plist",
189 ]
190 }
191 }
192
193 group(_target_name) {
194 forward_variables_from(invoker,
195 [
196 "public_deps",
197 "testonly",
198 "visibility",
199 ])
183 deps = [ 200 deps = [
184 ":$bin_gen_target_name", 201 ":$_app_name.app",
185 ":$plist_gen_target_name", 202 ]
186 ]
187 if (invoker.code_signing_identity != "") {
188 deps += [ ":$code_sign_gen_target_name" ]
189 }
190 } 203 }
191 } 204 }
205
206 # Use this template to create test application bundle for iOS.
Dirk Pranke 2016/01/29 00:54:25 nit "create a test" ?
sdefresne 2016/02/05 10:20:00 Ack.
207 #
208 # Arguments:
209 #
210 # bundle_test_name (optional)
211 # String to use as bundle identifier in the Info.plist. Default to
212 # ${app_name}.
213 #
214 # test_data_files (optional)
215 # List of file to copy in the application bundle. The path in the
216 # bundle will be the same as the path from the source root, unless
217 # test_data_prefix is defined.
218 #
219 # test_data_prefix (optional)
220 # If defined, ${test_data_files} will be copied to this directory
221 # relative to the application bundle instead of a path relative to
222 # source root.
223 #
224 # info_plist (optional)
225 # Path to the application Info.plist template (variable substitution
226 # will be performed).
227 #
228 # entitlements_path (optional)
229 # Path to the application entitlements .xcent.
230 #
231 # code_signing_identity (optional)
232 # Identity to use for signing the application, if signing is enabled.
233 #
234 # app_name (optional)
235 # Name of the application, defaults to ${target_name}.
236 #
237 # extra_substitutions (optional)
238 # List of string in "key=value" format. Each correspond to variable
239 # substitution to perform when compiling the Info.plist template.
240 #
241 # The template uses an "ios_app" target under the hood and forwards to it
242 # all the arguments it supports. Look at "executable" documentation for more
243 # information.
244 template("ios_test_app") {
245 # Copy target_name so that it can be used in sub-targets.
246 _target_name = target_name
247
248 if (defined(invoker.test_data_files)) {
249 if (defined(invoker.app_name)) {
250 _app_name = invoker.app_name
251 } else {
252 _app_name = _target_name
253 }
254
255 copy(_target_name + ".testdata") {
Dirk Pranke 2016/02/10 01:18:13 we don't usually use periods in target names; copy
256 sources = invoker.test_data_files
257 outputs = [
258 "$root_build_dir/$_app_name.app/{{source_root_relative_dir}}/" +
259 "{{source_file_part}}",
260 ]
261 }
262 }
263
264 ios_app(_target_name) {
265 forward_variables_from(invoker, "*")
266
267 if (defined(invoker.test_data_files)) {
268 extra_deps = [ ":$_target_name.testdata" ]
269 }
270 }
271 }
OLDNEW
« base/BUILD.gn ('K') | « 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