blob: 859c24c2d5dc9e1f081ef0301b6b18c87e5562c8 [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_test.gni")
common_sources = [
"src/bti.rs",
"src/channel.rs",
"src/clock.rs",
"src/clock_update.rs",
"src/cprng.rs",
"src/debuglog.rs",
"src/event.rs",
"src/eventpair.rs",
"src/exception.rs",
"src/fifo.rs",
"src/guest.rs",
"src/handle.rs",
"src/info.rs",
"src/interrupt.rs",
"src/iommu.rs",
"src/job.rs",
"src/lib.rs",
"src/pager.rs",
"src/pmt.rs",
"src/port.rs",
"src/process.rs",
"src/profile.rs",
"src/property.rs",
"src/resource.rs",
"src/rights.rs",
"src/signals.rs",
"src/socket.rs",
"src/stream.rs",
"src/task.rs",
"src/thread.rs",
"src/time.rs",
"src/vcpu.rs",
"src/version.rs",
"src/vmar.rs",
"src/vmo.rs",
]
if (is_fuchsia) {
rustc_library("fuchsia-zircon") {
version = "0.3.3"
edition = "2021"
deps = [
":fuchsia-zircon-status",
"//third_party/rust_crates:bitflags",
"//zircon/vdso:fuchsia-zircon-sys",
]
sources = common_sources
}
}
rustc_library("fuchsia-cprng") {
version = "0.1.1"
edition = "2021"
with_unit_tests = true
visibility = [ ":*" ]
source_root = "fuchsia-cprng/src/lib.rs"
sources = [ "fuchsia-cprng/src/lib.rs" ]
}
rustc_library("fuchsia-zircon-types") {
version = "0.1.0"
edition = "2021"
source_root = "fuchsia-zircon-types/src/lib.rs"
deps = [ "//third_party/rust_crates:static_assertions" ]
sources = [ "fuchsia-zircon-types/src/lib.rs" ]
}
rustc_test("fuchsia-zircon-types-tests") {
name = "fuchsia_zircon_types_tests"
edition = "2021"
source_root = "fuchsia-zircon-types/src/lib.rs"
deps = [ "//third_party/rust_crates:static_assertions" ]
sources = [ "fuchsia-zircon-types/src/lib.rs" ]
}
rustc_library("fuchsia-zircon-status") {
version = "0.1.0"
edition = "2021"
source_root = "fuchsia-zircon-status/src/lib.rs"
deps = [ ":fuchsia-zircon-types" ]
sources = [ "fuchsia-zircon-status/src/lib.rs" ]
}
rustc_test("fuchsia-zircon-status-tests") {
name = "fuchsia_zircon_status_tests"
edition = "2021"
source_root = "fuchsia-zircon-status/src/lib.rs"
deps = [ "//src/lib/zircon/rust:fuchsia-zircon-types" ]
sources = [ "fuchsia-zircon-status/src/lib.rs" ]
}
# Certain tests written as unit tests of fuchsia-zircon make use of other
# crates which themselves depend on fuchsia-zircon. This causes
# fuchsia_zircon::foo to be a different type from crate::foo in the context of
# those unit tests when fuchsia-zircon is built with `with_unit_tests = true`.
#
# Since those tests are really integration tests, we should either move them
# into the "other" crates so that the dependency graph flows in only one
# direction, or simply move those tests into a dedicated target and redesignate
# them as integration tests, which they appear to be.
#
# TODO(https://fxbug.dev/91562): untangle this web.
rustc_test("fuchsia-zircon-unittests") {
edition = "2021"
output_name = "fuchsia_zircon_tests"
deps = [
":fuchsia-zircon-status",
"//third_party/rust_crates:bitflags",
"//zircon/vdso:fuchsia-zircon-sys",
# Test-only deps
":fuchsia-zircon",
"//sdk/fidl/fuchsia.boot:fuchsia.boot_rust",
"//sdk/fidl/fuchsia.kernel:fuchsia.kernel_rust",
"//src/lib/fdio/rust:fdio",
"//src/lib/fuchsia",
"//src/lib/fuchsia-component",
"//src/lib/fuchsia-runtime",
"//third_party/rust_crates:assert_matches",
]
sources = common_sources
}
rustc_binary("exit_with_code_util") {
edition = "2021"
source_root = "test_util/exit_with_code_util.rs"
deps = [ ":fuchsia-zircon" ]
sources = [ "test_util/exit_with_code_util.rs" ]
}
rustc_binary("sleep_forever_util") {
edition = "2021"
source_root = "test_util/sleep_forever_util.rs"
deps = [ ":fuchsia-zircon" ]
sources = [ "test_util/sleep_forever_util.rs" ]
}
fuchsia_unittest_component("fuchsia-cprng_test-component") {
component_name = "fuchsia-cprng"
deps = [ ":fuchsia-cprng_test" ]
}
fuchsia_unittest_component("fuchsia-zircon-status-component") {
component_name = "fuchsia-zircon-status"
deps = [ ":fuchsia-zircon-status-tests" ]
}
fuchsia_unittest_component("fuchsia-zircon-tests-component") {
component_name = "fuchsia-zircon-tests"
manifest = "meta/fuchsia_zircon_tests.cml"
deps = [ ":fuchsia-zircon-unittests" ]
}
fuchsia_unittest_component("fuchsia-zircon-types-tests-component") {
component_name = "fuchsia-zircon-types-tests"
deps = [ ":fuchsia-zircon-types-tests" ]
}
fuchsia_test_package("fuchsia-zircon-tests") {
test_components = [
":fuchsia-cprng_test-component",
":fuchsia-zircon-status-component",
":fuchsia-zircon-tests-component",
":fuchsia-zircon-types-tests-component",
]
deps = [
":exit_with_code_util",
":sleep_forever_util",
]
}
group("tests") {
testonly = true
deps = [ ":fuchsia-zircon-tests" ]
}