Chromium Code Reviews| 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 # _output_name: | |
|
Robert Sesek
2016/04/21 15:36:21
_ prefix is usually for private variables. Call th
Patti Lor
2016/04/22 02:49:55
Done.
| |
| 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._output_name), | |
| 28 "The output_name file must be specified for $target_name") | |
| 29 output_name = invoker._output_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=$output_name", | |
| 47 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", | |
| 48 "-s=PRODUCT_NAME=$output_name", | |
| 49 "-s=VERSION=$chrome_version_full", | |
| 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 # _output_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 assert(defined(invoker.info_plist), | |
|
Robert Sesek
2016/04/21 15:36:21
I think you can rely on the asserts in the base in
Patti Lor
2016/04/22 02:49:55
Done.
| |
| 76 "The Info.plist file must be specified for $target_name") | |
| 77 assert(defined(invoker._output_name), | |
| 78 "The output_name file must be specified for $target_name") | |
| 79 | |
| 80 info_plist(target_name) { | |
| 81 extra_substitutions = [] | |
| 82 if (defined(invoker.extra_substitutions)) { | |
| 83 extra_substitutions = invoker.extra_substitutions | |
| 84 } | |
| 85 extra_substitutions += [ | |
| 86 "MAC_SDK_BUILD=$mac_sdk_build", | |
| 87 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", | |
| 88 ] | |
| 89 plist_templates = [ | |
| 90 "//build/config/mac/BuildInfo.plist", | |
| 91 invoker.info_plist, | |
| 92 ] | |
| 93 forward_variables_from(invoker, [ "_output_name" ]) | |
| 94 } | |
| 95 } | |
| 96 | |
| 97 # This is used as the base template for both iOS and Mac frameworks. | |
| 98 # | |
| 99 # Arguments | |
| 100 # | |
| 12 # output_name: | 101 # output_name: |
| 13 # (optional) string, name of the generated framework without the | 102 # (optional) string, name of the generated framework without the |
| 14 # .framework suffix. If omitted, defaults to target_name. | 103 # .framework suffix. If omitted, defaults to target_name. |
| 15 # | 104 # |
| 16 # framework_version: | 105 # framework_version: |
| 17 # (optional) string, version of the framework. Typically this is a | 106 # (optional) string, version of the framework. Typically this is a |
| 18 # single letter, like "A". If omitted, the Versions/ subdirectory | 107 # single letter, like "A". If omitted, the Versions/ subdirectory |
| 19 # structure will not be created, and build output will go directly | 108 # structure will not be created, and build output will go directly |
| 20 # into the framework subdirectory. | 109 # into the framework subdirectory. |
| 21 # | 110 # |
| 22 # See "gn help shared_library" for more information on arguments supported | 111 # See "gn help shared_library" for more information on arguments supported |
| 23 # by shared library target. | 112 # by shared library target. |
| 24 template("framework_bundle") { | 113 template("framework_bundle") { |
| 25 _target_name = target_name | 114 _target_name = target_name |
| 26 _output_name = target_name | 115 _output_name = target_name |
| 27 if (defined(invoker.output_name)) { | 116 if (defined(invoker.output_name)) { |
| 28 _output_name = invoker.output_name | 117 _output_name = invoker.output_name |
| 29 } | 118 } |
| 30 | 119 |
| 31 # If the framework is unversionned, the final _target_name will be the | 120 # If the framework is unversioned, the final _target_name will be the |
| 32 # create_bundle(_framework_target), otherwise an action with the name | 121 # create_bundle(_framework_target), otherwise an action with the name |
| 33 # _target_name will depends on the the create_bundle() in order to prepare | 122 # _target_name will depends on the the create_bundle() in order to prepare |
| 34 # the versioned directory structure. | 123 # the versioned directory structure. |
| 35 _framework_target = _target_name | 124 _framework_target = _target_name |
| 36 _framework_name = _output_name + ".framework" | 125 _framework_name = _output_name + ".framework" |
| 37 _framework_root_dir = "$root_out_dir/$_framework_name" | 126 _framework_root_dir = "$root_out_dir/$_framework_name" |
| 38 if (defined(invoker.framework_version) && invoker.framework_version != "") { | 127 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
| 39 _framework_version = invoker.framework_version | 128 _framework_version = invoker.framework_version |
| 40 _framework_root_dir += "/Versions/$_framework_version" | 129 _framework_root_dir += "/Versions/$_framework_version" |
| 41 _framework_target = _target_name + "_create_bundle" | 130 _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 | 335 # See "gn help shared_library" for more information on arguments supported |
| 247 # by shared library target. | 336 # by shared library target. |
| 248 template("mac_framework_bundle") { | 337 template("mac_framework_bundle") { |
| 249 assert(defined(invoker.deps), | 338 assert(defined(invoker.deps), |
| 250 "Dependencies must be specified for $target_name") | 339 "Dependencies must be specified for $target_name") |
| 251 assert(defined(invoker.info_plist), | 340 assert(defined(invoker.info_plist), |
| 252 "The Info.plist file must be specified for $target_name") | 341 "The Info.plist file must be specified for $target_name") |
| 253 | 342 |
| 254 _info_plist_target = target_name + "_info_plist" | 343 _info_plist_target = target_name + "_info_plist" |
| 255 | 344 |
| 256 # TODO(rsesek): Process Info.plist variables. | 345 mac_info_plist(_info_plist_target) { |
| 346 _output_name = target_name | |
| 347 if (defined(invoker.output_name)) { | |
| 348 _output_name = invoker.output_name | |
| 349 } | |
| 350 forward_variables_from(invoker, | |
| 351 [ | |
| 352 "info_plist", | |
| 353 "_output_name", | |
| 354 ]) | |
| 355 } | |
| 257 | 356 |
| 258 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 357 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 259 | 358 |
| 260 bundle_data(_info_plist_bundle_data) { | 359 bundle_data(_info_plist_bundle_data) { |
| 261 forward_variables_from(invoker, [ "testonly" ]) | 360 forward_variables_from(invoker, [ "testonly" ]) |
| 262 sources = [ | 361 sources = get_target_outputs(":$_info_plist_target") |
| 263 invoker.info_plist, | |
| 264 ] | |
| 265 outputs = [ | 362 outputs = [ |
| 266 "{{bundle_root_dir}}/Info.plist", | 363 "{{bundle_root_dir}}/Info.plist", |
| 267 ] | 364 ] |
| 365 public_deps = [ | |
| 366 ":$_info_plist_target", | |
| 367 ] | |
| 268 } | 368 } |
| 269 | 369 |
| 270 framework_bundle(target_name) { | 370 framework_bundle(target_name) { |
| 271 forward_variables_from(invoker, "*", [ "info_plist" ]) | 371 forward_variables_from(invoker, "*", [ "info_plist" ]) |
| 272 | 372 |
| 273 if (!defined(deps)) { | 373 if (!defined(deps)) { |
| 274 deps = [] | 374 deps = [] |
| 275 } | 375 } |
| 276 deps += [ ":$_info_plist_bundle_data" ] | 376 deps += [ ":$_info_plist_bundle_data" ] |
| 277 } | 377 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 324 outputs = [ | 424 outputs = [ |
| 325 "{{bundle_executable_dir}}/$_output_name", | 425 "{{bundle_executable_dir}}/$_output_name", |
| 326 ] | 426 ] |
| 327 public_deps = [ | 427 public_deps = [ |
| 328 ":$_executable_target", | 428 ":$_executable_target", |
| 329 ] | 429 ] |
| 330 } | 430 } |
| 331 | 431 |
| 332 _info_plist_target = target_name + "_info_plist" | 432 _info_plist_target = target_name + "_info_plist" |
| 333 | 433 |
| 334 # TODO(rsesek): Process Info.plist variables. | 434 mac_info_plist(_info_plist_target) { |
| 435 forward_variables_from(invoker, | |
| 436 [ | |
| 437 "info_plist", | |
| 438 "_output_name", | |
| 439 ]) | |
| 440 } | |
| 335 | 441 |
| 336 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 442 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 337 | 443 |
| 338 bundle_data(_info_plist_bundle_data) { | 444 bundle_data(_info_plist_bundle_data) { |
| 339 forward_variables_from(invoker, [ "testonly" ]) | 445 forward_variables_from(invoker, [ "testonly" ]) |
| 340 visibility = [ ":$_target_name" ] | 446 visibility = [ ":$_target_name" ] |
| 341 sources = [ | 447 sources = get_target_outputs(":$_info_plist_target") |
| 342 invoker.info_plist, | |
| 343 ] | |
| 344 outputs = [ | 448 outputs = [ |
| 345 "{{bundle_root_dir}}/Info.plist", | 449 "{{bundle_root_dir}}/Info.plist", |
| 346 ] | 450 ] |
| 451 public_deps = [ | |
| 452 ":$_info_plist_target", | |
| 453 ] | |
| 347 } | 454 } |
| 348 | 455 |
| 349 create_bundle(_target_name) { | 456 create_bundle(_target_name) { |
| 350 forward_variables_from(invoker, | 457 forward_variables_from(invoker, |
| 351 [ | 458 [ |
| 352 "data_deps", | 459 "data_deps", |
| 353 "deps", | 460 "deps", |
| 354 "public_deps", | 461 "public_deps", |
| 355 "testonly", | 462 "testonly", |
| 356 ]) | 463 ]) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 423 ]) | 530 ]) |
| 424 if (!defined(deps)) { | 531 if (!defined(deps)) { |
| 425 deps = [] | 532 deps = [] |
| 426 } | 533 } |
| 427 deps += [ ":$_loadable_module_bundle_data" ] | 534 deps += [ ":$_loadable_module_bundle_data" ] |
| 428 | 535 |
| 429 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 536 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
| 430 bundle_executable_dir = "$bundle_root_dir/MacOS" | 537 bundle_executable_dir = "$bundle_root_dir/MacOS" |
| 431 } | 538 } |
| 432 } | 539 } |
| OLD | NEW |