Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions format_checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,26 @@ This will register two Bazel targets:
- `bazel run //:format.fix` — fixes format issues
- `bazel test //:format.check` — fails on unformatted files

### 3️⃣ In VS Code settings:

⚠️ First formatting run can be slow!

Add the following entry to `.vscode/settings.json`:

```json
"rust-analyzer.rustfmt.overrideCommand": [
"${workspaceFolder}/.vscode/rustfmt.sh"
]
```

Add `.vscode/rustfmt.sh` file with `+x` permissions:

```bash
#!/usr/bin/env bash

bazel run @score_tooling//format_checker:rustfmt_with_policies
```

---

## Rust support
Expand Down
13 changes: 12 additions & 1 deletion format_checker/tool/rustfmt_with_policies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
set -euo pipefail

# --- begin runfiles.bash initialization v3 ---
# Copy-pasted from the Bazel Bash runfiles library v3.
set -uo pipefail; set +e; f=bazel_tools/tools/bash/runfiles/runfiles.bash
# shellcheck disable=SC1090
source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \
source "$0.runfiles/$f" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \
{ echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e
# --- end runfiles.bash initialization v3 ---

RUSTFMT_BIN="$(rlocation rules_rust/tools/upstream_wrapper/rustfmt)"
RUSTFMT_CONFIG="$(rlocation score_rust_policies/rustfmt/rustfmt.toml)"
Expand Down