blob: 4fbeba16a5a600f1b85ce3db2bd0c91e8dad6b5c [file] [log] [blame]
# Copyright 2019 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/config.gni")
# Provide ICU time zone resource files to the given package.
#
# The following files will be available in the component's namespace:
#
# * /config/data/tzdata/revision.txt
# * /config/data/tzdata/icu/44/le/metaZones.res
# * /config/data/tzdata/icu/44/le/timezoneTypes.res
# * /config/data/tzdata/icu/44/le/zoneinfo64.res
#
# For `testonly = true` targets, the rule will add a marker file:
#
# * /config/data/FUCHSIA_IN_TREE_TEST
#
# Please see `README.md` for detailed documentation.
template("icu_tzdata_config_data") {
_resources_label = "_${target_name}_resources"
config_data(_resources_label) {
forward_variables_from(invoker,
[
"for_pkg",
"testonly",
])
data_version = "44"
if (defined(invoker.data_version)) {
data_version = invoker.data_version
}
format = "le"
if (defined(invoker.format)) {
format = invoker.format
}
assert(data_version == "44" && format == "le",
"Unsupported data version or format")
deps = [
"//src/lib/icu/tzdata:revision",
]
outputs = [
"tzdata/icu/${data_version}/${format}/{{source_file_part}}",
]
sources = [
"//third_party/icu/tzres/metaZones.res",
"//third_party/icu/tzres/timezoneTypes.res",
"//third_party/icu/tzres/zoneinfo64.res",
]
# //src/lib/icu/tzdata:revision will be found in the build directory at
#`out/default/gen/src/lib/icu/tzdata/revision.txt`
}
_revision_label = "_${target_name}_revision"
config_data(_revision_label) {
forward_variables_from(invoker,
[
"for_pkg",
"testonly",
])
deps = [
"//src/lib/icu/tzdata:revision",
]
outputs = [
"tzdata/{{source_file_part}}",
]
# get_target_outputs("//src/lib/icu/tzdata:revision") can only be used in
# //src/lib/icu/tzdata/BUILD.gn, so we have to hard-code the file path.
sources = [
# This is usually `out/default/gen/src/lib/icu/tzdata/revision.txt`
"${root_gen_dir}/src/lib/icu/tzdata/revision.txt",
]
}
if (defined(invoker.testonly) && invoker.testonly) {
_test_marker_label = "_${target_name}_test_marker"
# Includes a dummy file only for test targets.
config_data(_test_marker_label) {
forward_variables_from(invoker,
[
"for_pkg",
"testonly",
])
sources = [
"//src/lib/icu/tzdata/testing/FUCHSIA_IN_TREE_TEST",
]
}
}
group(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
deps = [
":${_resources_label}",
":${_revision_label}",
]
if (defined(testonly) && testonly) {
deps += [ ":${_test_marker_label}" ]
}
}
}