blob: ce7cccad6994845616f39095892be46ee43e705e [file] [log] [blame]
# Copyright 2020 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/compiled_action.gni")
import("//src/lib/icu/third_party_icu_headers.gni")
import("//src/lib/icu/tzdata/icu_tzres_source.gni")
# Generates a file containing static data extracted from ICU using icu_data_extractor.
#
# Example:
#
# import("//src/lib/icu/tools/static_icu_data.gni")
# import("//build/components.gni")
# import("//build/dist/resource.gni")
#
# static_icu_data("revision") {
# command = "tz-version"
# output = "${target_gen_dir}/revision.txt"
# }
#
# resource("resource") {
# sources = get_target_outputs(":revision")
# outputs = [ "data/revision.txt" ]
# }
#
# fuchsia_component("component") {
# deps = [ ":resource" ]
# ...
# }
#
# To view all the supported commands and arguments, run
#
# fx build host-tools/icu_data_extractor && out/default/host_x64/icu_data_extractor
#
# Parameters
#
# output:
# Required: Path to the output file. This should usually be something like
# "$target_gen_dir/myfile.txt".
# Type: file
#
# command:
# Required: icu_data_extractor command ("tz-version", "tz-ids")
# Type: string
#
# command_args:
# Optional: Additional arguments to icu_data_extractor command.
# Type: list(string)
#
template("static_icu_data") {
compiled_action(target_name) {
forward_variables_from(invoker,
[
"testonly",
"visibility",
"command_args",
"command",
"output",
])
if (!defined(command_args)) {
command_args = []
}
tool = "//src/lib/icu/tools/extractor:icu_data_extractor"
icu_data_file = "${icu_root}/common/icudtl.dat"
tz_res_dir = icu_tzres_path
inputs = [
icu_data_file,
# While these files aren't strictly the only files in tz_res_dir, in
# practice they rarely change, so it's OK to list them explicitly as
# inputs here.
"${icu_tzres_path}/metaZones.res",
"${icu_tzres_path}/timezoneTypes.res",
"${icu_tzres_path}/zoneinfo64.res",
]
outputs = [ output ]
args = [
"--icu-data-file=" + rebase_path(icu_data_file, root_build_dir),
"--tz-res-dir=" + rebase_path(tz_res_dir, root_build_dir),
command,
"--output=" + rebase_path(output, root_build_dir),
] + command_args
}
}