| # 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") |
| |
| # Generates a file containing static data extracted from ICU using icu_data_extractor. |
| # |
| # Example: |
| # |
| # import("//src/lib/icu/tools/static_icu_data.gni") |
| # import("//src/sys/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 = "//third_party/icu/common/icudtl.dat" |
| tz_res_dir = "//third_party/icu/tzres/" |
| |
| 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. |
| "//third_party/icu/tzres/metaZones.res", |
| "//third_party/icu/tzres/timezoneTypes.res", |
| "//third_party/icu/tzres/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 |
| } |
| } |