From 905bf39d2dccedf22c094cef70b73cab2097f8d1 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Fri, 8 Apr 2022 16:04:02 +0200 Subject: [PATCH] Trim transitioned Go settings on non-Go dependencies --- go/private/rules/binary.bzl | 8 ++++++++ go/private/rules/library.bzl | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/go/private/rules/binary.bzl b/go/private/rules/binary.bzl index 78e74e26af..c1b227750f 100644 --- a/go/private/rules/binary.bzl +++ b/go/private/rules/binary.bzl @@ -29,6 +29,7 @@ load( ) load( "//go/private/rules:transition.bzl", + "go_non_go_reset_transition", "go_transition_rule", ) load( @@ -160,6 +161,7 @@ _go_binary_kwargs = { "attrs": { "srcs": attr.label_list( allow_files = go_exts + asm_exts + cgo_exts, + cfg = go_non_go_reset_transition, doc = """The list of Go source files that are compiled to create the package. Only `.go` and `.s` files are permitted, unless the `cgo` attribute is set, in which case, @@ -170,6 +172,7 @@ _go_binary_kwargs = { ), "data": attr.label_list( allow_files = True, + cfg = go_non_go_reset_transition, doc = """List of files needed by this rule at run-time. This may include data files needed or other programs that may be executed. The [bazel] package may be used to locate run files; they may appear in different places depending on the @@ -197,6 +200,7 @@ _go_binary_kwargs = { ), "embedsrcs": attr.label_list( allow_files = True, + cfg = go_non_go_reset_transition, doc = """The list of files that may be embedded into the compiled package using `//go:embed` directives. All files must be in the same logical directory or a subdirectory as source files. All source files containing `//go:embed` @@ -249,6 +253,7 @@ _go_binary_kwargs = { """, ), "cdeps": attr.label_list( + cfg = go_non_go_reset_transition, doc = """The list of other libraries that the c code depends on. This can be anything that would be allowed in [cc_library deps] Only valid if `cgo` = `True`. @@ -358,6 +363,9 @@ _go_binary_kwargs = { """, ), "_go_context_data": attr.label(default = "//:go_context_data"), + "_whitelist_function_transition": attr.label( + default = "@bazel_tools//tools/whitelists/function_transition_whitelist", + ), }, "executable": True, "toolchains": ["@io_bazel_rules_go//go:toolchain"], diff --git a/go/private/rules/library.bzl b/go/private/rules/library.bzl index 325f87ecc8..8f000d4d28 100644 --- a/go/private/rules/library.bzl +++ b/go/private/rules/library.bzl @@ -27,6 +27,10 @@ load( "GoLibrary", "INFERRED_PATH", ) +load( + "//go/private/rules:transition.bzl", + "go_non_go_reset_transition", +) def _go_library_impl(ctx): """Implements the go_library() rule.""" @@ -55,6 +59,7 @@ go_library = rule( attrs = { "data": attr.label_list( allow_files = True, + cfg = go_non_go_reset_transition, doc = """ List of files needed by this rule at run-time. This may include data files needed or other programs that may be executed. @@ -64,6 +69,7 @@ go_library = rule( ), "srcs": attr.label_list( allow_files = go_exts + asm_exts + cgo_exts, + cfg = go_non_go_reset_transition, doc = """ The list of Go source files that are compiled to create the package. Only `.go` and `.s` files are permitted, unless the `cgo` attribute is set, @@ -106,6 +112,7 @@ go_library = rule( ), "embedsrcs": attr.label_list( allow_files = True, + cfg = go_non_go_reset_transition, doc = """ The list of files that may be embedded into the compiled package using `//go:embed` directives. All files must be in the same logical directory or a subdirectory as source files. @@ -133,6 +140,7 @@ go_library = rule( """, ), "cdeps": attr.label_list( + cfg = go_non_go_reset_transition, doc = """ List of other libraries that the c code depends on. This can be anything that would be allowed in [cc_library deps] Only valid if `cgo = True`. @@ -164,6 +172,9 @@ go_library = rule( """, ), "_go_context_data": attr.label(default = "//:go_context_data"), + "_whitelist_function_transition": attr.label( + default = "@bazel_tools//tools/whitelists/function_transition_whitelist", + ), }, toolchains = ["@io_bazel_rules_go//go:toolchain"], doc = """This builds a Go library from a set of source files that are all part of