Skip to content

Commit 673e55a

Browse files
committed
Use coreutils hermetic symlink instead of host ln
1 parent afe82a1 commit 673e55a

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

MODULE.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,18 @@ bazel_dep(name = "rules_proto", version = "7.1.0")
6060
bazel_dep(name = "llvm", version = "0.7.6")
6161
bazel_dep(name = "aspect_tools_telemetry", version = "0.3.3")
6262

63+
bazel_lib_toolchains = use_extension("@bazel_lib//lib:extensions.bzl", "toolchains")
64+
bazel_lib_toolchains.coreutils(version = "0.5.0")
65+
use_repo(
66+
bazel_lib_toolchains,
67+
"coreutils_darwin_amd64",
68+
"coreutils_darwin_arm64",
69+
"coreutils_linux_amd64",
70+
"coreutils_linux_arm64",
71+
"coreutils_windows_amd64",
72+
"coreutils_windows_arm64",
73+
)
74+
6375
osx = use_extension("@llvm//extensions:osx.bzl", "osx")
6476
use_repo(osx, "macos_sdk")
6577

rs/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ bzl_library(
208208
deps = [
209209
"@bazel_features//:features",
210210
"@bazel_lib//lib:paths",
211+
"@bazel_lib//lib:repo_utils",
211212
],
212213
)
213214

rs/private/symlink_utils.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
load("@bazel_features//:features.bzl", "bazel_features")
22
load("@bazel_lib//lib:paths.bzl", "relative_file")
3+
load("@bazel_lib//lib:repo_utils.bzl", "repo_utils")
4+
5+
def _coreutils_label(rctx):
6+
platform = repo_utils.platform(rctx)
7+
binary = "coreutils.exe" if platform.startswith("windows_") else "coreutils"
8+
return Label("@coreutils_%s//:%s" % (platform, binary))
39

410
def relative_symlink(rctx, target, link_name):
511
target_path = rctx.path(target)
@@ -16,6 +22,7 @@ def relative_symlink(rctx, target, link_name):
1622
return
1723

1824
result = rctx.execute([
25+
_coreutils_label(rctx),
1926
"ln",
2027
"-sf",
2128
relative_file(str(target_path), str(link_path)),

0 commit comments

Comments
 (0)