Skip to content

Commit

Permalink
go_library wrapper: Add bazel_cgo and cgo-related arguments.
Browse files Browse the repository at this point in the history
This adds cgo-only arguments passed to `go_library` rules when the
`bazel_cgo` argument is specified and `True`.

Credits go to @avagin for this change.

Updates #9266
Updates #9551

PiperOrigin-RevId: 677085717
  • Loading branch information
EtiennePerot authored and gvisor-bot committed Sep 21, 2024
1 parent 49310d9 commit a7dcce9
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tools/bazeldefs/go.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,22 @@ def go_importpath(target):
"""Returns the importpath for the target."""
return target[GoLibrary].importpath

def go_library(name, arch_deps = [], **kwargs):
def go_library(name, bazel_cgo = False, cgo_cdeps = [], cgo_clinkopts = [], cgo_copts = [], **kwargs):
"""Wrapper for `go_library` rule.
Args:
name: name of the target.
bazel_cgo: if True, build with cgo.
cgo_cdeps: cgo deps to pass to `go_library`.
cgo_clinkopts: cgo linkopts to pass to `go_library`.
cgo_copts: cgo opts to pass to `go_library`.
**kwargs: rest of the arguments are passed to `go_library`.
"""
if bazel_cgo == True:
kwargs["cgo"] = bazel_cgo
kwargs["cdeps"] = cgo_cdeps
kwargs["clinkopts"] = cgo_clinkopts
kwargs["copts"] = cgo_copts
_go_library(
name = name,
importpath = "gvisor.dev/gvisor/" + native.package_name(),
Expand Down

0 comments on commit a7dcce9

Please # to comment.