blob: b364f353404819df359ad2d11b894450fe6075b1 [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/compiled_action.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
rustc_library("unicode") {
edition = "2024"
name = "fxfs-unicode"
sources = [
"src/lib.rs",
"src/lookup.rs",
"src/nfd.rs",
]
deps = [
":types",
":unicode_gen",
"//src/storage/type-fprint:fprint",
"//third_party/rust_crates:arbitrary",
"//third_party/rust_crates:serde",
]
visibility = [ "//src/storage/*" ]
}
# We compile this file into its own crate to avoid gen/ path imports from rust.
rustc_library("unicode_gen") {
edition = "2024"
source_root = "${target_gen_dir}/unicode_gen.rs"
sources = [ "${target_gen_dir}/unicode_gen.rs" ]
deps = [ ":types" ]
non_rust_deps = [ ":generate_unicode_gen" ]
}
# This rule is for executing unicode_gen_builder.
compiled_action("generate_unicode_gen") {
tool = ":unicode_gen_builder"
outputs =
[ get_label_info(":unicode_gen", "target_gen_dir") + "/unicode_gen.rs" ]
inputs = [ "//prebuilt/third_party/ucd/UCD.zip" ]
args = [ rebase_path("//prebuilt/third_party/ucd/UCD.zip", root_build_dir) ] +
rebase_path(outputs, root_build_dir)
}
if (is_host) {
rustc_test("unicode_test") {
edition = "2024"
name = "fxfs-unicode-test"
sources = [
"src/lib.rs",
"src/lookup.rs",
"src/nfd.rs",
]
deps = [
":types",
":unicode_gen",
"//src/storage/type-fprint:fprint",
"//third_party/rust_crates:arbitrary",
"//third_party/rust_crates:regex",
"//third_party/rust_crates:serde",
"//third_party/rust_crates:zip",
]
data_deps = [ ":ucd_zip" ]
visibility = [ "//src/storage/fxfs/*" ]
rustenv = [ "UCD_ZIP=" + rebase_path("//prebuilt/third_party/ucd/UCD.zip",
root_build_dir) ]
}
host_test_data("ucd_zip") {
sources = [ "//prebuilt/third_party/ucd/UCD.zip" ]
}
# This (host) binary is responsible for taking UCD.zip and creating unicode_gen.rs.
rustc_binary("unicode_gen_builder") {
edition = "2024"
source_root = "src/generator.rs"
sources = [ "src/generator.rs" ]
deps = [
":types",
"//third_party/rust_crates:regex",
"//third_party/rust_crates:zip",
]
visibility = [ "//src/storage/fxfs/*" ]
}
}
# The types that we generate are shared with the library and generator so
# we put them in their own target.
rustc_library("types") {
edition = "2024"
source_root = "src/types.rs"
sources = [ "src/types.rs" ]
visibility = [ "//src/storage/fxfs/unicode/*" ]
}
group("tests") {
testonly = true
deps = [ ":unicode_test($host_toolchain)" ]
}