| # 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") |
| |
| # Provide ICU time zone files to the given package via config-data. |
| # |
| # 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 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}" ] |
| } |
| } |
| } |
| |
| # Provide ICU time zone resource files to the given package. |
| # |
| # The following files will be available in the component's namespace: |
| # |
| # * /pkg/tzdata/revision.txt |
| # * /pkg/tzdata/icu/44/le/metaZones.res |
| # * /pkg/tzdata/icu/44/le/timezoneTypes.res |
| # * /pkg/tzdata/icu/44/le/zoneinfo64.res |
| # |
| # For `testonly = true` targets, the rule will add a marker file: |
| # |
| # * /pkg/FUCHSIA_IN_TREE_TEST |
| # |
| # Please see `README.md` for detailed documentation. |
| template("icu_tzdata_resource") { |
| _resources_label = "_${target_name}_resources" |
| resource(_resources_label) { |
| forward_variables_from(invoker, [ "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 = |
| [ "data/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" |
| resource(_revision_label) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| deps = [ "//src/lib/icu/tzdata:revision" ] |
| |
| outputs = [ "data/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. |
| resource(_test_marker_label) { |
| forward_variables_from(invoker, [ "testonly" ]) |
| sources = [ "//src/lib/icu/tzdata/testing/FUCHSIA_IN_TREE_TEST" ] |
| outputs = [ "data/FUCHSIA_IN_TREE_TEST" ] |
| } |
| } |
| |
| group(target_name) { |
| forward_variables_from(invoker, [ "visibility" ]) |
| |
| # Production components should use ICU data from /config/data |
| # for storage efficiency and for configuration consistency. |
| # Tests can include whatever data they need in the test package. |
| testonly = true |
| deps = [ |
| ":${_resources_label}", |
| ":${_revision_label}", |
| ] |
| |
| if (defined(testonly) && testonly) { |
| deps += [ ":${_test_marker_label}" ] |
| } |
| } |
| } |