blob: 0d85d2fd7ab2135170ddadc9b1d3d20403d2a591 [file] [edit]
# 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.
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@platforms//host:constraints.bzl", "HOST_CONSTRAINTS")
load("//build/bazel/bazel_idk:defs.bzl", "idk_go_binary_host_tool")
load("//build/tools/bazel2gn/bazel_rules:defs.bzl", "install_host_tools")
go_library(
name = "lib",
srcs = [
"cmd/common.go",
"cmd/dnssderrors.go",
"cmd/dnssdfinder.go",
"cmd/dnssdfinder.h",
"cmd/dnssdfinder_c.c",
"cmd/finders.go",
"cmd/list.go",
"cmd/main.go",
"cmd/resolve.go",
],
cgo = True,
target_compatible_with = HOST_CONSTRAINTS,
deps = [
"//third_party/golibs:github.com/google/subcommands",
"//tools/lib/color",
"//tools/lib/logger",
"//tools/net/mdns",
"//tools/net/netboot",
],
)
idk_go_binary_host_tool(
name = "device-finder",
api_area = "Developer",
category = "partner",
embed = [":lib"],
idk_name = "device-finder",
# Forces PIE mode, otherwise linking against CGO library would fail with `recompile with -fPIC`.
linkmode = "pie", # @bazel2gn:skip
# We turn on pure mode globally for build consistency, see https://fxbug.dev/489925970.
#
# Here we need to turn it off because `lib` needs CGO support, and pure mode disables CGO.
pure = "off", # @bazel2gn:skip
target_compatible_with = HOST_CONSTRAINTS,
)
go_test(
name = "dev_finder_tests",
srcs = [
"cmd/dev_finder_test.go",
],
embed = [
":lib",
],
target_compatible_with = HOST_CONSTRAINTS,
deps = [
"//third_party/golibs:github.com/google/go-cmp/cmp",
],
)
install_host_tools(
name = "host",
implementation_deps = [":device-finder"],
target_compatible_with = HOST_CONSTRAINTS,
tool_output_names = ["device-finder"],
)