Skip to content

Commit 43a817a

Browse files
committed
build: add 'compliant' makefile target for fixing code style
Signed-off-by: Patrick McCarty <[email protected]>
1 parent 4e868b4 commit 43a817a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Makefile.am

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,27 @@ dist_check_SCRIPTS = \
147147
test/run.sh
148148
endif
149149

150+
compliant:
151+
@git diff --quiet --exit-code include src; ret=$$?; \
152+
if [ $$ret -eq 1 ]; then \
153+
echo "Error: can only check code style when include/ and src/ are clean."; \
154+
echo "Stash or commit your changes and try again."; \
155+
exit $$ret; \
156+
elif [ $$ret -gt 1 ]; then \
157+
exit $$ret; \
158+
fi; \
159+
clang-format -i -style=file include/*.h src/*.c; ret=$$?; \
160+
if [ $$ret -ne 0 ]; then \
161+
exit $$ret; \
162+
fi; \
163+
git diff --quiet --exit-code include src; ret=$$?; \
164+
if [ $$ret -eq 1 ]; then \
165+
echo "Code style issues found. Run 'git diff' to view issues."; \
166+
elif [ $$ret -eq 0 ]; then \
167+
echo "No code style issues found."; \
168+
fi; \
169+
exit $$ret
170+
150171
release:
151172
@git rev-parse v$(PACKAGE_VERSION) &> /dev/null; \
152173
if [ "$$?" -eq 0 ]; then \

0 commit comments

Comments
 (0)