Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GO_TOOLCHAIN string to Label and add toolchain param to one more action #3762

Merged
merged 4 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def _gomock_source_impl(ctx):
ctx.file.mockgen_tool,
go_ctx.go,
],
toolchain = GO_TOOLCHAIN,
command = """
export GOPATH=$(pwd)/{gopath} &&
{cmd} {args} > {out}
Expand Down Expand Up @@ -147,7 +148,7 @@ _gomock_source = rule(
default = "//:go_context_data",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def gomock(name, library, out, source = None, interfaces = [], package = "", self_package = "", aux_files = {}, mockgen_tool = _MOCKGEN_TOOL, imports = {}, copyright_file = None, mock_names = {}, **kwargs):
Expand Down Expand Up @@ -278,7 +279,7 @@ _gomock_prog_gen = rule(
default = "//:go_context_data",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def _gomock_prog_exec_impl(ctx):
Expand Down Expand Up @@ -360,7 +361,7 @@ _gomock_prog_exec = rule(
default = "//:go_context_data",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def _handle_shared_args(ctx, args):
Expand Down
2 changes: 1 addition & 1 deletion go/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain"
GO_TOOLCHAIN = Label("@io_bazel_rules_go//go:toolchain")
fmeum marked this conversation as resolved.
Show resolved Hide resolved

go_exts = [
".go",
Expand Down
2 changes: 1 addition & 1 deletion go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ go_context_data = rule(
},
doc = """go_context_data gathers information about the build configuration.
It is a common dependency of all Go targets.""",
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
cfg = request_nogo_transition,
)

Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ _go_binary_kwargs = {
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
"toolchains": [GO_TOOLCHAIN],
"toolchains": [str(GO_TOOLCHAIN)],
"doc": """This builds an executable from a set of source files,
which must all be in the `main` package. You can run the binary with
`bazel run`, or you can build it with `bazel build` and run it directly.<br><br>
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/go_bin_for_host.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _go_bin_for_host_impl(ctx):

go_bin_for_host = rule(
implementation = _go_bin_for_host_impl,
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
# Resolve a toolchain that runs on the host platform.
exec_compatible_with = HOST_CONSTRAINTS,
)
2 changes: 1 addition & 1 deletion go/private/rules/info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ _go_info = rule(
default = "//:go_context_data",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def go_info():
Expand Down
4 changes: 2 additions & 2 deletions go/private/rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ go_library = rule(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
doc = """This builds a Go library from a set of source files that are all part of
the same package.<br><br>
***Note:*** For targets generated by Gazelle, `name` is typically the last component of the path,
Expand Down Expand Up @@ -211,7 +211,7 @@ go_tool_library = rule(
"_cgo_context_data": attr.label(default = "//:cgo_context_data_proxy"),
"_stdlib": attr.label(default = "//:stdlib"),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)
# This is used instead of `go_library` for dependencies of the `nogo` rule and
# packages that are depended on implicitly by code generated within the Go rules.
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/nogo.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ _nogo = rule(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
cfg = go_tool_transition,
)

Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/source.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ go_source = rule(
"_go_config": attr.label(default = "//:go_config"),
"_cgo_context_data": attr.label(default = "//:cgo_context_data_proxy"),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
doc = """This declares a set of source files and related dependencies that can be embedded into one of the
other rules.
This is used as a way of easily declaring a common set of sources re-used in multiple rules.<br><br>
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ stdlib = rule(
},
doc = """stdlib builds the standard library for the target configuration
or uses the precompiled standard library from the SDK if it is suitable.""",
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)
2 changes: 1 addition & 1 deletion go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ _go_test_kwargs = {
},
"executable": True,
"test": True,
"toolchains": [GO_TOOLCHAIN],
"toolchains": [str(GO_TOOLCHAIN)],
"doc": """This builds a set of tests that can be run with `bazel test`.<br><br>
To run all tests in the workspace, and print output on failure (the
equivalent of `go test ./...`), run<br>
Expand Down
2 changes: 1 addition & 1 deletion proto/compiler.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ _go_proto_compiler = rule(
default = "//:go_context_data",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def go_proto_compiler(name, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions proto/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ _go_proto_aspect = aspect(
"deps",
"embed",
],
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)

def _proto_library_to_source(_go, attr, source, merge):
Expand Down Expand Up @@ -178,7 +178,7 @@ go_proto_library = rule(
default = "@bazel_tools//tools/allowlists/function_transition_allowlist",
),
},
toolchains = [GO_TOOLCHAIN],
toolchains = [str(GO_TOOLCHAIN)],
)
# go_proto_library is a rule that takes a proto_library (in the proto
# attribute) and produces a go library for it.
Expand Down