Skip to content

build: add black/clang-format helpers - #449

Closed
fwilliams wants to merge 1 commit into
openvdb:mainfrom
fwilliams:build/formatting-scripts
Closed

fwilliams wants to merge 1 commit into
openvdb:mainfrom
fwilliams:build/formatting-scripts

Conversation

@fwilliams

@fwilliams fwilliams commented Feb 6, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add build.sh subcommands for CI-aligned Python (black) and C++/CUDA (clang-format) formatting.
  • Add scripts to run black and clang-format-18 (with helpful errors if missing).\n\n## Notes\n- Intended as a standalone formatting/tooling PR off main.

Add build.sh subcommands to run CI-aligned black and clang-format, and add scripts that locate the expected formatter binaries.

Co-authored-by: Cursor <cursoragent@cursor.com>
@fwilliams
fwilliams requested a review from a team as a code owner February 6, 2026 23:26
@harrism

harrism commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

I think for black we can just add the command line arguments to pyproject.toml, no script needed. Then you can just call black. And it's easier to maintain than adding a build.sh to fvdb-reality-capture.

@harrism harrism added CI Issues related to the Github actions CI/CD. For build issues use CMake/Build cmake/build Issues related to building and CMake labels Feb 10, 2026
@harrism

harrism commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

PR #592 adds [tool.black] section to our pyproject.toml with the appropriate settings so now when you run black locally and in CI they will use the same options. So I think the run_black.sh script in this PR is now superfluous.

@swahtz

swahtz commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Because the commit on this branch isn't signed and I wouldn't be able to force push a history rewrite up to the fork repo, I'm opening #769 to finish this out by addressing the notes to remove the run_black.sh script, etc.

@swahtz swahtz closed this Sep 10, 2026
swahtz added a commit that referenced this pull request Sep 10, 2026
## Summary

Adds `./build.sh format`, a single command that formats the repo the way
CI checks it, and fixes the existing clang-format script.

- `./build.sh format` runs clang-format over `src/` and then black over
the repo. `./build.sh format check` reports violations without rewriting
files and exits non-zero, matching the CI codestyle jobs.
- Black reads its settings from the `[tool.black]` section in
`pyproject.toml` added in #592, so this PR duplicates no black flags.
- `src/scripts/run_clang_format.sh` previously had its shebang after the
license header, only worked when invoked from `src/scripts`, and did not
pass `-style=file`. It now walks `src/` with the same extensions CI
uses, prefers `clang-format-18` (which `env/dev_environment.yml`
provides), warns when another version is used, and supports `check`
mode.

Supersedes #449. Per the discussion there, the standalone black script
is dropped in favor of the pyproject config.

## Testing

- `./build.sh format bogus` and `./build.sh format check extra` reject
the arguments.
- `./build.sh format check` runs clang-format in dry-run mode and
reports violations, then runs black in check mode. Exit code is non-zero
if either reports a problem.
- `./build.sh format` rewrites files in place. With a local clang-format
21 the version warning fires and the reformat differs from CI, which is
why the warning exists.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: Jonathan Swartz <jonathan@jswartz.info>
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Issues related to the Github actions CI/CD. For build issues use CMake/Build cmake/build Issues related to building and CMake

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants