| # 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/components.gni") |
| import("//build/fidl/fidl.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/rust/rustc_test.gni") |
| |
| _common = { |
| edition = "2021" |
| sources = [ |
| "src/buffer.rs", |
| "src/concurrency.rs", |
| "src/endpoints/client.rs", |
| "src/endpoints/connection.rs", |
| "src/endpoints/lockers.rs", |
| "src/endpoints/mod.rs", |
| "src/endpoints/server.rs", |
| "src/error.rs", |
| "src/flexible.rs", |
| "src/flexible_result.rs", |
| "src/framework_error.rs", |
| "src/lib.rs", |
| "src/mpsc.rs", |
| "src/service.rs", |
| "src/testing.rs", |
| "src/transport.rs", |
| "src/wire.rs", |
| ] |
| deps = [ |
| "//src/lib/fidl/rust_next/fidl_next_codec", |
| |
| # Used for atomic wakers, but not for any APIs |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:pin-project", |
| "//third_party/rust_crates:thiserror", |
| "//third_party/rust_crates:zerocopy", |
| ] |
| features = [] |
| } |
| |
| rustc_library("fidl_next_protocol") { |
| forward_variables_from(_common, "*") |
| |
| if (is_fuchsia) { |
| sources += [ |
| "src/fuchsia/channel.rs", |
| "src/fuchsia/mod.rs", |
| ] |
| deps += [ |
| "//sdk/rust/zx", |
| "//src/lib/fuchsia-async", |
| ] |
| features += [ "fuchsia" ] |
| } |
| |
| with_unit_tests = true |
| test_deps = [ "//src/lib/fuchsia-async" ] |
| |
| # NOTE: this library is still experimental |
| visibility = [ |
| "//:developer_universe_packages", |
| "//sdk/lib/driver/*", |
| "//src/lib/fdomain/*", |
| "//src/lib/fidl/rust_next/*", |
| "//tools/fidl/fidlc/testdata/*", |
| "//tools/fidl/fidlgen_rust_next/*", |
| ] |
| } |
| |
| fuchsia_unittest_package("fidl_next_protocol_test_package") { |
| deps = [ ":fidl_next_protocol_test" ] |
| } |
| |
| if (is_host) { |
| rustc_library("fidl_next_protocol_loom") { |
| forward_variables_from(_common, "*") |
| |
| configs += [ ":loom" ] |
| features = [ "loom" ] |
| deps -= [ "//third_party/rust_crates:futures" ] |
| deps += [ "//third_party/rust_crates:loom" ] |
| testonly = true |
| } |
| |
| rustc_test("fidl_next_protocol_loom_tests") { |
| edition = "2021" |
| source_root = "tests/loom.rs" |
| sources = [ "tests/loom.rs" ] |
| features = [ "loom" ] |
| deps = [ |
| ":fidl_next_protocol_loom", |
| "//src/lib/fidl/rust_next/fidl_next_codec", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:loom", |
| ] |
| } |
| } |
| |
| config("loom") { |
| # The loom crate documentation recommends compiling with optimizations since |
| # the number of iterations can be large enough to make tests unreasonably slow |
| # otherwise. |
| configs = [ "//build/config:optimize_moderate" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":fidl_next_protocol_loom_tests($host_toolchain)", |
| ":fidl_next_protocol_test($host_toolchain)", |
| ":fidl_next_protocol_test_package", |
| ] |
| } |