blob: 03c7a302f8232c4b7f3fc285acec637035da0374 [file] [log] [blame]
# 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("config.gni")
# An ICU-aware group.
#
# All args are forwarded verbatim from "group".
template("icu_group") {
foreach(icu_flavor, icu_flavors) {
group("${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",
])
# Ensure that we preserve the toolchain when adding dependencies.
not_needed([ "icu_flavor" ])
if (defined(invoker.icu_deps)) {
if (!defined(deps)) {
deps = []
}
# Deps fixup is a bit more involved than needed, to make it a tad faster
# to evaluate in GN.
deps_to_remove = invoker.icu_deps
foreach(icu_dep, invoker.icu_deps) {
# Fully resolve labels like "//foo/bar" to "//foo/bar:bar", so that
# ICU fixup doesn't change the leaf directory name.
_relabel = get_label_info(icu_dep, "label_no_toolchain")
# Also remove the remnants of unlabeled deps.
deps_to_remove += [ _relabel ]
deps += [ "${_relabel}.icu_${icu_flavor.name}_${icu_flavor.commit_id}(${current_toolchain})" ]
}
deps += deps_to_remove
deps -= deps_to_remove
}
# Similar to above, but for public_deps.
if (defined(invoker.icu_public_deps)) {
if (!defined(public_deps)) {
public_deps = []
}
public_deps_to_remove = invoker.icu_public_deps
foreach(icu_public_dep, invoker.icu_public_deps) {
_relabel = get_label_info(icu_public_dep, "label_no_toolchain")
# See the similar idiom above.
public_deps_to_remove += [ _relabel ]
public_deps += [ "${_relabel}.icu_${icu_flavor.name}_${icu_flavor.commit_id}(${current_toolchain})" ]
}
public_deps += public_deps_to_remove
public_deps -= public_deps_to_remove
}
}
}
# The original source set, with the original target name.
group(target_name) {
forward_variables_from(invoker,
"*",
[
"visibility",
"testonly",
"icu_deps",
"icu_public_deps",
])
forward_variables_from(invoker,
[
"visibility",
"testonly",
])
if (defined(invoker.icu_deps)) {
if (!defined(deps)) {
deps = []
}
deps += invoker.icu_deps
}
if (defined(invoker.icu_public_deps)) {
if (!defined(public_deps)) {
public_deps = []
}
public_deps += invoker.icu_public_deps
}
}
}