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

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: Address comments 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.
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 plist_gen_target_name = target_name + "__plist"
85 47 bin_gen_target_name = target_name + "__bin"
86 plist_gen_target_name = target_name + "_plist" 48 res_gen_target_name = target_name + "__res"
87 bin_gen_target_name = target_name + "_bin" 49 _target_name = target_name
88 group_target_name = target_name
89 50
90 # Generate the executable 51 # Generate the executable
91 executable(bin_gen_target_name) { 52 executable(bin_gen_target_name) {
92 visibility = [ ":$group_target_name" ] 53 forward_variables_from(invoker,
93 54 "*",
94 output_name = "${_app_name}.app/${_app_name}" 55 [
95 56 "app_name",
57 "code_signing_identity",
58 "entitlements_path",
59 "extra_deps",
60 "extra_substitutions",
61 "info_plist",
62 "output_name",
63 "visibility",
64 ])
65
66 visibility = [ ":$plist_gen_target_name" ]
67 output_name = "$_app_name.app/$_app_name"
68
69 if (!defined(invoker.libs)) {
70 libs = []
71 }
72 libs += [ "UIKit.framework" ]
73 }
74
75 # Copy resources.
76 copy_bundle_data(res_gen_target_name) {
96 forward_variables_from(invoker, 77 forward_variables_from(invoker,
97 [ 78 [
98 "all_dependent_configs", 79 "bundle_data",
99 "allow_circular_includes_from", 80 "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", 81 "public_deps",
115 "sources", 82 "testonly",
116 ]) 83 ])
117 84
118 if (defined(invoker.libs)) { 85 visibility = [ ":$plist_gen_target_name" ]
119 libs = invoker.libs 86 outputs = [
120 } else { 87 "$root_build_dir/$_app_name.app/{{source_file_part}}",
121 libs = [] 88 ]
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 } 89 }
136 90
137 # Process the Info.plist 91 # Process the Info.plist
138 action(plist_gen_target_name) { 92 action(plist_gen_target_name) {
139 visibility = [ 93 forward_variables_from(invoker, [ "testonly" ])
140 ":$group_target_name", 94
95 visibility = [ ":$_target_name" ]
96
97 generated_info_plist = "$root_build_dir/$_app_name.app/Info.plist"
98
99 script = "//build/config/ios/ios_gen_plist.py"
100 outputs = [
101 generated_info_plist,
102 ]
103 sources = [
104 "//build/config/ios/BuildInfo.plist",
105 invoker.info_plist,
106 ]
107
108 extra_args = []
109 if (defined(invoker.extra_substitutions)) {
110 foreach(substitution, invoker.extra_substitutions) {
111 extra_args += [ "-s=$substitution" ]
112 }
113 }
114
115 args = extra_args + [
116 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build",
117 "-s=IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
118 "-s=IOS_SDK_NAME=$ios_sdk_name",
119 "-s=IOS_SDK_BUILD=$ios_sdk_version",
120 "-s=XCODE_VERSION=$xcode_version",
121 "-s=XCODE_BUILD=$xcode_build",
122 "-s=PRODUCT_NAME=$_app_name",
123 "-s=EXECUTABLE_NAME=$_app_name",
124 "-o=" + rebase_path(generated_info_plist),
125 ] + rebase_path(sources)
126
127 deps = [
141 ":$bin_gen_target_name", 128 ":$bin_gen_target_name",
142 ] 129 ":$res_gen_target_name",
143 130 ]
144 script = ios_app_script 131
145 132 if (defined(invoker.extra_deps)) {
146 sources = [ 133 deps += invoker.extra_deps
147 invoker.info_plist, 134 }
148 ] 135 }
149 outputs = [ 136
150 "$root_build_dir/${_app_name}.app/Info.plist", 137 # Perform code signature if needed. Since this require the application
151 ] 138 # bundle to be complete, this targets depends on the action generating
152 139 # the Info.plist file, since this introduces a hard dependency (and as
153 args = [ 140 # it depends on the other targets, this ensure the bundle is complete).
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 != "") { 141 if (invoker.code_signing_identity != "") {
165 code_sign_gen_target_name = target_name + "_codesign" 142 action(target_name) {
166 code_sign_ios(code_sign_gen_target_name) { 143 forward_variables_from(invoker,
167 visibility = [ ":$target_name" ] 144 [
168 145 "visibility",
169 identity = invoker.code_signing_identity 146 "testonly",
170 application_path = "$root_build_dir/$app_name.app" 147 "public_deps",
148 ])
149 script = "//build/config/ios/ios_code_sign.py"
150
151 sources = [
152 entitlements_path,
153 ]
154 outputs = [
155 "$root_build_dir/$app_name.app/_CodeSignature/CodeResources",
156 ]
157
158 args = [
159 "-i=" + invoker.code_signing_identity,
160 "-p=" + rebase_path("$root_build_dir/$app_name.app", root_build_dir),
161 "-e=" + rebase_path(invoker.entitlements_path, root_build_dir),
162 ]
163
171 deps = [ 164 deps = [
172 ":$bin_gen_target_name",
173 ":$plist_gen_target_name", 165 ":$plist_gen_target_name",
174 ] 166 ]
175 } 167 }
176 } else { 168 } else {
177 # This avoids a potential unused variable warning in the caller. 169 # This avoids a potential unused variable warning in the caller.
170 entitlements_path = invoker.entitlements_path
178 entitlements_path = entitlements_path 171 entitlements_path = entitlements_path
179 } 172
180 173 group(target_name) {
181 # Top level group 174 forward_variables_from(invoker,
182 group(target_name) { 175 [
183 deps = [ 176 "visibility",
184 ":$bin_gen_target_name", 177 "testonly",
185 ":$plist_gen_target_name", 178 "public_deps",
186 ] 179 ])
187 if (invoker.code_signing_identity != "") { 180 deps = [
188 deps += [ ":$code_sign_gen_target_name" ] 181 ":$plist_gen_target_name",
182 ]
189 } 183 }
190 } 184 }
191 } 185 }
186
187 # Use this template to create test application bundle for iOS.
188 #
189 # Arguments:
190 #
191 # bundle_test_name (optional)
192 # String to use as bundle identifier in the Info.plist. Default to
193 # ${app_name}.
194 #
195 # test_data_files (optional)
196 # List of file to copy in the application bundle. The path in the
197 # bundle will be the same as the path from the source root, unless
198 # test_data_prefix is defined.
199 #
200 # test_data_prefix (optional)
201 # If defined, ${test_data_files} will be copied to this directory
202 # relative to the application bundle instead of a path relative to
203 # source root.
204 #
205 # info_plist (optional)
206 # Path to the application Info.plist template (variable substitution
207 # will be performed).
208 #
209 # entitlements_path (optional)
210 # Path to the application entitlements .xcent.
211 #
212 # code_signing_identity (optional)
213 # Identity to use for signing the application, if signing is enabled.
214 #
215 # app_name (optional)
216 # Name of the application, defaults to ${target_name}.
217 #
218 # extra_substitutions (optional)
219 # List of string in "key=value" format. Each correspond to variable
220 # substitution to perform when compiling the Info.plist template.
221 #
222 # The template uses an "ios_app" target under the hood and forwards to it
223 # all the arguments it supports. Look at "executable" documentation for more
224 # information.
225 template("ios_test_app") {
226 _app_name = target_name
227 if (defined(invoker.app_name)) {
228 _app_name = invoker.app_name
229 }
230
231 if (defined(invoker.test_data_files)) {
232 _copy_test_data_target_name = target_name + "__test_data"
233 copy(_copy_test_data_target_name) {
234 sources = invoker.test_data_files
235 outputs = [
236 "$root_build_dir/$_app_name.app/{{source_root_relative_dir}}/{{source_fi le_part}}",
237 ]
238 }
239 }
240
241 ios_app(target_name) {
242 forward_variables_from(invoker, "*")
243
244 app_name = _app_name
245 if (defined(invoker.test_data_files)) {
246 extra_deps = [ ":$_copy_test_data_target_name" ]
247 }
248 }
249 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698