Skip to content

Commit

Permalink
Forward @bazel_tools//tools/sh:toolchain_type to rules_shell
Browse files Browse the repository at this point in the history
This is required for compatibility with modules that rely on the auto-registered `sh_toolchain` to obtain a shebang, e.g. `rules_js`.

Also remove implementations and toolchain registrations in favor of forwarders.

Closes #24748.

PiperOrigin-RevId: 709149200
Change-Id: I758cf403c24f6b5e6f00bbf5b4e0313a30773f78
  • Loading branch information
fmeum authored and copybara-github committed Dec 23, 2024
1 parent 1644cea commit 720e15e
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 119 deletions.
1 change: 0 additions & 1 deletion scripts/bootstrap/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ EOF

# Create @bazel_tools//tools/sh
mkdir -p ${BAZEL_TOOLS_REPO}/tools/sh
link_file "${PWD}/tools/sh/sh_configure.bzl" "${BAZEL_TOOLS_REPO}/tools/sh/sh_configure.bzl"
link_file "${PWD}/tools/sh/sh_toolchain.bzl" "${BAZEL_TOOLS_REPO}/tools/sh/sh_toolchain.bzl"
link_file "${PWD}/tools/sh/BUILD.tools" "${BAZEL_TOOLS_REPO}/tools/sh/BUILD"

Expand Down
4 changes: 0 additions & 4 deletions src/MODULE.tools
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ use_repo(
"remote_java_tools_darwin_arm64",
)

sh_configure_extension = use_extension("//tools/sh:sh_configure.bzl", "sh_configure_extension")
use_repo(sh_configure_extension, "local_config_sh")
register_toolchains("@local_config_sh//:local_sh_toolchain")

remote_coverage_tools_extension = use_extension("//tools/test:extensions.bzl", "remote_coverage_tools_extension")
use_repo(remote_coverage_tools_extension, "remote_coverage_tools")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,6 @@ def cc_configure(**kwargs):
""");

config.create("embedded_tools/tools/sh/BUILD");
config.create(
"embedded_tools/tools/sh/sh_configure.bzl",
"""
def sh_configure(**kwargs):
pass
""");
config.create("embedded_tools/tools/osx/BUILD");
config.create(
"embedded_tools/tools/osx/xcode_configure.bzl",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ private static void mockEmbeddedTools(Path embeddedBinaries) throws IOException
"def xcode_configure(*args, **kwargs):",
" pass");
FileSystemUtils.writeIsoLatin1(tools.getRelative("tools/sh/BUILD"), "");
FileSystemUtils.writeIsoLatin1(
tools.getRelative("tools/sh/sh_configure.bzl"),
"def sh_configure(*args, **kwargs):",
" pass");
FileSystemUtils.writeIsoLatin1(tools.getRelative("tools/build_defs/repo/BUILD"));
FileSystemUtils.writeIsoLatin1(
tools.getRelative("tools/build_defs/repo/http.bzl"),
Expand Down
1 change: 0 additions & 1 deletion tools/sh/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ filegroup(
name = "embedded_tools",
srcs = [
"BUILD.tools",
"sh_configure.bzl",
"sh_toolchain.bzl",
],
visibility = ["//tools:__pkg__"],
Expand Down
4 changes: 2 additions & 2 deletions tools/sh/BUILD.tools
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
exports_files([
"sh_toolchain.bzl",
"sh_configure.bzl",
])

toolchain_type(
alias(
name = "toolchain_type",
actual = "@rules_shell//shell:toolchain_type",
visibility = ["//visibility:public"],
)

Expand Down
90 changes: 0 additions & 90 deletions tools/sh/sh_configure.bzl

This file was deleted.

14 changes: 3 additions & 11 deletions tools/sh/sh_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Define a toolchain rule for the shell."""
"""Deprecated forwarders to rules_shell."""

def _sh_toolchain_impl(ctx):
"""sh_toolchain rule implementation."""
return [platform_common.ToolchainInfo(path = ctx.attr.path)]
load("@rules_shell//shell:sh_toolchain.bzl", _sh_toolchain = "sh_toolchain")

sh_toolchain = rule(
attrs = {
# Absolute path to the shell interpreter.
"path": attr.string(),
},
implementation = _sh_toolchain_impl,
)
sh_toolchain = _sh_toolchain

0 comments on commit 720e15e

Please sign in to comment.