Distribute sanitizer/clang-tidy policies via bazelrc-preset.bzl#13
Distribute sanitizer/clang-tidy policies via bazelrc-preset.bzl#13RSingh1511 wants to merge 1 commit into
Conversation
eadac5d to
b2bec2a
Compare
There was a problem hiding this comment.
Pull request overview
Adds a bazelrc-preset.bzl-based distribution mechanism so downstream consumers can generate and vendor .bazelrc fragments for the sanitizer and clang-tidy policies instead of copying *.bazelrc files manually.
Changes:
- Introduces
SANITIZER_PRESETS,CLANG_TIDY_PRESETS, and a combinedPRESETSentrypoint for consumers. - Adds a
tools:presetgenerator plus a committed generated fragment (tools/preset.bazelrc). - Adds drift-detection tests to ensure
*.bazelrcfragments stay equivalent to their corresponding preset definitions.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tools/preset.bazelrc | Committed generated .bazelrc fragment produced by bazelrc-preset.bzl. |
| tools/check_bazelrc_equivalence.sh | Adds a normalization+diff helper to compare legacy .bazelrc fragments against generated output. |
| tools/BUILD.bazel | Adds bazelrc_preset target and schema test; exports the equivalence script. |
| sanitizers/README.md | Documents consuming sanitizer presets via bazelrc-preset.bzl. |
| sanitizers/presets.bzl | Defines SANITIZER_PRESETS mirroring sanitizers.bazelrc. |
| sanitizers/BUILD.bazel | Exports presets.bzl and adds an equivalence sh_test against the generated preset output. |
| README.md | Documents the new presets.bzl entrypoint at the repo root. |
| presets.bzl | Adds a single combined PRESETS entrypoint for sanitizers + clang-tidy. |
| MODULE.bazel | Adds bazelrc-preset.bzl dependency and updates platforms version. |
| clang_tidy/README.md | Documents consuming clang-tidy presets via bazelrc-preset.bzl. |
| clang_tidy/presets.bzl | Defines CLANG_TIDY_PRESETS mirroring clang_tidy.bazelrc. |
| clang_tidy/BUILD.bazel | Exports presets.bzl and adds an equivalence sh_test against the generated preset output. |
| BUILD.bazel | Exports root presets.bzl for external consumption. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| extra_presets = PRESETS, | ||
| ) | ||
|
|
||
| exports_files(["check_bazelrc_equivalence.sh"]) |
| default = "//tools/lint:linters.bzl%clang_tidy_aspect", | ||
| description = "Run the consumer's clang-tidy aspect (see clang_tidy/README.md step 3-4) under --config=clang-tidy.", | ||
| ), | ||
| "extra_toolchains": struct( |
There was a problem hiding this comment.
This means they have to register all toolchains that they want to use on the project level? How then toolchain resolution is working? How this thing know which toolchain is selected?
| default = "@llvm_toolchain//:cc-toolchain-x86_64-linux", | ||
| description = "Use the LLVM toolchain registered by the consumer's llvm_toolchain extension for clang-tidy.", | ||
| ), | ||
| "output_groups": struct( |
There was a problem hiding this comment.
Is this something that is then collected by filegroup output_group selection?
| description = "Compile/link with -fsanitize=thread via the score_tsan cc_feature.", | ||
| ), | ||
| ], | ||
| "platform_suffix": [ |
There was a problem hiding this comment.
Why do we need this? This will duplicate build tree for each configuration. Is there a reason why we do this?
| @@ -0,0 +1,72 @@ | |||
| #!/usr/bin/env bash | |||
There was a problem hiding this comment.
I generally likes to have shell scripts for simple tasks and for more heavier task I prefer to use Python. I think it will increase readability and maintenance.
Summary
Adds presets.bzl (SANITIZER_PRESETS, CLANG_TIDY_PRESETS, PRESETS) so consumers can pull these policies in via bazelrc-preset.bzl
instead of hand-copying sanitizers.bazelrc/clang_tidy.bazelrc.
Notes for Reviewer
Pre-Review Checklist for the PR Author
Checklist for the PR Reviewer
Post-review Checklist for the PR Author
References
Closes #