Skip to content

Commit

Permalink
Bazel 5.4.0 supports toolchain's registration only as a String, not L…
Browse files Browse the repository at this point in the history
…abel
  • Loading branch information
kotlaja committed Nov 22, 2023
1 parent 2f29bd3 commit 1bc3da1
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 17 deletions.
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=5.4.0
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")

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

0 comments on commit 1bc3da1

Please sign in to comment.