Skip to content

Commit 8120a51

Browse files
authored
Fix printing of toolchain type label in error message (#20)
It used to print `//shell:toolchain_type`, now it should prepend the apparent repo name (if available).
1 parent 44fe1be commit 8120a51

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

shell/private/sh_executable.bzl

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
visibility(["//shell"])
1818

19-
_SH_TOOLCHAIN_TYPE = "//shell:toolchain_type"
19+
_SH_TOOLCHAIN_TYPE = Label("//shell:toolchain_type")
2020

2121
def _sh_executable_impl(ctx):
2222
if len(ctx.files.srcs) != 1:
@@ -123,10 +123,14 @@ def _launcher_for_windows(ctx, primary_output, main_file):
123123
# bazel_tools should always registers a toolchain for Windows, but it may have an empty path.
124124
sh_toolchain = ctx.toolchains[_SH_TOOLCHAIN_TYPE]
125125
if not sh_toolchain or not sh_toolchain.path:
126-
fail("""No suitable shell toolchain found:
126+
# Let fail print the toolchain type with an apparent repo name.
127+
fail(
128+
"""No suitable shell toolchain found:
127129
* if you are running Bazel on Windows, set the BAZEL_SH environment variable to the path of bash.exe
128-
* if you are running Bazel on a non-Windows platform but are targeting Windows, register an sh_toolchain for the {} toolchain type
129-
""".format(_SH_TOOLCHAIN_TYPE))
130+
* if you are running Bazel on a non-Windows platform but are targeting Windows, register an sh_toolchain for the""",
131+
_SH_TOOLCHAIN_TYPE,
132+
"toolchain type",
133+
)
130134

131135
return _create_windows_exe_launcher(ctx, sh_toolchain, primary_output)
132136

0 commit comments

Comments
 (0)