Skip to content

Commit

Permalink
Go: workaround for gazelle on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
redsun82 committed Apr 29, 2024
1 parent d66494d commit b0758fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions go/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down

0 comments on commit b0758fd

Please sign in to comment.