From b0c53f8475d14606ef82aeddfb2f742269c1b5b7 Mon Sep 17 00:00:00 2001 From: Adin Scannell Date: Tue, 25 Aug 2020 12:16:31 -0700 Subject: Add nogo support to go_binary and go_test targets. Updates #3374 PiperOrigin-RevId: 328378700 --- tools/bazeldefs/defs.bzl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'tools/bazeldefs/defs.bzl') 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( -- cgit v1.2.3