rustls / rustls-ffi

Use Rustls from any language
Other
124 stars 31 forks source link

clang-format all C code, enforce formatting in CI. #329

Closed cpu closed 1 year ago

cpu commented 1 year ago

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 https://github.com/rustls/rustls-ffi/issues/327

Makefile: rm empty space.

Simple tidy commit.

Makefile: fix PHONY targets.

The all, clean, and test aren't traditional file targets: they don't produce a built artifact on disk from other files. If there were to 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:

Both targets use find to locate all suitable .h and .c files. Crucially we configure find to ignore the target build directory, as well as the src/rustls.h file that is generated by cbindgen.

tests: universally apply clang-format.

This commit uses the new make format target to re-format all of the .c/.h files using clang-format. Afterwards the make 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 call make format-check to enforce the use of clang-format for C code.

cpu commented 1 year ago

cpu force-pushed the cpu-clang-format-all-the-things branch from 4d0f519 to 21e200e

Resolved conflicts.