Skip to content

Distribute sanitizer/clang-tidy policies via bazelrc-preset.bzl#13

Draft
RSingh1511 wants to merge 1 commit into
eclipse-score:mainfrom
RSingh1511:rs/bazelrc-preset
Draft

Distribute sanitizer/clang-tidy policies via bazelrc-preset.bzl#13
RSingh1511 wants to merge 1 commit into
eclipse-score:mainfrom
RSingh1511:rs/bazelrc-preset

Conversation

@RSingh1511

@RSingh1511 RSingh1511 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

  • PR title is short, expressive and meaningful
  • Commits are properly organized
  • Relevant issues are linked in the References section
  • Tests are conducted
  • Unit tests are added

Checklist for the PR Reviewer

  • Commits are properly organized and messages follow S-CORE commit guidelines
  • Unit tests have been written for new behavior
  • Public API is documented
  • PR title describes the changes

Post-review Checklist for the PR Author

  • All open points are addressed and tracked via issues

References

Closes #

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 combined PRESETS entrypoint for consumers.
  • Adds a tools:preset generator plus a committed generated fragment (tools/preset.bazelrc).
  • Adds drift-detection tests to ensure *.bazelrc fragments 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.

Comment thread tools/BUILD.bazel Outdated
extra_presets = PRESETS,
)

exports_files(["check_bazelrc_equivalence.sh"])
Comment thread clang_tidy/presets.bzl
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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread clang_tidy/presets.bzl
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(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that is then collected by filegroup output_group selection?

Comment thread sanitizers/presets.bzl
description = "Compile/link with -fsanitize=thread via the score_tsan cc_feature.",
),
],
"platform_suffix": [

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this? This will duplicate build tree for each configuration. Is there a reason why we do this?

Comment thread tools/check_bazelrc_equivalence.sh Outdated
@@ -0,0 +1,72 @@
#!/usr/bin/env bash

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@RSingh1511 RSingh1511 added enhancement New feature or request wip Work in progress labels Jun 30, 2026
@RSingh1511 RSingh1511 self-assigned this Jun 30, 2026
@RSingh1511 RSingh1511 force-pushed the rs/bazelrc-preset branch from b2bec2a to c07caef Compare July 1, 2026 03:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request wip Work in progress

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants