Skip to content

Commit 2d0a6f7

Browse files
avagingvisor-bot
authored andcommitted
tools/bazeldefs: always pass bazel_cgo to go_library
Its value will be known only on the configuration phase, before that it can be a select directive. Updates #9266 PiperOrigin-RevId: 678412518
1 parent 9488cfc commit 2d0a6f7

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

pkg/sentry/socket/plugin/cgo/BUILD

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@ go_library(
1919
"stack_unsafe.go",
2020
"util_unsafe.go",
2121
],
22-
bazel_cdeps = [
23-
"@libpluginstack//:libpluginstack",
24-
],
22+
bazel_cdeps = select({
23+
":network_plugins": ["@libpluginstack//:libpluginstack"],
24+
"//conditions:default": [],
25+
}),
2526
bazel_cgo = select({
2627
":network_plugins": True,
2728
"//conditions:default": False,
2829
}),
29-
bazel_clinkopts = [
30-
"-L external/libpluginstack",
31-
],
32-
bazel_copts = [
33-
"-march=native",
34-
"-I external/libpluginstack/lib/libtle_glue",
35-
],
30+
bazel_clinkopts = select({
31+
":network_plugins": ["-L external/libpluginstack"],
32+
"//conditions:default": [],
33+
}),
34+
bazel_copts = select({
35+
":network_plugins": [
36+
"-march=native",
37+
"-I external/libpluginstack/lib/libtle_glue",
38+
],
39+
"//conditions:default": [],
40+
}),
3641
visibility = ["//visibility:public"],
3742
deps = [
3843
"//pkg/abi/linux",

tools/bazeldefs/go.bzl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ def go_library(name, bazel_cgo = False, bazel_cdeps = [], bazel_clinkopts = [],
8585
cgo_copts: cgo opts to pass to `go_library`.
8686
**kwargs: rest of the arguments are passed to `go_library`.
8787
"""
88-
if bazel_cgo == True:
89-
kwargs["cgo"] = bazel_cgo
90-
kwargs["cdeps"] = bazel_cdeps
91-
kwargs["clinkopts"] = bazel_clinkopts
92-
kwargs["copts"] = bazel_copts
9388
_go_library(
9489
name = name,
90+
cgo = bazel_cgo,
91+
cdeps = bazel_cdeps,
92+
copts = bazel_copts,
93+
clinkopts = bazel_clinkopts,
9594
importpath = "gvisor.dev/gvisor/" + native.package_name(),
9695
**kwargs
9796
)

0 commit comments

Comments
 (0)