Skip to content

Commit b918438

Browse files
authored
Define aliased tools as native binaries (#171)
Define aliased tools as native binaries instead of simple file aliases, so that their `files_to_run.executable` attribute can be used in starlark.
1 parent 62d9a10 commit b918438

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

toolchain/BUILD.toolchain.tpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package(default_visibility = ["//visibility:public"])
1616

17+
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
1718
load("@rules_cc//cc:defs.bzl", "cc_toolchain", "cc_toolchain_suite")
1819
load("%{cc_toolchain_config_bzl}", "cc_toolchain_config")
1920

toolchain/aliases.bzl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ aliased_libs = [
2020
]
2121

2222
aliased_tools = [
23+
"clang-apply-replacements",
2324
"clang-format",
25+
"clang-tidy",
2426
"llvm-cov",
2527
]

toolchain/deps.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,16 @@ def bazel_toolchain_dependencies():
2323
strip_prefix = "rules_cc-726dd8157557f1456b3656e26ab21a1646653405",
2424
urls = ["https://github.com/bazelbuild/rules_cc/archive/726dd8157557f1456b3656e26ab21a1646653405.tar.gz"],
2525
)
26+
27+
# Load bazel_skylib if the user has not defined them.
28+
if not native.existing_rule("bazel_skylib"):
29+
http_archive(
30+
name = "bazel_skylib",
31+
urls = [
32+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
33+
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
34+
],
35+
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
36+
)
37+
38+
# Skip bazel_skylib_workspace because we are not using lib/unittest.bzl

toolchain/internal/configure.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,10 @@ cc_import(
511511
tool_target_strs = []
512512
for name in _aliased_tools:
513513
template = """
514-
alias(
514+
native_binary(
515515
name = "{name}",
516-
actual = "{{llvm_dist_label_prefix}}bin/{name}",
516+
out = "{name}",
517+
src = "{{llvm_dist_label_prefix}}bin/{name}",
517518
)""".format(name = name)
518519
tool_target_strs.append(template)
519520

0 commit comments

Comments
 (0)