Skip to content

Commit

Permalink
Add toolchain param to affected actions (#3740)
Browse files Browse the repository at this point in the history
* Add toolchain param to affected actions

* Move GO_TOOLCHAIN to common.bzl

* Update new location of GO_TOOLCHAIN

* Fix error

* Format files
  • Loading branch information
kotlaja authored Oct 31, 2023
1 parent 37ae8b3 commit 4211c6d
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 26 deletions.
2 changes: 1 addition & 1 deletion extras/gomock.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# DO NOT USE IT.

load("//go/private:context.bzl", "go_context")
load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN")
load("//go/private:common.bzl", "GO_TOOLCHAIN")
load("//go/private/rules:wrappers.bzl", go_binary = "go_binary_macro")
load("//go/private:providers.bzl", "GoLibrary")
load("@bazel_skylib//lib:paths.bzl", "paths")
Expand Down
2 changes: 2 additions & 0 deletions go/private/actions/compilepkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

load("//go/private:common.bzl", "GO_TOOLCHAIN")
load(
"//go/private:mode.bzl",
"link_mode_args",
Expand Down Expand Up @@ -162,4 +163,5 @@ def emit_compilepkg(
executable = go.toolchain._builder,
arguments = [args],
env = go.env,
toolchain = GO_TOOLCHAIN,
)
2 changes: 2 additions & 0 deletions go/private/actions/link.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"as_set",
"count_group_matches",
"has_shared_lib_extension",
Expand Down Expand Up @@ -209,6 +210,7 @@ def emit_link(
executable = go.toolchain._builder,
arguments = [builder_args, "--", tool_args],
env = go.env,
toolchain = GO_TOOLCHAIN,
)

def _extract_extldflags(gc_linkopts, extldflags):
Expand Down
3 changes: 3 additions & 0 deletions go/private/actions/stdlib.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
load(
"//go/private:common.bzl",
"COVERAGE_OPTIONS_DENYLIST",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
Expand Down Expand Up @@ -82,6 +83,7 @@ def _build_stdlib_list_json(go):
executable = go.toolchain._builder,
arguments = [args],
env = _build_env(go),
toolchain = GO_TOOLCHAIN,
)
return out

Expand Down Expand Up @@ -149,6 +151,7 @@ def _build_stdlib(go):
executable = go.toolchain._builder,
arguments = [args],
env = _build_env(go),
toolchain = GO_TOOLCHAIN,
)
return GoStdLib(
_list_json = _build_stdlib_list_json(go),
Expand Down
2 changes: 2 additions & 0 deletions go/private/common.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain"

go_exts = [
".go",
]
Expand Down
5 changes: 1 addition & 4 deletions go/private/context.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ load(
"OBJCPP_COMPILE_ACTION_NAME",
"OBJC_COMPILE_ACTION_NAME",
)
load(
":go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
":providers.bzl",
"CgoContextInfo",
Expand All @@ -52,6 +48,7 @@ load(
load(
":common.bzl",
"COVERAGE_OPTIONS_DENYLIST",
"GO_TOOLCHAIN",
"as_iterable",
"goos_to_extension",
"goos_to_shared_extension",
Expand Down
3 changes: 1 addition & 2 deletions go/private/go_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
Toolchain rules used by go.
"""

load("//go/private:common.bzl", "GO_TOOLCHAIN")
load("//go/private:platforms.bzl", "PLATFORMS")
load("//go/private:providers.bzl", "GoSDK")
load("//go/private/actions:archive.bzl", "emit_archive")
Expand All @@ -23,8 +24,6 @@ load("//go/private/actions:link.bzl", "emit_link")
load("//go/private/actions:stdlib.bzl", "emit_stdlib")
load("@bazel_skylib//lib:selects.bzl", "selects")

GO_TOOLCHAIN = "@io_bazel_rules_go//go:toolchain"

def _go_toolchain_impl(ctx):
sdk = ctx.attr.sdk[GoSDK]
cross_compile = ctx.attr.goos != sdk.goos or ctx.attr.goarch != sdk.goarch
Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/binary.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ load(
)
load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"asm_exts",
"cgo_exts",
"go_exts",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
"GoLibrary",
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 @@ -13,7 +13,7 @@
# limitations under the License.

load("@local_config_platform//:constraints.bzl", "HOST_CONSTRAINTS")
load("//go/private:go_toolchain.bzl", "GO_TOOLCHAIN")
load("//go/private:common.bzl", "GO_TOOLCHAIN")

def _ensure_target_cfg(ctx):
# A target is assumed to be built in the target configuration if it is neither in the exec nor
Expand Down
2 changes: 1 addition & 1 deletion go/private/rules/info.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)

Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"asm_exts",
"cgo_exts",
"go_exts",
Expand All @@ -22,10 +23,6 @@ load(
"//go/private:context.bzl",
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private:providers.bzl",
"GoLibrary",
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 @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
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 @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
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 @@ -17,7 +17,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
5 changes: 1 addition & 4 deletions go/private/rules/test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,13 @@ load(
)
load(
"//go/private:common.bzl",
"GO_TOOLCHAIN",
"as_list",
"asm_exts",
"cgo_exts",
"go_exts",
"split_srcs",
)
load(
"//go/private:go_toolchain.bzl",
"GO_TOOLCHAIN",
)
load(
"//go/private/rules:binary.bzl",
"gc_linkopts",
Expand Down
2 changes: 1 addition & 1 deletion proto/compiler.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ load(
"go_context",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down
2 changes: 1 addition & 1 deletion proto/def.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ load(
"proto_path",
)
load(
"//go/private:go_toolchain.bzl",
"//go/private:common.bzl",
"GO_TOOLCHAIN",
)
load(
Expand Down

0 comments on commit 4211c6d

Please sign in to comment.