blob: e4f3cd951b80309dd60f1e2e9affeb92f01bc6d6 [file] [log] [blame]
# Copyright 2016 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/go/go_library.gni")
import("//build/go/go_test.gni")
import("//build/go/toolchain.gni")
import("//src/go/grand_unified_binary/gub.gni")
import("//src/sys/build/components.gni")
import("//third_party/cobalt/metrics_registry.gni")
import("gentool/generated.gni")
grand_unified_binary("bin") {
output_name = "netstack"
}
fuchsia_component("component-v2") {
component_name = "netstack"
manifest = "meta/netstack.cml"
deps = [ ":bin" ]
}
fuchsia_component("component") {
component_name = "netstack"
manifest = "meta/netstack.cmx"
deps = [ ":bin" ]
}
fuchsia_component("component-debug") {
testonly = true
component_name = "netstack-debug"
manifest = "meta/netstack_debug.cmx"
deps = [ ":bin" ]
}
fuchsia_package("netstack") {
deps = [ ":component" ]
}
fuchsia_shell_package("tools") {
deps = [ "ifconfig" ]
}
metrics_registry("networking_metrics") {
# This must match the ID of our Cobalt project as specified in:
# third_party/cobalt_config/projects.yaml
project_id = 1
go_package_name = "networking_metrics"
generate_go = true
generate_rust = true
generate_binarypb = false
}
tests = []
foreach(name,
[
"netstack_bench_test",
"netstack_fidlconv_test",
"netstack_filter_test",
"netstack_link_bridge_test",
"netstack_link_eth_test",
"netstack_link_fifo_test",
"netstack_link_netdevice_test",
"netstack_test",
]) {
component_name = "$name-component"
fuchsia_unittest_component(component_name) {
component_name = name
deps = [ ":$name" ]
manifest = "meta/$name.cmx"
}
tests += [ ":$component_name" ]
}
fuchsia_test_package("netstack-gotests") {
deps = [ "//src/connectivity/network/tun/network-tun:component" ]
test_components = tests
}
generated_go("gen/netstack") {
definitions = [
{
src = "link/eth/handler.json"
package = "link/eth"
template = "link/fifo/gen/handler.tmpl"
copy = [ "link/fifo/gen/fifo_entry.go" ]
},
{
src = "link/eth/entries.json"
package = "link/eth"
template = "link/fifo/gen/entries.tmpl"
},
{
src = "link/netdevice/handler.json"
package = "link/netdevice"
template = "link/fifo/gen/handler.tmpl"
},
{
src = "link/netdevice/entries.json"
package = "link/netdevice"
template = "link/fifo/gen/entries.tmpl"
},
]
}
go_library("netstack_lib") {
name = "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/..."
deps = [
":gen/netstack",
":networking_metrics_golib",
"fidlext/fuchsia/hardware/ethernet",
"//sdk/fidl/fuchsia.cobalt($go_toolchain)",
"//sdk/fidl/fuchsia.device($go_toolchain)",
"//sdk/fidl/fuchsia.hardware.ethernet($go_toolchain)",
"//sdk/fidl/fuchsia.hardware.network($go_toolchain)",
"//sdk/fidl/fuchsia.inspect.deprecated($go_toolchain)",
"//sdk/fidl/fuchsia.net($go_toolchain)",
"//sdk/fidl/fuchsia.net.dhcp($go_toolchain)",
"//sdk/fidl/fuchsia.net.filter($go_toolchain)",
"//sdk/fidl/fuchsia.net.interfaces($go_toolchain)",
"//sdk/fidl/fuchsia.net.name($go_toolchain)",
"//sdk/fidl/fuchsia.net.neighbor($go_toolchain)",
"//sdk/fidl/fuchsia.net.routes($go_toolchain)",
"//sdk/fidl/fuchsia.net.stack($go_toolchain)",
"//sdk/fidl/fuchsia.net.tun($go_toolchain)",
"//sdk/fidl/fuchsia.netstack($go_toolchain)",
"//sdk/fidl/fuchsia.posix($go_toolchain)",
"//sdk/fidl/fuchsia.posix.socket($go_toolchain)",
"//sdk/fidl/fuchsia.stash($go_toolchain)",
"//sdk/fidl/fuchsia.sys($go_toolchain)",
"//src/lib/component",
"//src/lib/syslog/go",
"//third_party/golibs:github.com/google/btree",
"//third_party/golibs:github.com/google/go-cmp",
"//third_party/golibs:go.uber.org/multierr",
"//third_party/golibs:golang.org/x/net",
"//third_party/golibs:golang.org/x/time",
"//third_party/golibs:gvisor.dev/gvisor",
]
sources = [
"bench/bench_test.go",
"dhcp/client.go",
"dhcp/dhcp.go",
"dhcp/dhcp_string.go",
"dhcp/dhcp_test.go",
"dhcp/server.go",
"dns/servers_config.go",
"dns/servers_config_test.go",
"errors.go",
"fidlconv/fidlconv.go",
"fidlconv/fidlconv_test.go",
"filter/filter.go",
"filter/filter_service.go",
"filter/filter_service_test.go",
"filter/filter_test.go",
"filter/matchers.go",
"fuchsia_inspect_inspect.go",
"fuchsia_inspect_inspect_test.go",
"fuchsia_net_dhcp.go",
"fuchsia_net_interfaces.go",
"fuchsia_net_interfaces_test.go",
"fuchsia_net_name_dns_server_watcher.go",
"fuchsia_net_name_dns_server_watcher_test.go",
"fuchsia_net_neighbor.go",
"fuchsia_net_neighbor_test.go",
"fuchsia_net_routes.go",
"fuchsia_net_stack.go",
"fuchsia_net_stack_test.go",
"fuchsia_posix_socket.go",
"ifconfig/ifconfig.go",
"ifconfig/ifconfig_test.go",
"inspect/validator/main.go",
"inspect/writer.go",
"link/bridge/bridge.go",
"link/bridge/bridge_test.go",
"link/bridge/bridgeable.go",
"link/controller.go",
"link/eth/client.go",
"link/eth/client_test.go",
"link/fifo/entries_test.go",
"link/fifo/gen/fifo_entry.go",
"link/fifo/mapped_vmo.go",
"link/fifo/stats.go",
"link/fifo/testutil/fifo_util.go",
"link/netdevice/client.go",
"link/netdevice/client_test.go",
"link/netdevice/mac_client.go",
"link/netdevice/session_config.go",
"main.go",
"ndp.go",
"ndp_test.go",
"netstack.go",
"netstack_service.go",
"netstack_service_impl_test.go",
"netstack_test.go",
"noop_endpoint_test.go",
"pprof/export.go",
"routes/routes.go",
"routes/routes_test.go",
"socket_conv.go",
"socket_encode.go",
"testutil/packet_buffer.go",
"util/parse.go",
"util/parse_test.go",
]
}
go_test("netstack_bench_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/bench" ]
deps = [ ":netstack_lib" ]
}
go_test("netstack_fidlconv_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/fidlconv" ]
deps = [ ":netstack_lib" ]
}
go_test("netstack_filter_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/filter" ]
deps = [ ":netstack_lib" ]
}
go_test("netstack_link_bridge_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/link/bridge" ]
deps = [ ":netstack_lib" ]
}
go_test("netstack_link_eth_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/link/eth" ]
deps = [ ":netstack_lib" ]
}
generated_go("entries_gen_test") {
definitions = [
{
src = "link/fifo/test_entries.json"
package = "entries"
template = "link/fifo/gen/entries.tmpl"
},
]
}
go_test("netstack_link_fifo_test") {
gopackages =
[ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/link/fifo" ]
deps = [
":entries_gen_test",
":netstack_lib",
]
}
go_test("netstack_link_netdevice_test") {
gopackages = [
"go.fuchsia.dev/fuchsia/src/connectivity/network/netstack/link/netdevice",
]
deps = [ ":netstack_lib" ]
}
go_test("netstack_test") {
gopackages = [ "go.fuchsia.dev/fuchsia/src/connectivity/network/netstack" ]
deps = [ ":netstack_lib" ]
}
group("tests") {
testonly = true
deps = [
":netstack-gotests",
"dhcp:netstack-dhcp-gotests",
"dns:netstack-dns-gotests",
"ifconfig:netstack-ifconfig-gotests",
"inspect/validator:tests",
"routes:netstack-routes-gotests",
"tests",
"util:tests",
]
}