Skip to content

Commit e76f0c5

Browse files
committed
Fix Bazel 7.7.1 compatibility for git shallow_since and clang-tidy using aspect_rules_lint
Signed-off-by: Matthieu MOREL <[email protected]>
1 parent e9d7a38 commit e76f0c5

File tree

8 files changed

+124
-28
lines changed

8 files changed

+124
-28
lines changed

.bazelrc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ build:clang-tsan --copt -fsanitize=thread
5757
build:clang-tsan --linkopt -fsanitize=thread
5858
build:clang-tsan --test_env=TSAN_OPTIONS=suppressions=bazel/tsan_suppressions.txt
5959

60-
# Use Clang-Tidy tool.
61-
build:clang-tidy --config=clang
62-
build:clang-tidy --aspects @bazel_clang_tidy//clang_tidy:clang_tidy.bzl%clang_tidy_aspect
63-
build:clang-tidy --@bazel_clang_tidy//:clang_tidy_config=@proxy_wasm_cpp_host//:clang_tidy_config
64-
build:clang-tidy --output_groups=report
60+
# Use Clang-Tidy tool with hermetic LLVM toolchain via aspect_rules_lint.
61+
build:clang-tidy --aspects //tools/lint:linters.bzl%clang_tidy
62+
build:clang-tidy --output_groups=rules_lint_report
6563

6664
# Use GCC compiler.
6765
build:gcc --action_env=BAZEL_COMPILER=gcc

WORKSPACE

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ load("@proxy_wasm_cpp_host//bazel:dependencies.bzl", "proxy_wasm_cpp_host_depend
88

99
proxy_wasm_cpp_host_dependencies()
1010

11+
# Setup bazel_features internal repos (required for aspect_rules_lint)
12+
load("@proxy_wasm_cpp_host//bazel:setup_features.bzl", "setup_bazel_features")
13+
14+
setup_bazel_features()
15+
1116
load("@proxy_wasm_cpp_host//bazel:dependencies_python.bzl", "proxy_wasm_cpp_host_dependencies_python")
1217

1318
proxy_wasm_cpp_host_dependencies_python()

bazel/dependencies.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@aspect_rules_lint//format:repositories.bzl", "rules_lint_dependencies")
16+
load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies", "bazel_lib_register_toolchains")
1517
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
1618
load("@envoy_toolshed//sysroot:sysroot.bzl", "setup_sysroots")
1719
load("@proxy_wasm_cpp_host//bazel/cargo/wasmsign/remote:crates.bzl", wasmsign_crate_repositories = "crate_repositories")
@@ -54,6 +56,11 @@ def proxy_wasm_cpp_host_dependencies():
5456
)
5557
crate_universe_dependencies(bootstrap = True)
5658

59+
# Aspect dependencies for clang-tidy integration
60+
rules_lint_dependencies()
61+
bazel_lib_dependencies()
62+
bazel_lib_register_toolchains()
63+
5764
setup_sysroots()
5865
bazel_toolchain_dependencies()
5966
llvm_toolchain(

bazel/external/bazel_clang_tidy.patch

Lines changed: 0 additions & 16 deletions
This file was deleted.

bazel/repositories.bzl

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,42 @@ def proxy_wasm_cpp_host_repositories():
4848
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"],
4949
)
5050

