1
0
Fork 0
forked from NotAShelf/rogged

chore: setup clang-format for formatting

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I322b7dd5dcd699247b58fe9f5db7bcd86a6a6964
This commit is contained in:
raf 2026-04-03 14:03:01 +03:00
commit 8f6650919d
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 123 additions and 3 deletions

View file

@ -12,7 +12,7 @@ OBJDIR := obj
SOURCES := $(wildcard $(SRCDIR)/*.c)
OBJECTS := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SOURCES))
.PHONY: all clean
.PHONY: all clean format format-check
all: $(TARGET)
@ -29,3 +29,17 @@ clean:
# Alias for development
dev: all
./$(TARGET)
# Format all source files with clang-format
fmt:
@command -v clang-format >/dev/null 2>&1 || { echo "Error: clang-format is missing"; exit 1; }
@echo "Formatting source files..."
@clang-format -i $(SOURCES) $(wildcard $(SRCDIR)/*.h)
@echo "Done formatting."
# Check formatting without modifying files
fmt-check:
@command -v clang-format >/dev/null 2>&1 || { echo "Error: clang-format is missing"; exit 1; }
@echo "Checking formatting..."
@clang-format --dry-run --Werror \
$(SOURCES) $(wildcard $(SRCDIR)/*.h) && echo "All files properly formatted." || { echo "Formatting issues found. Run 'make fmt' to fix."; exit 1; }