diff options
author | Adin Scannell <ascannell@google.com> | 2020-08-25 12:16:31 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-08-25 12:18:25 -0700 |
commit | b0c53f8475d14606ef82aeddfb2f742269c1b5b7 (patch) | |
tree | 758f77d07ea16b97cf1b81729fae0577b87c9f08 /tools/bazeldefs | |
parent | b83758cd875be8fea521c6bb51b4ba6b41a690a9 (diff) |
Add nogo support to go_binary and go_test targets.
Updates #3374
PiperOrigin-RevId: 328378700
Diffstat (limited to 'tools/bazeldefs')
-rw-r--r-- | tools/bazeldefs/defs.bzl | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/bazeldefs/defs.bzl b/tools/bazeldefs/defs.bzl index db7f379b8..4bbcda054 100644 --- a/tools/bazeldefs/defs.bzl +++ b/tools/bazeldefs/defs.bzl @@ -87,13 +87,14 @@ def cc_binary(name, static = False, **kwargs): **kwargs ) -def go_binary(name, static = False, pure = False, **kwargs): +def go_binary(name, static = False, pure = False, x_defs = None, **kwargs): """Build a go binary. Args: name: name of the target. static: build a static binary. pure: build without cgo. + x_defs: additional definitions. **kwargs: rest of the arguments are passed to _go_binary. """ if static: @@ -102,6 +103,7 @@ def go_binary(name, static = False, pure = False, **kwargs): kwargs["pure"] = "on" _go_binary( name = name, + x_defs = x_defs, **kwargs ) @@ -151,6 +153,11 @@ def go_rule(rule, implementation, **kwargs): toolchains = kwargs.get("toolchains", []) + ["@io_bazel_rules_go//go:toolchain"] return rule(implementation, attrs = attrs, toolchains = toolchains, **kwargs) +def go_test_library(target): + if hasattr(target.attr, "embed") and len(target.attr.embed) > 0: + return target.attr.embed[0] + return None + def go_context(ctx): go_ctx = _go_context(ctx) return struct( |