Skip to content

Commit 9c167dc

Browse files
authored
clang-format: use llvm binary on linux [BUILD-640] (#57)
Makes the `clang_format` rule hermetic on linux by using the clang-format binary that is provided with the llvm distribution instead of the system version. This will remove any discrepancy between local dev and ci. The select condition will be removed once we've set up the llvm toolchain on macos.
1 parent 355a423 commit 9c167dc

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

cc/toolchains/llvm.BUILD.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,3 +130,8 @@ filegroup(
130130
name = "clang-tidy",
131131
srcs = ["bin/clang-tidy"],
132132
)
133+
134+
filegroup(
135+
name = "clang-format",
136+
srcs = ["bin/clang-format"],
137+
)

clang_format/BUILD renamed to clang_format/BUILD.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ choose_clang_format(
1818

1919
filegroup(
2020
name = "_clang_format_bin",
21-
srcs = [":clang_format_bin"],
21+
srcs = select({
22+
"@platforms//os:linux": ["@llvm-distribution//:clang-format"],
23+
"//conditions:default": [":clang_format_bin"],
24+
}),
25+
visibility = ["//visibility:public"],
2226
)
2327

2428
sh_binary(

clang_format/clang_format_check.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ clang_format_check_aspect = aspect(
5656
attrs = {
5757
"_clang_format": attr.label(default = Label("//clang_format:clang_format")),
5858
"_clang_format_config": attr.label(default = "//clang_format:clang_format_config"),
59-
"_clang_format_bin": attr.label(default = Label("//clang_format:clang_format_bin")),
59+
"_clang_format_bin": attr.label(default = Label("//clang_format:_clang_format_bin")),
6060
},
6161
)
File renamed without changes.

0 commit comments

Comments
 (0)