Add clang-format to c++ backend#262
Open
AaronWebster wants to merge 2 commits into
Open
Conversation
c9f6a24 to
5efef50
Compare
Apply Google-style clang-format to all generated .emb.h output, in both the bazel codegen path (emboss_codegen_cpp.main) and the standalone embossc driver. The clang-format binary path is resolved through the new compiler/back_end/cpp/clang_format_path module, which is the single seam to the underlying binary. The upstream version uses the clang-format PyPI package; downstream forks that cannot use the PyPI package can replace just clang_format_path.py and its BUILD entry with a shim returning an alternative path.
5efef50 to
50b28a6
Compare
robrussell
approved these changes
May 21, 2026
|
|
||
| def get_clang_format_path(): | ||
| """Returns the path to the clang-format executable.""" | ||
| from clang_format import get_executable |
Member
There was a problem hiding this comment.
Imports should be at the top.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated C++ headers are now run through
clang-format --style=googlebeforebeing written out, so the output is consistent and readable instead of relying
on whitespace baked into the templates.
The clang-format binary is located via a small
clang_format_path.pyshim(with its own
py_librarytarget). The seam exists so downstream forks thatcan't use the upstream
clang-formatPyPI package can swap in their ownbinary by rewriting just that one file and its pip dep — nothing else in the
Emboss tree needs to change. The PyPI package itself is pinned at 22.1.5 in
requirements.txt.Most of the diff is regenerated goldens under
testdata/golden_cpp/. Thosechanges are purely formatting; no semantics moved.