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/toolchain/toolchain.gni") | 5 import("//build/toolchain/toolchain.gni") |
6 import("//build/config/mac/mac_sdk.gni") | 6 import("//build/config/mac/mac_sdk.gni") |
7 import("//build/util/version.gni") | |
7 | 8 |
8 # This is used as the base template for both iOS and Mac frameworks.. | 9 # The base template used to generate Info.plist files for iOS and Mac apps and |
10 # frameworks. | |
9 # | 11 # |
10 # Arguments | 12 # Arguments |
11 # | 13 # |
14 # plist_templates: | |
15 # string array, paths to plist files which will be used for the bundle. | |
16 # | |
17 # executable_name: | |
18 # string, name of the generated target used for the product | |
19 # and executable name as specified in the output Info.plist. | |
20 # | |
21 # extra_substitutions: | |
22 # (optional) string array, 'key=value' pairs for extra fields which are | |
23 # specified in a source Info.plist template. | |
24 template("info_plist") { | |
25 assert(defined(invoker.plist_templates), | |
26 "A list of template plist files must be specified for $target_name") | |
27 assert(defined(invoker.executable_name), | |
28 "The output_name file must be specified for $target_name") | |
Robert Sesek
2016/04/22 04:34:40
"output_name file" -> "executable_name"
Patti Lor
2016/04/26 03:25:15
Done.
| |
29 executable_name = invoker.executable_name | |
30 | |
31 action(target_name) { | |
32 script = "//build/config/mac/gen_plist.py" | |
33 sources = invoker.plist_templates | |
34 outputs = [ | |
35 "$target_gen_dir/$target_name.plist", | |
36 ] | |
37 extra_args = [] | |
38 if (defined(invoker.extra_substitutions)) { | |
39 foreach(substitution, invoker.extra_substitutions) { | |
40 extra_args += [ "-s=$substitution" ] | |
41 } | |
42 } | |
43 response_file_contents = | |
44 extra_args + [ | |
45 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", | |
46 "-s=EXECUTABLE_NAME=$executable_name", | |
47 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", | |
48 "-s=PRODUCT_NAME=$executable_name", | |
49 "-s=VERSION=$chrome_version_full", | |
Robert Sesek
2016/04/22 04:34:40
Remove VERSION and VERSION_BUILD from the template
Patti Lor
2016/04/26 03:25:15
Done.
| |
50 "-s=VERSION_BUILD=$chrome_version_build", | |
51 "-s=XCODE_BUILD=$xcode_build", | |
52 "-s=XCODE_VERSION=$xcode_version", | |
53 "-o=" + rebase_path(outputs[0], root_build_dir), | |
54 ] + rebase_path(sources, root_build_dir) | |
55 args = [ "@{{response_file_name}}" ] | |
56 } | |
57 } | |
58 | |
59 # Generates Info.plist files for Mac apps and frameworks. | |
60 # | |
61 # Arguments | |
62 # | |
63 # info_plist: | |
64 # string, the path to an plist file that will be included in the final | |
65 # Info.plist generated. | |
66 # | |
67 # executable_name: | |
68 # string, name of the generated target used for the product | |
69 # and executable name as specified in the output Info.plist. | |
70 # | |
71 # extra_substitutions: | |
72 # (optional) string array, 'key=value' pairs for extra fields which are | |
73 # specified in a source Info.plist template. | |
74 template("mac_info_plist") { | |
75 info_plist(target_name) { | |
76 extra_substitutions = [] | |
77 if (defined(invoker.extra_substitutions)) { | |
78 extra_substitutions = invoker.extra_substitutions | |
79 } | |
80 extra_substitutions += [ | |
81 "MAC_SDK_BUILD=$mac_sdk_build", | |
82 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", | |
83 ] | |
84 plist_templates = [ | |
85 "//build/config/mac/BuildInfo.plist", | |
86 invoker.info_plist, | |
87 ] | |
88 forward_variables_from(invoker, [ "executable_name" ]) | |
89 } | |
90 } | |
91 | |
92 # This is used as the base template for both iOS and Mac frameworks. | |
93 # | |
94 # Arguments | |
95 # | |
12 # output_name: | 96 # output_name: |
13 # (optional) string, name of the generated framework without the | 97 # (optional) string, name of the generated framework without the |
14 # .framework suffix. If omitted, defaults to target_name. | 98 # .framework suffix. If omitted, defaults to target_name. |
15 # | 99 # |
16 # framework_version: | 100 # framework_version: |
17 # (optional) string, version of the framework. Typically this is a | 101 # (optional) string, version of the framework. Typically this is a |
18 # single letter, like "A". If omitted, the Versions/ subdirectory | 102 # single letter, like "A". If omitted, the Versions/ subdirectory |
19 # structure will not be created, and build output will go directly | 103 # structure will not be created, and build output will go directly |
20 # into the framework subdirectory. | 104 # into the framework subdirectory. |
21 # | 105 # |
22 # See "gn help shared_library" for more information on arguments supported | 106 # See "gn help shared_library" for more information on arguments supported |
23 # by shared library target. | 107 # by shared library target. |
24 template("framework_bundle") { | 108 template("framework_bundle") { |
25 _target_name = target_name | 109 _target_name = target_name |
26 _output_name = target_name | 110 _output_name = target_name |
27 if (defined(invoker.output_name)) { | 111 if (defined(invoker.output_name)) { |
28 _output_name = invoker.output_name | 112 _output_name = invoker.output_name |
29 } | 113 } |
30 | 114 |
31 # If the framework is unversionned, the final _target_name will be the | 115 # If the framework is unversioned, the final _target_name will be the |
32 # create_bundle(_framework_target), otherwise an action with the name | 116 # create_bundle(_framework_target), otherwise an action with the name |
33 # _target_name will depends on the the create_bundle() in order to prepare | 117 # _target_name will depends on the the create_bundle() in order to prepare |
34 # the versioned directory structure. | 118 # the versioned directory structure. |
35 _framework_target = _target_name | 119 _framework_target = _target_name |
36 _framework_name = _output_name + ".framework" | 120 _framework_name = _output_name + ".framework" |
37 _framework_root_dir = "$root_out_dir/$_framework_name" | 121 _framework_root_dir = "$root_out_dir/$_framework_name" |
38 if (defined(invoker.framework_version) && invoker.framework_version != "") { | 122 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
39 _framework_version = invoker.framework_version | 123 _framework_version = invoker.framework_version |
40 _framework_root_dir += "/Versions/$_framework_version" | 124 _framework_root_dir += "/Versions/$_framework_version" |
41 _framework_target = _target_name + "_create_bundle" | 125 _framework_target = _target_name + "_create_bundle" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 # See "gn help shared_library" for more information on arguments supported | 330 # See "gn help shared_library" for more information on arguments supported |
247 # by shared library target. | 331 # by shared library target. |
248 template("mac_framework_bundle") { | 332 template("mac_framework_bundle") { |
249 assert(defined(invoker.deps), | 333 assert(defined(invoker.deps), |
250 "Dependencies must be specified for $target_name") | 334 "Dependencies must be specified for $target_name") |
251 assert(defined(invoker.info_plist), | 335 assert(defined(invoker.info_plist), |
252 "The Info.plist file must be specified for $target_name") | 336 "The Info.plist file must be specified for $target_name") |
253 | 337 |
254 _info_plist_target = target_name + "_info_plist" | 338 _info_plist_target = target_name + "_info_plist" |
255 | 339 |
256 # TODO(rsesek): Process Info.plist variables. | 340 mac_info_plist(_info_plist_target) { |
341 executable_name = target_name | |
342 if (defined(invoker.output_name)) { | |
343 executable_name = invoker.output_name | |
344 } | |
345 forward_variables_from(invoker, [ "info_plist" ]) | |
346 } | |
257 | 347 |
258 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 348 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
259 | 349 |
260 bundle_data(_info_plist_bundle_data) { | 350 bundle_data(_info_plist_bundle_data) { |
261 forward_variables_from(invoker, [ "testonly" ]) | 351 forward_variables_from(invoker, [ "testonly" ]) |
262 sources = [ | 352 sources = get_target_outputs(":$_info_plist_target") |
263 invoker.info_plist, | |
264 ] | |
265 outputs = [ | 353 outputs = [ |
266 "{{bundle_root_dir}}/Info.plist", | 354 "{{bundle_root_dir}}/Info.plist", |
267 ] | 355 ] |
356 public_deps = [ | |
357 ":$_info_plist_target", | |
358 ] | |
268 } | 359 } |
269 | 360 |
270 framework_bundle(target_name) { | 361 framework_bundle(target_name) { |
271 forward_variables_from(invoker, "*", [ "info_plist" ]) | 362 forward_variables_from(invoker, "*", [ "info_plist" ]) |
272 | 363 |
273 if (!defined(deps)) { | 364 if (!defined(deps)) { |
274 deps = [] | 365 deps = [] |
275 } | 366 } |
276 deps += [ ":$_info_plist_bundle_data" ] | 367 deps += [ ":$_info_plist_bundle_data" ] |
277 } | 368 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 outputs = [ | 415 outputs = [ |
325 "{{bundle_executable_dir}}/$_output_name", | 416 "{{bundle_executable_dir}}/$_output_name", |
326 ] | 417 ] |
327 public_deps = [ | 418 public_deps = [ |
328 ":$_executable_target", | 419 ":$_executable_target", |
329 ] | 420 ] |
330 } | 421 } |
331 | 422 |
332 _info_plist_target = target_name + "_info_plist" | 423 _info_plist_target = target_name + "_info_plist" |
333 | 424 |
334 # TODO(rsesek): Process Info.plist variables. | 425 mac_info_plist(_info_plist_target) { |
426 executable_name = _output_name | |
427 forward_variables_from(invoker, [ "info_plist" ]) | |
428 } | |
335 | 429 |
336 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 430 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
337 | 431 |
338 bundle_data(_info_plist_bundle_data) { | 432 bundle_data(_info_plist_bundle_data) { |
339 forward_variables_from(invoker, [ "testonly" ]) | 433 forward_variables_from(invoker, [ "testonly" ]) |
340 visibility = [ ":$_target_name" ] | 434 visibility = [ ":$_target_name" ] |
341 sources = [ | 435 sources = get_target_outputs(":$_info_plist_target") |
342 invoker.info_plist, | |
343 ] | |
344 outputs = [ | 436 outputs = [ |
345 "{{bundle_root_dir}}/Info.plist", | 437 "{{bundle_root_dir}}/Info.plist", |
346 ] | 438 ] |
439 public_deps = [ | |
440 ":$_info_plist_target", | |
441 ] | |
347 } | 442 } |
348 | 443 |
349 create_bundle(_target_name) { | 444 create_bundle(_target_name) { |
350 forward_variables_from(invoker, | 445 forward_variables_from(invoker, |
351 [ | 446 [ |
352 "data_deps", | 447 "data_deps", |
353 "deps", | 448 "deps", |
354 "public_deps", | 449 "public_deps", |
355 "testonly", | 450 "testonly", |
356 ]) | 451 ]) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 ]) | 518 ]) |
424 if (!defined(deps)) { | 519 if (!defined(deps)) { |
425 deps = [] | 520 deps = [] |
426 } | 521 } |
427 deps += [ ":$_loadable_module_bundle_data" ] | 522 deps += [ ":$_loadable_module_bundle_data" ] |
428 | 523 |
429 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 524 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
430 bundle_executable_dir = "$bundle_root_dir/MacOS" | 525 bundle_executable_dir = "$bundle_root_dir/MacOS" |
431 } | 526 } |
432 } | 527 } |
OLD | NEW |