Skip to content

Commit

Permalink
Fix printing of toolchain type label in error message (#20)
Browse files Browse the repository at this point in the history
It used to print `//shell:toolchain_type`, now it should prepend the
apparent repo name (if available).
  • Loading branch information
fmeum authored Jan 30, 2025
1 parent 44fe1be commit 8120a51
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions shell/private/sh_executable.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

visibility(["//shell"])

_SH_TOOLCHAIN_TYPE = "//shell:toolchain_type"
_SH_TOOLCHAIN_TYPE = Label("//shell:toolchain_type")

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

return _create_windows_exe_launcher(ctx, sh_toolchain, primary_output)

Expand Down

0 comments on commit 8120a51

Please sign in to comment.