blob: 9ac26c1f93948763867761b1c14f9d8cfc6f1df1 [file] [log] [blame]
# Copyright 2017 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/components.gni")
import("//build/rust/rustc_binary.gni")
import("//build/rust/rustc_library.gni")
import("//build/rust/rustc_link_attribute.gni")
# The Rust stdlib has an implicit link attribute to libfdio.
# Any Rust executable should depend on this target to link
# properly. See //build/rust/rustc_artifact.gni.
rustc_link_attribute("fdio_for_rust_stdlib") {
lib_shared_target = "//sdk/lib/fdio"
}
rustc_library("fdio") {
with_unit_tests = true
version = "0.2.0"
edition = "2021"
deps = [
"//sdk/fidl/fuchsia.io:fuchsia.io_rust",
"//sdk/lib/fdio",
"//sdk/rust/zx",
"//src/lib/fidl/rust/fidl",
"//src/lib/fuchsia-runtime",
"//third_party/rust_crates:bitflags",
"//third_party/rust_crates:thiserror",
]
test_deps = [
"//src/lib/fuchsia-async",
"//src/lib/fuchsia-runtime",
"//third_party/rust_crates:assert_matches",
"//third_party/rust_crates:libc",
"//third_party/rust_crates:rand",
"//third_party/rust_crates:tempfile",
]
sources = [
"src/fdio_sys.rs",
"src/lib.rs",
"src/spawn_builder.rs",
]
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
rustc_library("fdio_zxio") {
with_unit_tests = true
version = "0.1.0"
edition = "2021"
source_root = "src/fdio_zxio.rs"
sources = [
"src/fdio_sys.rs",
"src/fdio_zxio.rs",
"src/zxio_sys.rs",
]
deps = [
"//sdk/lib/zxio",
"//sdk/rust/zx",
]
test_deps = [
"//src/lib/fuchsia",
"//third_party/rust_crates:libc",
]
}
rustc_binary("spawn_test_target") {
version = "0.2.0"
edition = "2021"
source_root = "test/spawn_test_target.rs"
sources = [ "test/spawn_test_target.rs" ]
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
rustc_binary("spawn_builder_test_target") {
edition = "2021"
visibility = [ ":*" ]
source_root = "test/spawn_builder_test_target.rs"
sources = [ "test/spawn_builder_test_target.rs" ]
configs -= [ "//build/config/rust/lints:allow_unused_results" ]
}
fuchsia_component("test-component") {
testonly = true
visibility = [ ":*" ]
component_name = "fdio_lib_test"
deps = [
":fdio_test",
":spawn_builder_test_target",
":spawn_test_target",
]
manifest = "meta/fdio_lib_test.cml"
}
fuchsia_unittest_component("fdio_zxio_test_component") {
visibility = [ ":*" ]
component_name = "fdio_zxio_test"
deps = [ ":fdio_zxio_test" ]
}
fuchsia_test_package("test-package") {
package_name = "fdio-rust-tests"
test_components = [
":test-component",
":fdio_zxio_test_component",
]
}
group("tests") {
testonly = true
deps = [ ":test-package" ]
}