blob: 215c2048badb594ec7d0141cda4189d14eb27767 [file] [log] [blame]
# Copyright 2024 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")
# Provides the IANA time zone database files as a resource.
#
# The files will be made available in the namespace of the target component(s)
# namespace `/data/tzdata/zoneinfo/tzif2`.
# Users of cctz should set the TZDIR environment variable to this path.
#
# There will also be a file at `/config/data/tzdata/revision.txt` containing the
# time zone database revision ID, e.g. `2019c`.
#
# Example:
#
# ```
# zoneinfo_resource("zoneinfo") {
# }
# ```
#
template("zoneinfo_resource") {
version_name = "tzif2"
sub_targets = []
directory_list =
read_file("//prebuilt/third_party/zoneinfo/${version_name}_files.json",
"json")
# Package each individual file.
foreach(entry, directory_list) {
directory = entry.directory
target_suffix = string_replace(directory, "/", "_")
target_label = "_${target_name}_dir_${target_suffix}"
sub_targets += [ ":${target_label}" ]
resource(target_label) {
forward_variables_from(invoker, [ "testonly" ])
source_path = "//prebuilt/third_party/zoneinfo/${version_name}"
if (directory != "") {
source_path = "${source_path}/${directory}"
}
sources = []
foreach(file_name, entry.file_names) {
sources += [ "${source_path}/${file_name}" ]
}
output_path = "tzdata/zoneinfo/${version_name}"
if (directory != "") {
output_path = "${output_path}/${directory}"
}
outputs = [ "${output_path}/{{source_file_part}}" ]
}
} # /foreach
revision_target_label = "_${target_name}_revision_txt"
sub_targets += [ ":${revision_target_label}" ]
resource(revision_target_label) {
forward_variables_from(invoker, [ "testonly" ])
sources = [ "//prebuilt/third_party/zoneinfo/version.txt" ]
outputs = [ "tzdata/zoneinfo/revision.txt" ]
}
group(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
])
deps = sub_targets
}
}