Skip to content

Commit

Permalink
Add .clang-format (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
wins1ey authored Jun 3, 2024
2 parents 28ef2af + 7a35018 commit b816975
Show file tree
Hide file tree
Showing 24 changed files with 1,533 additions and 2,045 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
BasedOnStyle: WebKit
IndentCaseBlocks: true
IndentCaseLabels: true
23 changes: 23 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
on: [push]

jobs:
format-check:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Format files
run: |
clang-format -i $(find src -name '*.c' -or -name '*.h')
- name: Check for changes
run: |
changed_files=$(git diff --name-only)
if [ -n "$changed_files" ]; then
echo "The following files require formatting:"
echo "$changed_files"
echo "Run 'make format' and commit the changes."
exit 1
fi
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ remove-schema:
clean:
$(RM) -r $(BIN) $(OBJ_DIR) $(SRC_DIR)/main.h

format:
clang-format -i $(SOURCES) $(COMPONENTS) $(SRC_DIR)/*.h $(SRC_DIR)/component/*.h

.PHONY: all main.h install uninstall remove-schema clean
Loading

0 comments on commit b816975

Please sign in to comment.