blob: bd0af313e3590ce34d8d5d60c5795176188f6571 [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("//build/dist/resource.gni")
import("config.gni") # icu_flavors, icu_flavor_major_versions
# A placeholder for major version number. If this string appears in any
# `outputs`, it will be replaced with the current flavor's major version
# number, such as "73".
icu_major_version_number_placeholder = "||icu_major_version_number||"
# An ICU-aware resource.
#
# All args are forwarded verbatim from `resource`.
#
# In the `outputs`, use `${icu_major_version_number_placeholder}` to substitute
# the actual major version number of the respective ICU flavor, such as 73.
#
# 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_resource") {
foreach(icu_flavor, icu_flavors) {
_flavored_resource_name =
"${target_name}.icu_${icu_flavor.name}_${icu_flavor.commit_id}"
resource(_flavored_resource_name) {
forward_variables_from(invoker,
"*",
[
"target_name", # Workaround for
# https://fxbug.dev/42083609.
"testonly",
"visibility",
])
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
foreach(source, sources) {
sources -= [ source ]
sources += [ string_replace(source,
icu_root,
"//third_party/icu/${icu_flavor.name}") ]
}
foreach(output, outputs) {
outputs -= [ output ]
outputs += [ string_replace(output,
icu_major_version_number_placeholder,
icu_flavor.major_version) ]
}
}
}
resource(target_name) {
forward_variables_from(invoker, "*")
foreach(output, outputs) {
outputs -= [ output ]
outputs += [ string_replace(output,
icu_major_version_number_placeholder,
icu_flavor_major_versions.default) ]
}
}
}