Go: workaround for gazelle on macOS

See https://github.com/bazelbuild/bazel-gazelle/issues/1793 for details.
This commit is contained in:
Paolo Tranquilli
2024-04-29 10:29:53 +02:00
parent d66494dcb0
commit b0758fd109
2 changed files with 18 additions and 1 deletions

View File

@@ -56,7 +56,11 @@ node.toolchain(
use_repo(node, "nodejs", "nodejs_toolchains")
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk")
go_sdk.download(version = "1.22.2")
go_sdk.download(version = "1.22.2") # default
# following is needed for gazelle on macOS
# see https://github.com/bazelbuild/bazel-gazelle/issues/1793
go_sdk.download(version = "1.21.9")
register_toolchains(
"@nodejs_toolchains//:all",

View File

@@ -1,12 +1,25 @@
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_go//go:def.bzl", "go_cross_binary")
load("@rules_pkg//pkg:install.bzl", "pkg_install")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files")
load("//:defs.bzl", "codeql_platform")
# following is needed for running gazelle on macOS
# see https://github.com/bazelbuild/bazel-gazelle/issues/1793
go_cross_binary(
name = "gazelle-1.21.9",
sdk_version = "1.21.9",
target = "@gazelle//cmd/gazelle",
)
gazelle(
name = "gazelle",
extra_args = ["go/extractor"],
gazelle = select({
"@platforms//os:macos": ":gazelle-1.21.9",
"//conditions:default": "@gazelle//cmd/gazelle",
}),
)
_gen_binaries = [