Skip to content

Commit

Permalink
Define aliased tools as native binaries (#171)
Browse files Browse the repository at this point in the history
Define aliased tools as native binaries instead of simple file aliases, so that their
`files_to_run.executable` attribute can be used in starlark.
  • Loading branch information
oliverlee authored Jan 16, 2023
1 parent 62d9a10 commit b918438
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions toolchain/BUILD.toolchain.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

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

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

Expand Down
2 changes: 2 additions & 0 deletions toolchain/aliases.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ aliased_libs = [
]

aliased_tools = [
"clang-apply-replacements",
"clang-format",
"clang-tidy",
"llvm-cov",
]
13 changes: 13 additions & 0 deletions toolchain/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,16 @@ def bazel_toolchain_dependencies():
strip_prefix = "rules_cc-726dd8157557f1456b3656e26ab21a1646653405",
urls = ["https://github.com/bazelbuild/rules_cc/archive/726dd8157557f1456b3656e26ab21a1646653405.tar.gz"],
)

# Load bazel_skylib if the user has not defined them.
if not native.existing_rule("bazel_skylib"):
http_archive(
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
],
sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
)

# Skip bazel_skylib_workspace because we are not using lib/unittest.bzl
5 changes: 3 additions & 2 deletions toolchain/internal/configure.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -511,9 +511,10 @@ cc_import(
tool_target_strs = []
for name in _aliased_tools:
template = """
alias(
native_binary(
name = "{name}",
actual = "{{llvm_dist_label_prefix}}bin/{name}",
out = "{name}",
src = "{{llvm_dist_label_prefix}}bin/{name}",
)""".format(name = name)
tool_target_strs.append(template)

Expand Down

0 comments on commit b918438

Please sign in to comment.