clang-format all C code, enforce formatting in CI. #329
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.
Description
This branch builds on the already checked-in
.clang-format
, making it easier to use locally and enforcing that C code in-repo is always formatted using it w/ a CI check.I haven't attempted to extend the Windows Makefile with similar functionality on the assumption that all development is happening on Unix-like-systems and not Windows.
Resolves #327
Makefile: rm empty space.
Simple tidy commit.
Makefile: fix PHONY targets.
The
all
,clean
, andtest
aren't traditional file targets: they don't produce a built artifact on disk from other files. If there wereto be a file with a matching name found in the workdir these targets wouldn't perform their jobs as expected, thinking the workdir was up-to-date.
This commit marks these targets as "PHONY" targets, telling Make that they're not associated with produced files and are meta-targets for running helpful commands.
Makefile: add format-check and format targets.
This commit adds two new PHONY targets:
make format-check
for enforcing that all .c/.h files are correctly formatted. This will be run in CI in subsequent commits once it will pass.make format
for reformatting all .c/.h files according to the clang-format profile. This can be run by developers to format code.Both targets use
find
to locate all suitable.h
and.c
files. Crucially we configurefind
to ignore thetarget
build directory, as well as thesrc/rustls.h
file that is generated bycbindgen
.tests: universally apply clang-format.
This commit uses the new
make format
target to re-format all of the .c/.h files usingclang-format
. Afterwards themake format-check
passes, where previously it flagged the re-formatted files in this commit as needing formatting.ci: enforce C formatting w/ make format-check.
This commit extends the existing format task in CI that was enforcing the use of
cargo fmt
to also callmake format-check
to enforce the use ofclang-format
for C code.