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

Side by Side Diff: build/config/ios/rules.gni

Issue 2023703002: Beginning work on GN build (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Really add //build. Add dart_bootstrap rule. Created 4 years, 6 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
« no previous file with comments | « build/config/ios/ios_sdk.gni ('k') | build/config/linux/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 import("//build/config/mac/base_rules.gni")
6
7 # Generates Info.plist files for Mac apps and frameworks.
8 #
9 # Arguments
10 #
11 # info_plist:
12 # string, the path to an plist file that will be included in the final
13 # Info.plist generated.
14 #
15 # executable_name:
16 # string, name of the generated target used for the product
17 # and executable name as specified in the output Info.plist.
18 #
19 # extra_substitutions:
20 # (optional) string array, 'key=value' pairs for extra fields which are
21 # specified in a source Info.plist template.
22 template("ios_info_plist") {
23 info_plist(target_name) {
24 format = "binary1"
25 extra_substitutions = []
26 if (defined(invoker.extra_substitutions)) {
27 extra_substitutions = invoker.extra_substitutions
28 }
29 extra_substitutions += [
30 "IOS_DEPLOYMENT_TARGET=$ios_deployment_target",
31 "IOS_PLATFORM_BUILD=$ios_platform_build",
32 "IOS_PLATFORM_NAME=$ios_sdk_name",
33 "IOS_PLATFORM_VERSION=$ios_sdk_version",
34 "IOS_SDK_BUILD=$ios_sdk_build",
35 "IOS_SDK_NAME=$ios_sdk_name$ios_sdk_version",
36 "IOS_SUPPORTED_PLATFORM=$ios_sdk_platform",
37 ]
38 plist_templates = [
39 "//build/config/ios/BuildInfo.plist",
40 invoker.info_plist,
41 ]
42 forward_variables_from(invoker,
43 [
44 "executable_name",
45 "output_name",
46 "visibility",
47 ])
48 }
49 }
50
51 # TODO(crbug.com/297668): refactor this template to extract common behaviour
52 # between OS X and iOS bundle generation, then create a generic "app" template
53 # that forward to "executable" on all platform except iOS/OS X.
54
55 # Template to build an application bundle for iOS.
56 #
57 # This should be used instead of "executable" built-in target type on iOS.
58 # As the template forward the generation of the application executable to
59 # an "executable" target, all arguments supported by "executable" targets
60 # are also supported by this template.
61 #
62 # Arguments
63 #
64 # output_name:
65 # (optional) string, name of the generated application, if omitted,
66 # defaults to the target_name.
67 #
68 # extra_substitutions:
69 # (optional) list of string in "key=value" format, each value will
70 # be used as an additional variable substitution rule when generating
71 # the application Info.plist
72 #
73 # info_plist:
74 # path to the template to use to generate the application Info.plist
75 # by performing variable substitutions.
76 #
77 # bundle_extension:
78 # (optional) bundle extension including the dot, default to ".app".
79 #
80 # product_type
81 # (optional) string, product type for the generated Xcode project,
82 # default to "com.apple.product-type.application". Should generally
83 # not be overridden.
84 #
85 # For more information, see "gn help executable".
86 template("ios_app_bundle") {
87 assert(defined(invoker.info_plist),
88 "info_plist must be specified for target $target_name")
89
90 _output_name = target_name
91 _target_name = target_name
92 if (defined(invoker.output_name)) {
93 _output_name = invoker.output_name
94 }
95
96 _generate_info_plist = target_name + "_generate_info_plist"
97 _bundle_data_info_plist = target_name + "_bundle_data_info_plist"
98
99 ios_info_plist(_generate_info_plist) {
100 executable_name = _output_name
101 forward_variables_from(invoker,
102 [
103 "extra_substitutions",
104 "info_plist",
105 ])
106 }
107
108 bundle_data(_bundle_data_info_plist) {
109 forward_variables_from(invoker, [ "testonly" ])
110 visibility = [ ":$_target_name" ]
111 sources = get_target_outputs(":$_generate_info_plist")
112 outputs = [
113 "{{bundle_root_dir}}/Info.plist",
114 ]
115 public_deps = [
116 ":$_generate_info_plist",
117 ]
118 }
119
120 _generate_executable = target_name + "_generate_executable"
121 _bundle_data_executable = target_name + "_bundle_data_executable"
122
123 executable(_generate_executable) {
124 visibility = [ ":$_bundle_data_executable" ]
125 forward_variables_from(invoker,
126 "*",
127 [
128 "assert_no_deps",
129 "bundle_extension",
130 "code_signing_identity",
131 "data_deps",
132 "entitlements_path",
133 "info_plist",
134 "output_name",
135 "product_type",
136 "visibility",
137 ])
138
139 output_name = rebase_path("$target_gen_dir/$_output_name", root_out_dir)
140 if (!defined(libs)) {
141 libs = []
142 }
143 libs += [ "UIKit.framework" ]
144 }
145
146 bundle_data(_bundle_data_executable) {
147 forward_variables_from(invoker, [ "testonly" ])
148 visibility = [ ":$_target_name" ]
149 sources = [
150 "$target_gen_dir/$_output_name",
151 ]
152 outputs = [
153 "{{bundle_executable_dir}}/$_output_name",
154 ]
155 public_deps = [
156 ":$_generate_executable",
157 ]
158 }
159
160 create_bundle(target_name) {
161 forward_variables_from(invoker,
162 [
163 "data_deps",
164 "deps",
165 "public_deps",
166 "testonly",
167 "visibility",
168 ])
169
170 if (!defined(deps)) {
171 deps = []
172 }
173 deps += [
174 ":$_bundle_data_executable",
175 ":$_bundle_data_info_plist",
176 ]
177
178 if (use_ios_simulator) {
179 if (!defined(data_deps)) {
180 data_deps = []
181 }
182 data_deps += [ "//testing/iossim" ]
183 }
184
185 if (defined(invoker.product_type)) {
186 product_type = invoker.product_type
187 } else {
188 product_type = "com.apple.product-type.application"
189 }
190
191 if (defined(invoker.bundle_extension)) {
192 _bundle_extension = invoker.bundle_extension
193 } else {
194 _bundle_extension = ".app"
195 }
196
197 bundle_root_dir = "$root_out_dir/$_output_name$_bundle_extension"
198 bundle_resources_dir = bundle_root_dir
199 bundle_executable_dir = bundle_root_dir
200 bundle_plugins_dir = "$bundle_root_dir/PlugIns"
201 }
202
203 # TODO(crbug.com/297668):
204 # - add support for codesigning,
205 # - find a way to make "ninja -C out/Default base_unittests.app" work as
206 # an alias to "ninja -C out/Default base_unittests" (for convenience
207 # and compatibility with gyp),
208 }
209
210 # Template to build an application extension bundle for iOS.
211 #
212 # This should be used instead of "executable" built-in target type on iOS.
213 # As the template forward the generation of the application executable to
214 # an "executable" target, all arguments supported by "executable" targets
215 # are also supported by this template.
216 #
217 # Arguments
218 #
219 # output_name:
220 # (optional) string, name of the generated application, if omitted,
221 # defaults to the target_name.
222 #
223 # extra_substitutions:
224 # (optional) list of string in "key=value" format, each value will
225 # be used as an additional variable substitution rule when generating
226 # the application Info.plist
227 #
228 # info_plist:
229 # path to the template to use to generate the application Info.plist
230 # by performing variable substitutions.
231 #
232 # For more information, see "gn help executable".
233 template("ios_appex_bundle") {
234 ios_app_bundle(target_name) {
235 forward_variables_from(invoker,
236 "*",
237 [
238 "bundle_extension",
239 "product_type",
240 ])
241 bundle_extension = ".appex"
242 product_type = "com.apple.product-type.app-extension"
243
244 # Add linker flags required for an application extension (determined by
245 # inspecting the link command-line when using Xcode 9.0+).
246 if (!defined(ldflags)) {
247 ldflags = []
248 }
249 ldflags += [
250 "-e",
251 "_NSExtensionMain",
252 "-fapplication-extension",
253 ]
254 }
255 }
256
257 # Compile a xib or storyboard file and add it to a bundle_data so that it is
258 # available at runtime in the bundle.
259 #
260 # Arguments
261 #
262 # source:
263 # string, path of the xib or storyboard to compile.
264 #
265 # Forwards all variables to the bundle_data target.
266 template("bundle_data_xib") {
267 assert(defined(invoker.source), "source needs to be defined for $target_name")
268
269 _source_extension = get_path_info(invoker.source, "extension")
270 assert(_source_extension == "xib" || _source_extension == "storyboard",
271 "source must be a .xib or .storyboard for $target_name")
272
273 _target_name = target_name
274 _compile_xib = target_name + "_compile_xib"
275
276 compile_xibs(_compile_xib) {
277 sources = [
278 invoker.source,
279 ]
280 visibility = [ ":$_target_name" ]
281 ibtool_flags = [
282 "--minimum-deployment-target",
283 ios_deployment_target,
284 "--auto-activate-custom-fonts",
285 "--target-device",
286 "iphone",
287 "--target-device",
288 "ipad",
289 ]
290 }
291
292 bundle_data(_target_name) {
293 forward_variables_from(invoker, "*", [ "source" ])
294
295 if (!defined(public_deps)) {
296 public_deps = []
297 }
298 public_deps += [ ":$_compile_xib" ]
299
300 sources = get_target_outputs(":$_compile_xib")
301
302 outputs = [
303 "{{bundle_resources_dir}}/{{source_file_part}}",
304 ]
305 }
306 }
307
308 # Template to package a shared library into an iOS framework bundle.
309 #
310 # This template provides two targets to control whether the framework is
311 # merely built when targets depend on it, or whether it is linked as well:
312 # "$target_name" and "$target_name+link".
313 #
314 # See the //build/config/mac/base_rules.gni:framework_bundle for a discussion
315 # and examples.
316 #
317 # Arguments
318 #
319 # output_name:
320 # (optional) string, name of the generated framework without the
321 # .framework suffix. If omitted, defaults to target_name.
322 #
323 # framework_version:
324 # (optional) string, version of the framework. Typically this is a
325 # single letter, like "A". If omitted, the Versions/ subdirectory
326 # structure will not be created, and build output will go directly
327 # into the framework subdirectory.
328 #
329 # public_headers:
330 # (optional) list of paths to header file that needs to be copied
331 # into the framework bundle Headers subdirectory. If omitted or
332 # empty then the Headers subdirectory is not created.
333 #
334 # sources
335 # (optional) list of files. Needs to be defined and non-empty if
336 # public_headers is defined and non-empty.
337 #
338 # See "gn help shared_library" for more information on arguments supported
339 # by shared library target.
340 template("ios_framework_bundle") {
341 _target_name = target_name
342 _output_name = target_name
343 if (defined(invoker.output_name)) {
344 _output_name = invoker.output_name
345 }
346 _framework_target = _target_name
347
348 if (defined(invoker.public_headers) && invoker.public_headers != []) {
349 _public_headers = invoker.public_headers
350 _framework_name = _output_name + ".framework"
351 _framework_root = "$root_out_dir/$_framework_name"
352 _framework_target = target_name + "_internal"
353
354 _header_map_filename = "$target_gen_dir/$_output_name.headers.hmap"
355 _framework_headers_target = _target_name + "_framework_headers"
356
357 _compile_headers_map_target = _target_name + "_compile_headers_map"
358 action(_compile_headers_map_target) {
359 visibility = [ ":$_framework_headers_target" ]
360 script = "$root_out_dir/gyp-mac-tool"
361 outputs = [
362 _header_map_filename,
363 ]
364
365 # The header map generation only wants the list of headers, not all of
366 # sources, so filter any non-header source files from "sources". It is
367 # less error prone that having the developer duplicate the list of all
368 # headers in addition to "sources".
369 set_sources_assignment_filter([
370 "*.c",
371 "*.cc",
372 "*.cpp",
373 "*.m",
374 "*.mm",
375 ])
376 sources = invoker.sources
377 set_sources_assignment_filter([])
378
379 args = [
380 "compile-ios-framework-header-map",
381 rebase_path(_header_map_filename),
382 rebase_path(_framework_root, root_out_dir),
383 ] + rebase_path(sources, root_out_dir)
384 }
385
386 _create_module_map_target = _target_name + "_module_map"
387 action(_create_module_map_target) {
388 visibility = [ ":$_framework_headers_target" ]
389 script = "$root_out_dir/gyp-mac-tool"
390 outputs = [
391 "$_framework_root/Modules/module.modulemap",
392 ]
393 args = [
394 "package-ios-framework",
395 rebase_path("$_framework_root", root_out_dir),
396 ]
397 }
398
399 _copy_public_headers_target = _target_name + "_copy_public_headers"
400 copy(_copy_public_headers_target) {
401 visibility = [ ":$_framework_headers_target" ]
402 sources = _public_headers
403 outputs = [
404 "$_framework_root/Headers/{{source_file_part}}",
405 ]
406 }
407
408 _headers_map_config = _target_name + "_headers_map"
409 config(_headers_map_config) {
410 visibility = [ ":$_target_name" ]
411 include_dirs = [ _header_map_filename ]
412 ldflags = [
413 "-install_name",
414 "@rpath/$_framework_name/$_output_name",
415 ]
416 }
417
418 group(_framework_headers_target) {
419 deps = [
420 ":$_compile_headers_map_target",
421 ":$_copy_public_headers_target",
422 ":$_create_module_map_target",
423 ]
424 }
425 }
426
427 _framework_public_config = _target_name + "_ios_public_config"
428 config(_framework_public_config) {
429 visibility = [ ":$_framework_public_config" ]
430 if (defined(_public_headers)) {
431 common_flags = [ "-F" + rebase_path("$root_out_dir/.", root_out_dir) ]
432 cflags_objc = common_flags
433 cflags_objcc = common_flags
434 }
435
436 # The link settings are inherited from the framework_bundle config.
437 }
438
439 framework_bundle(_framework_target) {
440 forward_variables_from(invoker,
441 "*",
442 [
443 "output_name",
444 "public_headers",
445 "visibility",
446 ])
447 output_name = _output_name
448
449 if (!defined(public_configs)) {
450 public_configs = []
451 }
452 public_configs += [ ":$_framework_public_config" ]
453
454 if (defined(_public_headers)) {
455 visibility = [
456 ":$_target_name",
457 ":$_target_name+link",
458 ]
459 configs += [ ":$_headers_map_config" ]
460
461 if (!defined(deps)) {
462 deps = []
463 }
464 deps += [ ":$_framework_headers_target" ]
465 } else {
466 if (defined(invoker.visibility)) {
467 visibility = invoker.visibility
468 visibility += [ ":$_target_name+link" ]
469 }
470 }
471 }
472
473 if (defined(_public_headers)) {
474 group(_target_name) {
475 forward_variables_from(invoker,
476 [
477 "testonly",
478 "public_configs",
479 ])
480
481 if (defined(invoker.visibility)) {
482 visibility = invoker.visibility
483 visibility += [ ":$_target_name+link" ]
484 }
485
486 public_deps = [
487 ":$_framework_target",
488 ]
489 }
490
491 group(_target_name + "+link") {
492 forward_variables_from(invoker,
493 [
494 "testonly",
495 "visibility",
496 ])
497 public_deps = [
498 ":$_framework_target+link",
499 ]
500 }
501 }
502 }
OLDNEW
« no previous file with comments | « build/config/ios/ios_sdk.gni ('k') | build/config/linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698