| # 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/rust/rustc_library.gni") |
| import( |
| "//src/connectivity/network/netstack3/core/rustc_library_with_features.gni") |
| |
| rustc_library_with_features("netstack3-base") { |
| edition = "2021" |
| configs -= [ "//build/config/rust/lints:allow_unused_results" ] |
| sources = [ |
| "src/context.rs", |
| "src/convert.rs", |
| "src/counters.rs", |
| "src/data_structures.rs", |
| "src/data_structures/ref_counted_hash_map.rs", |
| "src/error.rs", |
| "src/event.rs", |
| "src/frame.rs", |
| "src/inspect.rs", |
| "src/lib.rs", |
| "src/resource_references.rs", |
| "src/rng.rs", |
| "src/testutil/addr.rs", |
| "src/testutil/benchmarks.rs", |
| "src/testutil/fake_bindings.rs", |
| "src/testutil/fake_core.rs", |
| "src/testutil/fake_network.rs", |
| "src/testutil/misc.rs", |
| "src/testutil/monotonic_id.rs", |
| "src/time.rs", |
| "src/time/local_timer_heap.rs", |
| "src/time/testutil.rs", |
| "src/trace.rs", |
| "src/uninstantiable.rs", |
| "src/work_queue.rs", |
| ] |
| deps = [ |
| "//src/connectivity/lib/net-types", |
| "//src/connectivity/network/lib/explicit", |
| "//src/lib/const-unwrap", |
| "//src/lib/fakealloc", |
| "//src/lib/network/packet", |
| "//third_party/rust_crates:rand", |
| "//third_party/rust_crates:thiserror", |
| |
| # TODO(https://github.com/rust-lang/rust/issues/62502): remove this module. |
| "//src/connectivity/network/netstack3/core/fakestd", |
| ] |
| |
| _testutils_deps = [ |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/lib/packet-formats", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:criterion", |
| "//third_party/rust_crates:derivative", |
| "//third_party/rust_crates:rand_xorshift", |
| "//third_party/rust_crates:tracing", |
| "//third_party/rust_crates:tracing-subscriber", |
| ] |
| |
| if (!is_host) { |
| configs += [ "//src/connectivity/network/netstack3:netstack3_configs" ] |
| } |
| |
| feature_sets = [ |
| { |
| features = [] |
| deps += |
| [ "//src/connectivity/network/netstack3/core/sync:netstack3-sync" ] |
| }, |
| |
| # A variant of the netstack3-base library that exposes test utilities. |
| { |
| target_name = "netstack3-base-testutils" |
| testonly = true |
| features = [ |
| "testutils", |
| "instrumented", |
| ] |
| deps += _testutils_deps |
| deps += [ "//src/connectivity/network/netstack3/core/sync:netstack3-sync-instrumented" ] |
| }, |
| { |
| target_name = "netstack3-base-benchmarks" |
| features = [ "testutils" ] |
| deps += _testutils_deps |
| deps += |
| [ "//src/connectivity/network/netstack3/core/sync:netstack3-sync" ] |
| }, |
| { |
| target_name = "netstack3-base-instrumented" |
| with_unit_tests = true |
| features = [ "instrumented" ] |
| test_deps = _testutils_deps |
| deps += [ "//src/connectivity/network/netstack3/core/sync:netstack3-sync-instrumented" ] |
| }, |
| ] |
| if (is_host) { |
| feature_sets += [ |
| { |
| target_name = "netstack3-base-loom" |
| features = [ |
| "testutils", |
| "instrumented", |
| ] |
| testonly = true |
| deps += _testutils_deps |
| deps += [ |
| "//src/connectivity/network/netstack3/core/sync:netstack3-sync-loom", |
| ] |
| configs += [ "//src/connectivity/network/netstack3/core:loom" ] |
| }, |
| ] |
| } |
| } |
| |
| fuchsia_unittest_package("netstack3-core-base-test") { |
| deps = [ ":netstack3-base-instrumented_test" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":netstack3-base-instrumented_test($host_toolchain)", |
| ":netstack3-core-base-test", |
| ] |
| } |