blob: c4a2823c2834463f623bc7d519dc8dc86f306713 [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")
import("//build/dist/resource.gni")
import("//src/lib/icu/tzdata/icu_tzres_source.gni")
# Provide ICU time zone files to the given package via config-data.
#
# NOTE: This rule is deprecated. Use the tzdata directory capability
# instead. See /docs/development/internationalization/icu_data.md.
#
# 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.
#
# TODO(fxbug.dev/104685): Remove in favor of tzdata directory capability
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 = [
"${icu_tzres_path}/metaZones.res",
"${icu_tzres_path}/timezoneTypes.res",
"${icu_tzres_path}/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 placeholder 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}" ]
}
}
}