feat(Makefile): adding rules to format the code with clang.

This commit is contained in:
damien DELPY 2025-03-21 15:16:57 +01:00
parent 4829d28f4a
commit 54b8236625
No known key found for this signature in database
2 changed files with 10 additions and 0 deletions

1
.clang-format Normal file
View File

@ -0,0 +1 @@
BasedOnStyle: webkit

View File

@ -54,6 +54,7 @@ else
endif endif
srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c) srcs+=$(wildcard ${src_dir}/*.c ${src_dir}/**/*.c)
headers+=$(wildcard ${src_dir}/*.h ${src_dir}/**/*.h)
objs+=$(patsubst %.c,${build_dir}/%.o,${srcs}) objs+=$(patsubst %.c,${build_dir}/%.o,${srcs})
.PHONY: all .PHONY: all
@ -122,6 +123,14 @@ ${build_dir}/%.o: %.c
compile_flags.txt: compile_flags.txt:
(echo "${CFLAGS} ${LDFLAGS}" | sed 's/ /\n/g') > compile_flags.txt (echo "${CFLAGS} ${LDFLAGS}" | sed 's/ /\n/g') > compile_flags.txt
.PHONY: format
format:
clang-format -i ${srcs} ${headers}
.PHONY: check_format
check_format:
clang-format --dry-run --Werror ${srcs} ${headers}
.PHONY: clean .PHONY: clean
clean: clean:
${RM} -r build install ${RM} -r build install