OLD | NEW |
---|---|
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 import("//build/config/ios/ios_sdk.gni") | 5 import("//build/config/ios/ios_sdk.gni") |
6 import("//build/config/mac/base_rules.gni") | 6 import("//build/config/mac/base_rules.gni") |
7 | 7 |
8 # Generates Info.plist files for Mac apps and frameworks. | 8 # Generates Info.plist files for Mac apps and frameworks. |
9 # | 9 # |
10 # Arguments | 10 # Arguments |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 # not be overridden. | 115 # not be overridden. |
116 # | 116 # |
117 # For more information, see "gn help executable". | 117 # For more information, see "gn help executable". |
118 template("ios_app_bundle") { | 118 template("ios_app_bundle") { |
119 _output_name = target_name | 119 _output_name = target_name |
120 _target_name = target_name | 120 _target_name = target_name |
121 if (defined(invoker.output_name)) { | 121 if (defined(invoker.output_name)) { |
122 _output_name = invoker.output_name | 122 _output_name = invoker.output_name |
123 } | 123 } |
124 | 124 |
125 _generate_info_plist = target_name + "_generate_info_plist" | 125 _is_fat_build = multi_arch_toolchains != [] |
126 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | 126 if (_is_fat_build) { |
127 | 127 _is_fat_build_main_target = current_toolchain == multi_arch_toolchains[0] |
128 ios_info_plist(_generate_info_plist) { | |
129 executable_name = _output_name | |
130 forward_variables_from(invoker, | |
131 [ | |
132 "extra_substitutions", | |
133 "info_plist", | |
134 "info_plist_target", | |
135 ]) | |
136 } | 128 } |
137 | 129 |
138 bundle_data(_bundle_data_info_plist) { | 130 if (_is_fat_build && !_is_fat_build_main_target) { |
139 forward_variables_from(invoker, [ "testonly" ]) | 131 executable(_target_name) { |
140 visibility = [ ":$_target_name" ] | 132 forward_variables_from(invoker, |
141 sources = get_target_outputs(":$_generate_info_plist") | 133 "*", |
142 outputs = [ | 134 [ |
143 "{{bundle_root_dir}}/Info.plist", | 135 "bundle_extension", |
144 ] | 136 "entitlements_path", |
145 public_deps = [ | 137 "extra_substitutions", |
146 ":$_generate_info_plist", | 138 "info_plist", |
147 ] | 139 "info_plist_target", |
148 } | 140 "output_name", |
149 | 141 "product_type", |
150 _generate_executable = target_name + "_generate_executable" | 142 ]) |
151 if (!ios_enable_code_signing) { | 143 |
152 _bundle_data_executable = target_name + "_bundle_data_executable" | 144 if (defined(visibility)) { |
153 } | 145 visibility += [ ":*($default_toolchain)" ] |
154 | 146 } |
155 executable(_generate_executable) { | 147 |
156 if (ios_enable_code_signing) { | 148 output_name = _output_name |
149 if (!defined(libs)) { | |
150 libs = [] | |
151 } | |
152 libs += [ "UIKit.framework" ] | |
153 if (!defined(ldflags)) { | |
154 ldflags = [] | |
155 } | |
156 ldflags += [ "-ObjC" ] | |
157 } | |
158 | |
159 # TODO(crbug.com/395883): ensure those variables are marked as used to | |
160 # avoid errors while running "gn gen". | |
161 assert(!defined(invoker.bundle_extension) || invoker.bundle_extension != "", | |
162 "mark bundle_extension as used") | |
163 assert( | |
164 !defined(invoker.entitlements_path) || invoker.entitlements_path != "", | |
165 "mark entitlements_path as used") | |
166 assert(!defined(invoker.extra_substitutions) || | |
167 invoker.extra_substitutions != [], | |
168 "mark extra_substitutions as used") | |
169 assert(!defined(invoker.info_plist) || invoker.info_plist != "", | |
170 "mark info_plist as used") | |
171 assert( | |
172 !defined(invoker.info_plist_target) || invoker.info_plist_target != "", | |
173 "mark info_plist_target as used") | |
174 assert(!defined(invoker.product_type) || invoker.product_type != "", | |
175 "mark product_type as used") | |
176 } else { | |
177 _generate_info_plist = target_name + "_generate_info_plist" | |
178 _bundle_data_info_plist = target_name + "_bundle_data_info_plist" | |
179 | |
180 ios_info_plist(_generate_info_plist) { | |
181 visibility = [ ":$_bundle_data_info_plist" ] | |
182 executable_name = _output_name | |
183 forward_variables_from(invoker, | |
184 [ | |
185 "extra_substitutions", | |
186 "info_plist", | |
187 "info_plist_target", | |
188 ]) | |
189 } | |
190 | |
191 bundle_data(_bundle_data_info_plist) { | |
157 visibility = [ ":$_target_name" ] | 192 visibility = [ ":$_target_name" ] |
158 } else { | |
159 visibility = [ ":$_bundle_data_executable" ] | |
160 } | |
161 forward_variables_from(invoker, | |
162 "*", | |
163 [ | |
164 "bundle_extension", | |
165 "data_deps", | |
166 "entitlements_path", | |
167 "info_plist", | |
168 "info_plist_target", | |
169 "output_name", | |
170 "product_type", | |
171 "visibility", | |
172 ]) | |
173 | |
174 output_name = rebase_path("$target_gen_dir/$_output_name", root_out_dir) | |
175 output_prefix_override = true | |
176 | |
177 if (!defined(libs)) { | |
178 libs = [] | |
179 } | |
180 libs += [ "UIKit.framework" ] | |
181 if (!defined(ldflags)) { | |
182 ldflags = [] | |
183 } | |
184 ldflags += [ "-ObjC" ] | |
185 } | |
186 | |
187 if (!ios_enable_code_signing) { | |
188 bundle_data(_bundle_data_executable) { | |
189 forward_variables_from(invoker, [ "testonly" ]) | 193 forward_variables_from(invoker, [ "testonly" ]) |
190 visibility = [ ":$_target_name" ] | 194 sources = get_target_outputs(":$_generate_info_plist") |
191 sources = [ | |
192 "$target_gen_dir/$_output_name", | |
193 ] | |
194 outputs = [ | 195 outputs = [ |
195 "{{bundle_executable_dir}}/$_output_name", | 196 "{{bundle_root_dir}}/Info.plist", |
196 ] | 197 ] |
197 public_deps = [ | 198 public_deps = [ |
198 ":$_generate_executable", | 199 ":$_generate_info_plist", |
199 ] | 200 ] |
200 } | 201 } |
201 } | 202 |
202 | 203 _link_executable = _target_name + "_link_executable" |
203 create_bundle(target_name) { | 204 _executable_path = "$target_gen_dir/$_output_name" |
204 forward_variables_from(invoker, | 205 |
205 [ | |
206 "data_deps", | |
207 "deps", | |
208 "public_deps", | |
209 "testonly", | |
210 "visibility", | |
211 ]) | |
212 | |
213 if (!defined(deps)) { | |
214 deps = [] | |
215 } | |
216 deps += [ ":$_bundle_data_info_plist" ] | |
217 if (ios_enable_code_signing) { | 206 if (ios_enable_code_signing) { |
218 deps += [ ":$_generate_executable" ] | 207 _link_executable_visibility = [ ":$_target_name" ] |
219 } else { | 208 } else { |
220 deps += [ ":$_bundle_data_executable" ] | 209 _bundle_data_executable = target_name + "_bundle_data_executable" |
221 } | 210 _link_executable_visibility = [ ":$_bundle_data_executable" ] |
222 | 211 } |
223 if (use_ios_simulator) { | 212 |
224 if (!defined(data_deps)) { | 213 if (_is_fat_build) { |
225 data_deps = [] | 214 _lipo_executable = _target_name + "_lipo_executable" |
226 } | 215 _lipo_executable_visibility = _link_executable_visibility |
227 data_deps += [ "//testing/iossim" ] | 216 |
228 } | 217 _link_executable_visibility = [] |
229 | 218 _link_executable_visibility = [ ":$_lipo_executable" ] |
230 if (defined(invoker.product_type)) { | 219 |
231 product_type = invoker.product_type | 220 _arch_executable_path = "$target_gen_dir/$current_cpu/$_output_name" |
232 } else { | 221 } |
233 product_type = "com.apple.product-type.application" | 222 |
234 } | 223 executable(_link_executable) { |
235 | 224 forward_variables_from(invoker, |
236 if (defined(invoker.bundle_extension)) { | 225 "*", |
237 _bundle_extension = invoker.bundle_extension | 226 [ |
238 } else { | 227 "bundle_extension", |
239 _bundle_extension = ".app" | 228 "data_deps", |
240 } | 229 "entitlements_path", |
241 | 230 "extra_substitutions", |
242 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" | 231 "info_plist", |
243 bundle_resources_dir = bundle_root_dir | 232 "info_plist_target", |
244 bundle_executable_dir = bundle_root_dir | 233 "output_name", |
245 bundle_plugins_dir = "$bundle_root_dir/PlugIns" | 234 "product_type", |
246 | 235 "visibility", |
247 if (defined(invoker.entitlements_path)) { | 236 ]) |
248 _entitlements_path = invoker.entitlements_path | 237 |
249 } else { | 238 visibility = _link_executable_visibility |
250 _entitlements_path = "$ios_sdk_path/Entitlements.plist" | 239 |
251 } | 240 output_prefix_override = true |
252 | 241 if (_is_fat_build) { |
253 if (ios_enable_code_signing) { | 242 output_name = rebase_path(_arch_executable_path, root_build_dir) |
254 code_signing_script = "//build/config/ios/codesign.py" | 243 } else { |
255 code_signing_sources = [ | 244 output_name = rebase_path(_executable_path, root_build_dir) |
256 _entitlements_path, | 245 } |
257 "$target_gen_dir/$_output_name", | 246 |
258 ] | 247 if (!defined(libs)) { |
259 code_signing_outputs = [ | 248 libs = [] |
260 "$bundle_root_dir/$_output_name", | 249 } |
261 "$bundle_root_dir/_CodeSignature/CodeResources", | 250 libs += [ "UIKit.framework" ] |
262 "$bundle_root_dir/embedded.mobileprovision", | 251 if (!defined(ldflags)) { |
263 ] | 252 ldflags = [] |
264 code_signing_args = [ | 253 } |
265 "-i=" + ios_code_signing_identity, | 254 ldflags += [ "-ObjC" ] |
266 "-b=" + rebase_path("$target_gen_dir/$_output_name", root_build_dir), | 255 } |
267 "-e=" + rebase_path(_entitlements_path, root_build_dir), | 256 |
268 rebase_path(bundle_root_dir, root_build_dir), | 257 if (_is_fat_build) { |
Robert Sesek
2016/07/07 17:27:09
How many times is lipo going to get run? I'd think
| |
269 ] | 258 action(_lipo_executable) { |
270 } else { | 259 forward_variables_from(invoker, [ "testonly" ]) |
271 assert(_entitlements_path != "", | 260 visibility = _lipo_executable_visibility |
272 "force usage of _entitlements_path to avoid unused variable error") | 261 script = "//build/config/mac/xcrun.py" |
262 outputs = [ | |
263 _executable_path, | |
264 ] | |
265 inputs = [ | |
266 _arch_executable_path, | |
267 ] | |
268 deps = [ | |
269 ":$_link_executable", | |
270 ] | |
271 foreach(_toolchain, multi_arch_toolchains) { | |
272 if (_toolchain != current_toolchain) { | |
273 _toolchain_target = "$_target_name($_toolchain)" | |
274 deps += [ ":$_toolchain_target" ] | |
275 inputs += [ get_label_info(_toolchain_target, "root_out_dir") + | |
276 "/$_output_name" ] | |
277 } | |
278 } | |
279 args = [ | |
280 "lipo", | |
281 "-create", | |
282 "-output", | |
283 rebase_path(outputs[0], root_build_dir), | |
284 ] + rebase_path(inputs, root_build_dir) | |
285 } | |
286 } | |
287 | |
288 if (!ios_enable_code_signing) { | |
289 bundle_data(_bundle_data_executable) { | |
290 forward_variables_from(invoker, [ "testonly" ]) | |
291 visibility = [ ":$_target_name" ] | |
292 outputs = [ | |
293 "{{bundle_executable_dir}}/$_output_name", | |
294 ] | |
295 if (_is_fat_build) { | |
296 public_deps = [ | |
297 ":$_lipo_executable", | |
298 ] | |
299 } else { | |
300 public_deps = [ | |
301 ":$_link_executable", | |
302 ] | |
303 } | |
304 sources = [ | |
305 "$target_gen_dir/$_output_name", | |
306 ] | |
307 } | |
308 } | |
309 | |
310 create_bundle(target_name) { | |
311 forward_variables_from(invoker, | |
312 [ | |
313 "data_deps", | |
314 "deps", | |
315 "public_deps", | |
316 "testonly", | |
317 "visibility", | |
318 ]) | |
319 | |
320 if (!defined(deps)) { | |
321 deps = [] | |
322 } | |
323 deps += [ ":$_bundle_data_info_plist" ] | |
324 if (ios_enable_code_signing) { | |
325 if (_is_fat_build) { | |
326 deps += [ ":$_lipo_executable" ] | |
327 } else { | |
328 deps += [ ":$_link_executable" ] | |
329 } | |
330 } else { | |
331 deps += [ ":$_bundle_data_executable" ] | |
332 } | |
333 | |
334 if (use_ios_simulator) { | |
335 if (!defined(data_deps)) { | |
336 data_deps = [] | |
337 } | |
338 data_deps += [ "//testing/iossim" ] | |
339 } | |
340 | |
341 if (defined(invoker.product_type)) { | |
342 product_type = invoker.product_type | |
343 } else { | |
344 product_type = "com.apple.product-type.application" | |
345 } | |
346 | |
347 if (defined(invoker.bundle_extension)) { | |
348 _bundle_extension = invoker.bundle_extension | |
349 } else { | |
350 _bundle_extension = ".app" | |
351 } | |
352 | |
353 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension" | |
354 bundle_resources_dir = bundle_root_dir | |
355 bundle_executable_dir = bundle_root_dir | |
356 bundle_plugins_dir = "$bundle_root_dir/PlugIns" | |
357 | |
358 if (defined(invoker.entitlements_path)) { | |
359 _entitlements_path = invoker.entitlements_path | |
360 } else { | |
361 _entitlements_path = "$ios_sdk_path/Entitlements.plist" | |
362 } | |
363 | |
364 if (ios_enable_code_signing) { | |
365 code_signing_script = "//build/config/ios/codesign.py" | |
366 code_signing_sources = [ | |
367 _entitlements_path, | |
368 "$target_gen_dir/$_output_name", | |
369 ] | |
370 code_signing_outputs = [ | |
371 "$bundle_root_dir/$_output_name", | |
372 "$bundle_root_dir/_CodeSignature/CodeResources", | |
373 "$bundle_root_dir/embedded.mobileprovision", | |
374 ] | |
375 code_signing_args = [ | |
376 "-i=" + ios_code_signing_identity, | |
377 "-b=" + rebase_path("$target_gen_dir/$_output_name", root_build_dir), | |
378 "-e=" + rebase_path(_entitlements_path, root_build_dir), | |
379 rebase_path(bundle_root_dir, root_build_dir), | |
380 ] | |
381 } else { | |
382 assert( | |
383 _entitlements_path != "", | |
384 "force usage of _entitlements_path to avoid unused variable error") | |
385 } | |
273 } | 386 } |
274 } | 387 } |
275 } | 388 } |
276 | 389 |
277 # Template to build an application extension bundle for iOS. | 390 # Template to build an application extension bundle for iOS. |
278 # | 391 # |
279 # This should be used instead of "executable" built-in target type on iOS. | 392 # This should be used instead of "executable" built-in target type on iOS. |
280 # As the template forward the generation of the application executable to | 393 # As the template forward the generation of the application executable to |
281 # an "executable" target, all arguments supported by "executable" targets | 394 # an "executable" target, all arguments supported by "executable" targets |
282 # are also supported by this template. | 395 # are also supported by this template. |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
561 [ | 674 [ |
562 "testonly", | 675 "testonly", |
563 "visibility", | 676 "visibility", |
564 ]) | 677 ]) |
565 public_deps = [ | 678 public_deps = [ |
566 ":$_framework_target+link", | 679 ":$_framework_target+link", |
567 ] | 680 ] |
568 } | 681 } |
569 } | 682 } |
570 } | 683 } |
OLD | NEW |