| # Copyright 2023 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/components.gni") |
| import("config.gni") # icu_flavors, icu_fixup_deps |
| |
| # ICU-aware fuchsia_package. |
| # |
| # Args: |
| # |
| # - icu_deps: list(label): the target labels that need to be fixed up for |
| # ICU product assembly. Otherwise the same as deps. |
| # - icu_public_deps: list(label): Same as above, but for public_deps |
| # - All other args are forwarded verbatim from the invoker. |
| # |
| # Refer to icu_source_set.gni for detailed comments on some constructs below, |
| # the ideas of which are commonly reused in all icu_* templates. |
| template("icu_fuchsia_package") { |
| foreach(icu_flavor, icu_flavors) { |
| fuchsia_package( |
| "${target_name}.icu_${icu_flavor.name}_${icu_flavor.commit_id}") { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "visibility", |
| "testonly", |
| "icu_deps", |
| "icu_public_deps", |
| ]) |
| forward_variables_from(invoker, |
| [ |
| "visibility", |
| "testonly", |
| ]) |
| |
| _flavored_icu_deps = [ |
| get_label_info("//third_party/icu/${icu_flavor.name}:icu", |
| "label_with_toolchain"), |
| get_label_info("//third_party/icu/${icu_flavor.name}:icudata", |
| "label_with_toolchain"), |
| ] |
| not_needed([ |
| "package_name", |
| "_flavored_icu_deps", |
| ]) |
| |
| if (defined(package_name)) { |
| package_name = |
| "${package_name}.icu_${icu_flavor.name}_${icu_flavor.commit_id}" |
| } else { |
| package_name = target_name |
| } |
| |
| if (defined(invoker.icu_deps)) { |
| if (!defined(deps)) { |
| deps = [] |
| } |
| |
| deps += icu_fixup_deps + _flavored_icu_deps |
| deps -= icu_fixup_deps |
| |
| foreach(icu_dep, invoker.icu_deps) { |
| _relabel = get_label_info(icu_dep, "label_no_toolchain") |
| deps += [ "${_relabel}.icu_${icu_flavor.name}_${icu_flavor.commit_id}(${current_toolchain})" ] |
| } |
| } |
| |
| if (defined(invoker.icu_public_deps)) { |
| if (!defined(public_deps)) { |
| public_deps = [] |
| } |
| public_deps += icu_fixup_deps + _flavored_icu_deps |
| public_deps -= icu_fixup_deps |
| foreach(icu_public_dep, invoker.icu_public_deps) { |
| _relabel = get_label_info(icu_public_dep, "label_no_toolchain") |
| public_deps += [ "${_relabel}.icu_${icu_flavor.name}_${icu_flavor.commit_id}(${current_toolchain})" ] |
| } |
| } |
| } |
| } |
| |
| fuchsia_package("${target_name}") { |
| forward_variables_from(invoker, "*") |
| |
| if (defined(icu_deps)) { |
| if (!defined(deps)) { |
| deps = [] |
| } |
| deps += icu_deps |
| } |
| if (defined(icu_public_deps)) { |
| if (!defined(public_deps)) { |
| public_deps = [] |
| } |
| public_deps += icu_public_deps |
| } |
| } |
| } |