diff --git a/MODULE.bazel b/MODULE.bazel index 23c3b35..65be828 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -25,6 +25,7 @@ bazel_dep(name = "aspect_rules_py", version = "1.4.0") bazel_dep(name = "aspect_rules_lint", version = "1.5.3") bazel_dep(name = "rules_shell", version = "0.5.0") bazel_dep(name = "rules_java", version = "8.15.1") +bazel_dep(name = "rules_rust", version = "0.61.0") bazel_dep(name = "rules_multitool", version = "1.9.0") bazel_dep(name = "bazel_skylib", version = "1.7.1", dev_dependency = True) diff --git a/format_checker/README.md b/format_checker/README.md index 7863e89..b07b8dd 100644 --- a/format_checker/README.md +++ b/format_checker/README.md @@ -1,15 +1,13 @@ # Source Format Targets for Bazel Projects -This module provides reusable Bazel macros for formatting **Starlark**, **Python** and **YAML** files -using [`aspect-build/rules_lint`](https://github.com/aspect-build/rules_lint) and `buildifier`. It enables -consistent formatting enforcement across Bazel-based projects. +This module provides reusable Bazel macros for formatting **Starlark**, **Python**, **YAML**, and **Rust** files using [`aspect-build/rules_lint`](https://github.com/aspect-build/rules_lint) and `buildifier`. By default Rust formatting uses the `@rules_rust//tools/upstream_wrapper:rustfmt` binary. --- ## Features -- ✅ Supports Python (`ruff`), YAML (`yamlfmt`) and Starlark (`buildifier`) +- ✅ Supports Python (`ruff`), YAML (`yamlfmt`), Starlark (`buildifier`) and Rust (via `@rules_rust` upstream wrapper by default) - ✅ Provides `format.fix` and `format.check` targets - ✅ Simple macro-based usage for local formatting scope - ✅ Centralized logic without Bazel module extensions @@ -19,9 +17,8 @@ consistent formatting enforcement across Bazel-based projects. ## Directory Structure ```bash -├── BUILD.bazel -├── MODULE.bazel # Bazel module declaration with deps -├── macros.bzl # Contains the reusable macro +├── BUILD.bazel +├── macros.bzl └── README.md ``` @@ -89,10 +86,16 @@ This will register two Bazel targets: --- +## Rust support + +- Default formatter label: `@rules_rust//tools/upstream_wrapper:rustfmt`. + +--- + ## Benefits -✅ Centralized formatting config with local file scope -✅ Consistent developer experience across repositories +✅ Centralized formatting config with local file scope +✅ Consistent developer experience across repositories ✅ Easily pluggable in CI pipelines or Git pre-commit hooks ---- \ No newline at end of file +--- diff --git a/format_checker/macros.bzl b/format_checker/macros.bzl index 948ef92..84c089b 100644 --- a/format_checker/macros.bzl +++ b/format_checker/macros.bzl @@ -16,6 +16,7 @@ def use_format_targets(fix_name = "format.fix", check_name = "format.check"): format_multirun( name = fix_name, python = "@aspect_rules_lint//format:ruff", + rust = "@rules_rust//tools/upstream_wrapper:rustfmt", starlark = "@buildifier_prebuilt//:buildifier", yaml = "@aspect_rules_lint//format:yamlfmt", visibility = ["//visibility:public"], @@ -25,6 +26,7 @@ def use_format_targets(fix_name = "format.fix", check_name = "format.check"): name = check_name, no_sandbox = True, python = "@aspect_rules_lint//format:ruff", + rust = "@rules_rust//tools/upstream_wrapper:rustfmt", starlark = "@buildifier_prebuilt//:buildifier", yaml = "@aspect_rules_lint//format:yamlfmt", workspace = "//:MODULE.bazel", diff --git a/tools/sample.sh b/tools/sample.sh index 43c2913..c34f375 100644 --- a/tools/sample.sh +++ b/tools/sample.sh @@ -1,3 +1,4 @@ +#!/usr/bin/env bash # ******************************************************************************* # Copyright (c) 2025 Contributors to the Eclipse Foundation # @@ -10,7 +11,6 @@ # # SPDX-License-Identifier: Apache-2.0 # ******************************************************************************* -#!/usr/bin/env bash set -euo pipefail bazel run //docs:ide_support