51+
# aspect_rules_lint v1.12.0 for modern clang-tidy integration
5152
maybe(
5253
http_archive,
53-
name = "bazel_clang_tidy",
54-
sha256 = "6ed23cbff9423a30ef10becf57210a26d54fe198a211f4037d931c06f843c023",
55-
strip_prefix = "bazel_clang_tidy-c2fe98cfec0430e78bff4169e9ca0a43123e4c99",
56-
url = "https://github.com/erenon/bazel_clang_tidy/archive/c2fe98cfec0430e78bff4169e9ca0a43123e4c99.tar.gz",
57-
patches = ["@proxy_wasm_cpp_host//bazel/external:bazel_clang_tidy.patch"],
58-
patch_args = ["-p1"],
54+
name = "aspect_rules_lint",
55+
sha256 = "a8a63bd071a39bd5be1f99d9f258eac674673c98505f9fc5b4c76587f67278cd",
56+
strip_prefix = "rules_lint-1.12.0",
57+
url = "https://github.com/aspect-build/rules_lint/releases/download/v1.12.0/rules_lint-v1.12.0.tar.gz",
58+
)
59+
60+
# bazel_lib v3.0.1 required by aspect_rules_lint v1.12.0
61+
maybe(
62+
http_archive,
63+
name = "bazel_lib",
64+
sha256 = "8b074b1a2731d29f6b95defdca95297354dc424492caf7019cf6b9f36afba54f",
65+
strip_prefix = "bazel-lib-3.0.1",
66+
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.1/bazel-lib-v3.0.1.tar.gz",
67+
)
68+
69+
# aspect_bazel_lib alias for aspect_rules_js v2.1.2 compatibility
70+
# aspect_rules_js expects @aspect_bazel_lib while aspect_rules_lint expects @bazel_lib
71+
# Both repos reference the same bazel-lib v3.0.1 release to maintain consistency
72+
maybe(
73+
http_archive,
74+
name = "aspect_bazel_lib",
75+
sha256 = "8b074b1a2731d29f6b95defdca95297354dc424492caf7019cf6b9f36afba54f",
76+
strip_prefix = "bazel-lib-3.0.1",
77+
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.1/bazel-lib-v3.0.1.tar.gz",
78+
)
79+
80+
# aspect_rules_js is required by aspect_rules_lint
81+
maybe(
82+
http_archive,
83+
name = "aspect_rules_js",
84+
sha256 = "fbc34d815a0cc52183a1a26732fc0329e26774a51abbe0f26fc9fd2dab6133b4",
85+
strip_prefix = "rules_js-2.1.2",
86+
url = "https://github.com/aspect-build/rules_js/releases/download/v2.1.2/rules_js-v2.1.2.tar.gz",
5987
)
6088

6189
maybe(
@@ -180,7 +208,7 @@ def proxy_wasm_cpp_host_repositories():
180208
# 13.8.258.26
181209
commit = "de9d0f8b56ae61896e4d2ac577fc589efb14f87d",
182210
remote = "https://chromium.googlesource.com/v8/v8",
183-
shallow_since = "1752074621 -0400",
211+
shallow_since = "1752074621",
184212
patches = [
185213
"@proxy_wasm_cpp_host//bazel/external:v8.patch",
186214
],

bazel/setup_features.bzl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Setup bazel_features internal repositories."""
16+
17+
load("@bazel_features//private:repos.bzl", "bazel_features_repos")
18+
19+
def setup_bazel_features():
20+
"""Initialize bazel_features internal repos (needed for WORKSPACE compat)."""
21+
bazel_features_repos()

tools/lint/BUILD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
load("@bazel_skylib//rules:native_binary.bzl", "native_binary")
16+
17+
# Make hermetic clang-tidy available as a binary for aspect_rules_lint
18+
native_binary(
19+
name = "clang_tidy",
20+
src = select(
21+
{
22+
"@bazel_tools//src/conditions:linux_x86_64": "@llvm_toolchain_llvm//:bin/clang-tidy",
23+
"@bazel_tools//src/conditions:linux_aarch64": "@llvm_toolchain_llvm//:bin/clang-tidy",
24+
"@bazel_tools//src/conditions:darwin_x86_64": "@llvm_toolchain_llvm//:bin/clang-tidy",
25+
"@bazel_tools//src/conditions:darwin_arm64": "@llvm_toolchain_llvm//:bin/clang-tidy",
26+
},
27+
),
28+
out = "clang_tidy",
29+
visibility = ["//visibility:public"],
30+
)

tools/lint/linters.bzl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""Linter configurations for the project."""
16+
17+
load("@aspect_rules_lint//lint:clang_tidy.bzl", "lint_clang_tidy_aspect")
18+
19+
# Configure clang-tidy to use the hermetic LLVM toolchain
20+
clang_tidy = lint_clang_tidy_aspect(
21+
binary = "@@//tools/lint:clang_tidy",
22+
configs = ["@@//:.clang-tidy"],
23+
)

0 commit comments

Comments
 (0)