Skip to content

Commit

Permalink
Trim transitioned Go settings on non-Go dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
fmeum committed Apr 8, 2022
1 parent f038f72 commit 905bf39
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ load(
)
load(
"//go/private/rules:transition.bzl",
"go_non_go_reset_transition",
"go_transition_rule",
)
load(
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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`
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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"],
Expand Down
11 changes: 11 additions & 0 deletions go/private/rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 905bf39

Please sign in to comment.