| # Copyright 2018 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. |
| |
| declare_args() { |
| # Adds compilation flags to emit rustc self-profiling when building netstack3 |
| # targets. That helps us track down where time is spent and memory |
| # consumption to play nice with RBE. |
| netstack3_profile_rustc = false |
| } |
| |
| import("//build/components.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//src/connectivity/network/unified_binary/network_unified_binary.gni") |
| |
| common_deps = [ |
| "//sdk/fidl/fuchsia.hardware.network:fuchsia.hardware.network_rust", |
| "//sdk/fidl/fuchsia.net:fuchsia.net_rust", |
| "//sdk/fidl/fuchsia.net.debug:fuchsia.net.debug_rust", |
| "//sdk/fidl/fuchsia.net.dhcp:fuchsia.net.dhcp_rust", |
| "//sdk/fidl/fuchsia.net.filter:fuchsia.net.filter_rust", |
| "//sdk/fidl/fuchsia.net.interfaces:fuchsia.net.interfaces_rust", |
| "//sdk/fidl/fuchsia.net.interfaces.admin:fuchsia.net.interfaces.admin_rust", |
| "//sdk/fidl/fuchsia.net.name:fuchsia.net.name_rust", |
| "//sdk/fidl/fuchsia.net.neighbor:fuchsia.net.neighbor_rust", |
| "//sdk/fidl/fuchsia.net.root:fuchsia.net.root_rust", |
| "//sdk/fidl/fuchsia.net.routes:fuchsia.net.routes_rust", |
| "//sdk/fidl/fuchsia.net.routes.admin:fuchsia.net.routes.admin_rust", |
| "//sdk/fidl/fuchsia.net.stack:fuchsia.net.stack_rust", |
| "//sdk/fidl/fuchsia.posix:fuchsia.posix_rust", |
| "//sdk/fidl/fuchsia.posix.socket:fuchsia.posix.socket_rust", |
| "//sdk/fidl/fuchsia.posix.socket.packet:fuchsia.posix.socket.packet_rust", |
| "//sdk/fidl/fuchsia.posix.socket.raw:fuchsia.posix.socket.raw_rust", |
| "//src/connectivity/lib/fidl_fuchsia_net_neighbor_ext", |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/lib/net-types", |
| "//src/connectivity/lib/network-device/rust", |
| "//src/connectivity/lib/packet-formats", |
| "//src/connectivity/network/lib/explicit", |
| "//src/lib/async-utils", |
| "//src/lib/const-unwrap", |
| "//src/lib/debug/rust", |
| "//src/lib/diagnostics/inspect/rust", |
| "//src/lib/diagnostics/log/rust", |
| "//src/lib/fidl/rust/fidl", |
| "//src/lib/fuchsia-async", |
| "//src/lib/fuchsia-component", |
| "//src/lib/fuchsia-runtime", |
| "//src/lib/network/fidl_fuchsia_net_ext", |
| "//src/lib/network/fidl_fuchsia_net_filter_ext", |
| "//src/lib/network/fidl_fuchsia_net_interfaces_ext", |
| "//src/lib/network/fidl_fuchsia_net_routes_ext", |
| "//src/lib/network/packet", |
| "//src/lib/trace/rust:trace", |
| "//src/lib/trace/rust:trace-provider", |
| "//src/lib/zircon/rust:fuchsia-zircon", |
| "//src/sys/pkg/fidl/fuchsia.update.verify:fuchsia.update.verify_rust", |
| "//third_party/rust_crates:argh", |
| "//third_party/rust_crates:assert_matches", |
| "//third_party/rust_crates:derivative", |
| "//third_party/rust_crates:either", |
| "//third_party/rust_crates:futures", |
| "//third_party/rust_crates:itertools", |
| "//third_party/rust_crates:once_cell", |
| "//third_party/rust_crates:rand", |
| "//third_party/rust_crates:thiserror", |
| "//third_party/rust_crates:tracing", |
| |
| # TODO(https://fxbug.dev/42175119): re-enable check includes when the inspect/client.shard.cml |
| # stops exposing diagnostics from framework. |
| "//src/lib/diagnostics/inspect/runtime/rust:unchecked_includes", |
| ] |
| |
| common_test_deps = [ |
| "//src/connectivity/lib/fidl_fuchsia_net_stack_ext", |
| "//src/connectivity/lib/ip-test-macro", |
| "//src/connectivity/lib/net-declare", |
| "//src/connectivity/network/testing/netemul/network-context/fidl:network_rust", |
| "//src/connectivity/network/testing/netemul/rust:lib", |
| "//src/lib/diagnostics/hierarchy/rust", |
| "//src/lib/diagnostics/testing/diagnostics-assertions/rust:diagnostics-assertions", |
| "//src/lib/network/fidl_fuchsia_net_ext", |
| "//src/lib/testing/fixture", |
| "//third_party/rust_crates:futures-lite", |
| "//third_party/rust_crates:itertools", |
| "//third_party/rust_crates:test-case", |
| "//third_party/rust_crates:tracing", |
| "//third_party/rust_crates:tracing-subscriber", |
| ] |
| |
| common_sources = [ |
| "src/bindings.rs", |
| "src/bindings/debug_fidl_worker.rs", |
| "src/bindings/devices.rs", |
| "src/bindings/filter.rs", |
| "src/bindings/filter/controller.rs", |
| "src/bindings/filter/conversion.rs", |
| "src/bindings/filter/conversion/actions.rs", |
| "src/bindings/filter/conversion/matchers.rs", |
| "src/bindings/inspect.rs", |
| "src/bindings/integration_tests.rs", |
| "src/bindings/interfaces_admin.rs", |
| "src/bindings/interfaces_watcher.rs", |
| "src/bindings/name_worker.rs", |
| "src/bindings/neighbor_worker.rs", |
| "src/bindings/netdevice_worker.rs", |
| "src/bindings/resource_removal.rs", |
| "src/bindings/root_fidl_worker.rs", |
| "src/bindings/routes.rs", |
| "src/bindings/routes/admin.rs", |
| "src/bindings/routes/state.rs", |
| "src/bindings/routes/witness.rs", |
| "src/bindings/socket.rs", |
| "src/bindings/socket/datagram.rs", |
| "src/bindings/socket/packet.rs", |
| "src/bindings/socket/queue.rs", |
| "src/bindings/socket/raw.rs", |
| "src/bindings/socket/stream.rs", |
| "src/bindings/socket/worker.rs", |
| "src/bindings/stack_fidl_worker.rs", |
| "src/bindings/timers.rs", |
| "src/bindings/util.rs", |
| "src/bindings/verifier_worker.rs", |
| "src/main.rs", |
| ] |
| |
| network_unified_binary("bin") { |
| name = "netstack3" |
| edition = "2021" |
| with_unit_tests = true |
| |
| deps = [ |
| "core:netstack3-core", |
| "fuchsia:netstack3-fuchsia", |
| ] + common_deps |
| |
| test_deps = common_test_deps |
| |
| sources = common_sources |
| |
| # Only add the netstack3 configs to the bin, not GUB because O3 in the default |
| # config causes binary size increases here. |
| bin_add_configs = [ ":netstack3_configs" ] |
| add_configs = [] |
| |
| # Profile the binary and GUB library builds when requested. |
| if (netstack3_profile_rustc) { |
| add_configs += [ ":compiler_profile" ] |
| } |
| } |
| |
| # See netstack3_profile_rustc GN arg for details here. |
| config("compiler_profile") { |
| rustflags = [ |
| "-Ztime-passes", |
| "-Zllvm-time-trace", |
| "-Zself-profile", |
| ] |
| visibility = [ ":*" ] |
| } |
| |
| # TODO(https://fxbug.dev/330735964): remove this config when Netstack3 doesn't |
| # OOM on ThinLTO builders. |
| config("disable-rbe") { |
| if (rust_rbe_enable) { |
| # --remote-flag=* is a pseudo flag that is intercepted by |
| # build/rbe/rustc_remote_wrapper.py. |
| rustflags = [ "--remote-disable" ] |
| } |
| } |
| |
| config("netstack3_configs") { |
| if (!is_debug) { |
| configs = [ |
| # Always optimize speed, even if it increases size. |
| "//build/config:optimize_speed", |
| ] |
| |
| # Add thinlto config if lto variants are not used. |
| if (!is_lto_variant) { |
| # Allow cross-crate optimization since netstack3 is split between multiple |
| # crates. |
| configs += [ "//build/config/lto:thinlto" ] |
| } |
| } |
| } |
| |
| rustc_binary("bin-instrumented") { |
| name = "netstack3-instrumented" |
| edition = "2021" |
| with_unit_tests = true |
| |
| deps = [ |
| "core:netstack3-core-instrumented", |
| "fuchsia:netstack3-fuchsia-instrumented", |
| ] + common_deps |
| features = [ "instrumented" ] |
| |
| test_deps = common_test_deps |
| |
| sources = common_sources |
| configs -= [ "//build/config/rust/lints:allow_unused_results" ] |
| } |
| |
| network_unified_binary_regular_and_gub_components("component") { |
| component_name = "netstack3" |
| manifest = "meta/netstack3.cml" |
| gub_deps = [ ":bin" ] |
| } |
| |
| # Component with debugging instrumentation enabled. This should be used for |
| # tests but not benchmarks. |
| fuchsia_component("component-debug") { |
| component_name = "netstack3-debug" |
| manifest = "meta/netstack3_debug.cml" |
| deps = [ ":bin-instrumented" ] |
| testonly = true |
| } |
| |
| # Drop-in component with the name "netstack" rather than "netstack3." |
| fuchsia_component("component-dropin") { |
| component_name = "netstack" |
| manifest = "meta/netstack3.cml" |
| deps = [ ":bin" ] |
| } |
| fuchsia_component("component-debug-dropin") { |
| component_name = "netstack-debug" |
| manifest = "meta/netstack3_debug.cml" |
| deps = [ ":bin-instrumented" ] |
| testonly = true |
| } |
| |
| fuchsia_unittest_component("netstack3-bin_test") { |
| deps = [ |
| ":bin_test", |
| "//src/connectivity/network/testing/netemul/service:netemul-sandbox", |
| ] |
| } |
| |
| fuchsia_unittest_component("netstack3-bin-instrumented_test") { |
| deps = [ |
| ":bin-instrumented_test", |
| "//src/connectivity/network/testing/netemul/service:netemul-sandbox", |
| ] |
| } |
| |
| fuchsia_test_package("netstack3-tests") { |
| test_components = [ |
| ":netstack3-bin_test", |
| ":netstack3-bin-instrumented_test", |
| ] |
| } |
| |
| group("benchmarks") { |
| testonly = true |
| deps = [ "bench" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| ":netstack3-tests", |
| "core:tests", |
| ] |
| } |