| 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 | 7 |
| 8 # This is used as the base template for both iOS and Mac frameworks.. | 8 # The base template used to generate Info.plist files for iOS and Mac apps and |
| 9 # frameworks. |
| 10 # |
| 11 # Arguments |
| 12 # |
| 13 # plist_templates: |
| 14 # string array, paths to plist files which will be used for the bundle. |
| 15 # |
| 16 # executable_name: |
| 17 # string, name of the generated target used for the product |
| 18 # and executable name as specified in the output Info.plist. |
| 19 # |
| 20 # extra_substitutions: |
| 21 # (optional) string array, 'key=value' pairs for extra fields which are |
| 22 # specified in a source Info.plist template. |
| 23 template("info_plist") { |
| 24 assert(defined(invoker.plist_templates), |
| 25 "A list of template plist files must be specified for $target_name") |
| 26 assert(defined(invoker.executable_name), |
| 27 "The executable_name must be specified for $target_name") |
| 28 executable_name = invoker.executable_name |
| 29 |
| 30 action(target_name) { |
| 31 script = "//build/config/mac/gen_plist.py" |
| 32 sources = invoker.plist_templates |
| 33 outputs = [ |
| 34 "$target_gen_dir/$target_name.plist", |
| 35 ] |
| 36 extra_args = [] |
| 37 if (defined(invoker.extra_substitutions)) { |
| 38 foreach(substitution, invoker.extra_substitutions) { |
| 39 extra_args += [ "-s=$substitution" ] |
| 40 } |
| 41 } |
| 42 response_file_contents = |
| 43 extra_args + [ |
| 44 "-s=BUILD_MACHINE_OS_BUILD=$machine_os_build", |
| 45 "-s=EXECUTABLE_NAME=$executable_name", |
| 46 "-s=GCC_VERSION=com.apple.compilers.llvm.clang.1_0", |
| 47 "-s=PRODUCT_NAME=$executable_name", |
| 48 "-s=XCODE_BUILD=$xcode_build", |
| 49 "-s=XCODE_VERSION=$xcode_version", |
| 50 "-o=" + rebase_path(outputs[0], root_build_dir), |
| 51 ] + rebase_path(sources, root_build_dir) |
| 52 args = [ "@{{response_file_name}}" ] |
| 53 } |
| 54 } |
| 55 |
| 56 # Generates Info.plist files for Mac apps and frameworks. |
| 57 # |
| 58 # Arguments |
| 59 # |
| 60 # info_plist: |
| 61 # string, the path to an plist file that will be included in the final |
| 62 # Info.plist generated. |
| 63 # |
| 64 # executable_name: |
| 65 # string, name of the generated target used for the product |
| 66 # and executable name as specified in the output Info.plist. |
| 67 # |
| 68 # extra_substitutions: |
| 69 # (optional) string array, 'key=value' pairs for extra fields which are |
| 70 # specified in a source Info.plist template. |
| 71 template("mac_info_plist") { |
| 72 info_plist(target_name) { |
| 73 extra_substitutions = [] |
| 74 if (defined(invoker.extra_substitutions)) { |
| 75 extra_substitutions = invoker.extra_substitutions |
| 76 } |
| 77 extra_substitutions += [ |
| 78 "MAC_SDK_BUILD=$mac_sdk_build", |
| 79 "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", |
| 80 ] |
| 81 plist_templates = [ |
| 82 "//build/config/mac/BuildInfo.plist", |
| 83 invoker.info_plist, |
| 84 ] |
| 85 forward_variables_from(invoker, [ "executable_name" ]) |
| 86 } |
| 87 } |
| 88 |
| 89 # This is used as the base template for both iOS and Mac frameworks. |
| 9 # | 90 # |
| 10 # By default, the bundle target this template generates does not link the | 91 # By default, the bundle target this template generates does not link the |
| 11 # resulting framework into anything that depends on it. If a dependency wants | 92 # resulting framework into anything that depends on it. If a dependency wants |
| 12 # a link-time (as well as build-time) dependency on the framework bundle, | 93 # a link-time (as well as build-time) dependency on the framework bundle, |
| 13 # depend against "$target_name+link". If only the build-time dependency is | 94 # depend against "$target_name+link". If only the build-time dependency is |
| 14 # required (e.g., for copying into another bundle), then use "$target_name". | 95 # required (e.g., for copying into another bundle), then use "$target_name". |
| 15 # | 96 # |
| 16 # Arguments | 97 # Arguments |
| 17 # | 98 # |
| 18 # output_name: | 99 # output_name: |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 # | 172 # |
| 92 # See "gn help shared_library" for more information on arguments supported | 173 # See "gn help shared_library" for more information on arguments supported |
| 93 # by shared library target. | 174 # by shared library target. |
| 94 template("framework_bundle") { | 175 template("framework_bundle") { |
| 95 _target_name = target_name | 176 _target_name = target_name |
| 96 _output_name = target_name | 177 _output_name = target_name |
| 97 if (defined(invoker.output_name)) { | 178 if (defined(invoker.output_name)) { |
| 98 _output_name = invoker.output_name | 179 _output_name = invoker.output_name |
| 99 } | 180 } |
| 100 | 181 |
| 101 # If the framework is unversionned, the final _target_name will be the | 182 # If the framework is unversioned, the final _target_name will be the |
| 102 # create_bundle(_framework_target), otherwise an action with the name | 183 # create_bundle(_framework_target), otherwise an action with the name |
| 103 # _target_name will depends on the the create_bundle() in order to prepare | 184 # _target_name will depends on the the create_bundle() in order to prepare |
| 104 # the versioned directory structure. | 185 # the versioned directory structure. |
| 105 _framework_target = _target_name | 186 _framework_target = _target_name |
| 106 _framework_name = _output_name + ".framework" | 187 _framework_name = _output_name + ".framework" |
| 107 _framework_root_dir = "$root_out_dir/$_framework_name" | 188 _framework_root_dir = "$root_out_dir/$_framework_name" |
| 108 if (defined(invoker.framework_version) && invoker.framework_version != "") { | 189 if (defined(invoker.framework_version) && invoker.framework_version != "") { |
| 109 _framework_version = invoker.framework_version | 190 _framework_version = invoker.framework_version |
| 110 _framework_root_dir += "/Versions/$_framework_version" | 191 _framework_root_dir += "/Versions/$_framework_version" |
| 111 _framework_target = _target_name + "_create_bundle" | 192 _framework_target = _target_name + "_create_bundle" |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 # See "gn help shared_library" for more information on arguments supported | 416 # See "gn help shared_library" for more information on arguments supported |
| 336 # by shared library target. | 417 # by shared library target. |
| 337 template("mac_framework_bundle") { | 418 template("mac_framework_bundle") { |
| 338 assert(defined(invoker.deps), | 419 assert(defined(invoker.deps), |
| 339 "Dependencies must be specified for $target_name") | 420 "Dependencies must be specified for $target_name") |
| 340 assert(defined(invoker.info_plist), | 421 assert(defined(invoker.info_plist), |
| 341 "The Info.plist file must be specified for $target_name") | 422 "The Info.plist file must be specified for $target_name") |
| 342 | 423 |
| 343 _info_plist_target = target_name + "_info_plist" | 424 _info_plist_target = target_name + "_info_plist" |
| 344 | 425 |
| 345 # TODO(rsesek): Process Info.plist variables. | 426 mac_info_plist(_info_plist_target) { |
| 427 executable_name = target_name |
| 428 if (defined(invoker.output_name)) { |
| 429 executable_name = invoker.output_name |
| 430 } |
| 431 forward_variables_from(invoker, [ "info_plist" ]) |
| 432 } |
| 346 | 433 |
| 347 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 434 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 348 | 435 |
| 349 bundle_data(_info_plist_bundle_data) { | 436 bundle_data(_info_plist_bundle_data) { |
| 350 forward_variables_from(invoker, [ "testonly" ]) | 437 forward_variables_from(invoker, [ "testonly" ]) |
| 351 sources = [ | 438 sources = get_target_outputs(":$_info_plist_target") |
| 352 invoker.info_plist, | |
| 353 ] | |
| 354 outputs = [ | 439 outputs = [ |
| 355 "{{bundle_root_dir}}/Info.plist", | 440 "{{bundle_root_dir}}/Info.plist", |
| 356 ] | 441 ] |
| 442 public_deps = [ |
| 443 ":$_info_plist_target", |
| 444 ] |
| 357 } | 445 } |
| 358 | 446 |
| 359 framework_bundle(target_name) { | 447 framework_bundle(target_name) { |
| 360 forward_variables_from(invoker, "*", [ "info_plist" ]) | 448 forward_variables_from(invoker, "*", [ "info_plist" ]) |
| 361 | 449 |
| 362 if (!defined(deps)) { | 450 if (!defined(deps)) { |
| 363 deps = [] | 451 deps = [] |
| 364 } | 452 } |
| 365 deps += [ ":$_info_plist_bundle_data" ] | 453 deps += [ ":$_info_plist_bundle_data" ] |
| 366 } | 454 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 outputs = [ | 501 outputs = [ |
| 414 "{{bundle_executable_dir}}/$_output_name", | 502 "{{bundle_executable_dir}}/$_output_name", |
| 415 ] | 503 ] |
| 416 public_deps = [ | 504 public_deps = [ |
| 417 ":$_executable_target", | 505 ":$_executable_target", |
| 418 ] | 506 ] |
| 419 } | 507 } |
| 420 | 508 |
| 421 _info_plist_target = target_name + "_info_plist" | 509 _info_plist_target = target_name + "_info_plist" |
| 422 | 510 |
| 423 # TODO(rsesek): Process Info.plist variables. | 511 mac_info_plist(_info_plist_target) { |
| 512 executable_name = _output_name |
| 513 forward_variables_from(invoker, [ "info_plist" ]) |
| 514 } |
| 424 | 515 |
| 425 _info_plist_bundle_data = _info_plist_target + "_bundle_data" | 516 _info_plist_bundle_data = _info_plist_target + "_bundle_data" |
| 426 | 517 |
| 427 bundle_data(_info_plist_bundle_data) { | 518 bundle_data(_info_plist_bundle_data) { |
| 428 forward_variables_from(invoker, [ "testonly" ]) | 519 forward_variables_from(invoker, [ "testonly" ]) |
| 429 visibility = [ ":$_target_name" ] | 520 visibility = [ ":$_target_name" ] |
| 430 sources = [ | 521 sources = get_target_outputs(":$_info_plist_target") |
| 431 invoker.info_plist, | |
| 432 ] | |
| 433 outputs = [ | 522 outputs = [ |
| 434 "{{bundle_root_dir}}/Info.plist", | 523 "{{bundle_root_dir}}/Info.plist", |
| 435 ] | 524 ] |
| 525 public_deps = [ |
| 526 ":$_info_plist_target", |
| 527 ] |
| 436 } | 528 } |
| 437 | 529 |
| 438 create_bundle(_target_name) { | 530 create_bundle(_target_name) { |
| 439 forward_variables_from(invoker, | 531 forward_variables_from(invoker, |
| 440 [ | 532 [ |
| 441 "data_deps", | 533 "data_deps", |
| 442 "deps", | 534 "deps", |
| 443 "public_deps", | 535 "public_deps", |
| 444 "testonly", | 536 "testonly", |
| 445 ]) | 537 ]) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 ]) | 604 ]) |
| 513 if (!defined(deps)) { | 605 if (!defined(deps)) { |
| 514 deps = [] | 606 deps = [] |
| 515 } | 607 } |
| 516 deps += [ ":$_loadable_module_bundle_data" ] | 608 deps += [ ":$_loadable_module_bundle_data" ] |
| 517 | 609 |
| 518 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" | 610 bundle_root_dir = "$root_out_dir/$_output_name.plugin/Contents" |
| 519 bundle_executable_dir = "$bundle_root_dir/MacOS" | 611 bundle_executable_dir = "$bundle_root_dir/MacOS" |
| 520 } | 612 } |
| 521 } | 613 } |
| OLD | NEW |