Skip to content

Commit

Permalink
Set rulesGoStdlibPrefix as ldflag of go_tool_binary
Browse files Browse the repository at this point in the history
Adapt toolchain with changes from bazel-contrib/rules_go#3701
  • Loading branch information
malt3 committed Nov 2, 2023
1 parent 52d34c0 commit 26ecfcf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion toolchains/go/go.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,19 @@ nixpkgs_go_toolchain = repository_rule(
go_sdk_build = """
load("@{rules_go}//go/private/rules:binary.bzl", "go_tool_binary")
load("@{rules_go}//go/private/rules:sdk.bzl", "package_list")
load("@{rules_go}//go:def.bzl", "go_sdk")
load("@{rules_go}//go:def.bzl", "go_sdk", "RULES_GO_VERSION")
load("@{helpers}//:go_sdk.bzl", "go_sdk_for_arch")
load(":go_version.bzl", "go_version")
package(default_visibility = ["//visibility:public"])
go_sdk_for_arch(go_version)
# rules_go >= 0.42.0 requires a stdlib prefix
TOOL_BINARY_NEEDS_STDLIB_PREFIX = (int(RULES_GO_VERSION.split(".")[0]) > 0) or (int(RULES_GO_VERSION.split(".")[1]) >= 42)
None if TOOL_BINARY_NEEDS_STDLIB_PREFIX else \
print("WARNING: rules_go %s is deprecated and support will soon be removed. Upgrade to rules_go >= 0.42.0. See https://github.com/tweag/rules_nixpkgs/issues/421 for more information." % (RULES_GO_VERSION))
filegroup(
name = "headers",
srcs = glob(["pkg/include/*.h"]),
Expand All @@ -237,6 +242,7 @@ filegroup(
go_tool_binary(
name = "builder",
srcs = ["@{rules_go}//go/tools/builders:builder_srcs"],
ldflags = "-X main.rulesGoStdlibPrefix=@{rules_go}//stdlib:" if TOOL_BINARY_NEEDS_STDLIB_PREFIX else None,
sdk = ":go_sdk",
)
Expand Down

0 comments on commit 26ecfcf

Please sign in to comment.