mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-12 10:33:52 +01:00
Problem: make format-check not implemented with autotools
Solution: port implementation from zproject
This commit is contained in:
parent
c33cb38af2
commit
d832267e23
51
Makefile.am
51
Makefile.am
@ -882,6 +882,57 @@ MAINTAINERCLEANFILES = \
|
||||
$(srcdir)/configure \
|
||||
`find "$(srcdir)" -type f -name Makefile.in -print`
|
||||
|
||||
if WITH_CLANG_FORMAT
|
||||
ALL_SOURCE_FILES = $(wildcard \
|
||||
$(top_srcdir)/src/*.c \
|
||||
$(top_srcdir)/src/*.cc \
|
||||
$(top_srcdir)/src/*.cpp \
|
||||
$(top_srcdir)/src/*.h \
|
||||
$(top_srcdir)/src/*.hpp \
|
||||
$(top_srcdir)/tests/*.c \
|
||||
$(top_srcdir)/tests/*.cc \
|
||||
$(top_srcdir)/tests/*.cpp \
|
||||
$(top_srcdir)/tests/*.h \
|
||||
$(top_srcdir)/tests/*.hpp \
|
||||
$(top_srcdir)/perf/*.c \
|
||||
$(top_srcdir)/perf/*.cc \
|
||||
$(top_srcdir)/perf/*.cpp \
|
||||
$(top_srcdir)/perf/*.h \
|
||||
$(top_srcdir)/perf/*.hpp \
|
||||
$(top_srcdir)/tools/*.c \
|
||||
$(top_srcdir)/tools/*.cc \
|
||||
$(top_srcdir)/tools/*.cpp \
|
||||
$(top_srcdir)/tools/*.h \
|
||||
$(top_srcdir)/tools/*.hpp \
|
||||
$(top_srcdir)/include/*.h \
|
||||
)
|
||||
|
||||
# Check if any sources need to be fixed, report the filenames and an error code
|
||||
clang-format-check: $(ALL_SOURCE_FILES)
|
||||
@FAILED=0 ; IFS=";" ; IDS="`printf '\n\b'`" ; export IFS IDS; \
|
||||
for FILE in $(ALL_SOURCE_FILES) ; do \
|
||||
test -s $$FILE || continue ; \
|
||||
$(CLANG_FORMAT) -style=file -output-replacements-xml "$$FILE" | grep "<replacement " >/dev/null && \
|
||||
{ echo "$$FILE is not correctly formatted" >&2 ; FAILED=1; } ; \
|
||||
done; \
|
||||
if test "$$FAILED" != 0 ; then \
|
||||
exit 1 ; \
|
||||
fi
|
||||
|
||||
# Change source formatting
|
||||
clang-format: $(ALL_SOURCE_FILES)
|
||||
$(CLANG_FORMAT) -style=file -i $(ALL_SOURCE_FILES)
|
||||
|
||||
# Change source formatting AND report the diff
|
||||
clang-format-diff: clang-format
|
||||
git diff $(ALL_SOURCE_FILES)
|
||||
|
||||
else
|
||||
clang-format clang-format-check clang-format-diff:
|
||||
@echo "Install the clang-format program, reconfigure and re-run this request"
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
@CODE_COVERAGE_RULES@
|
||||
|
||||
dist-hook:
|
||||
|
13
configure.ac
13
configure.ac
@ -800,6 +800,19 @@ if test "x$enable_libunwind" != "xno"; then
|
||||
])
|
||||
fi
|
||||
|
||||
# See if clang-format is in PATH; the result unblocks the relevant recipes
|
||||
WITH_CLANG_FORMAT=""
|
||||
AS_IF([test x"$CLANG_FORMAT" = x],
|
||||
[AC_PATH_PROG([CLANG_FORMAT], [clang-format], [])],
|
||||
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [fail])])
|
||||
AS_IF([test x"$CLANG_FORMAT" != x && test x"$WITH_CLANG_FORMAT" = x],
|
||||
[AS_IF([test -x "$CLANG_FORMAT"],
|
||||
[WITH_CLANG_FORMAT=true],
|
||||
[AC_CHECK_PROG([WITH_CLANG_FORMAT], [$CLANG_FORMAT], [true], [false])])])
|
||||
AS_IF([test "$WITH_CLANG_FORMAT" = fail],
|
||||
[AC_MSG_ERROR([Caller explicitly referenced CLANG_FORMAT=$CLANG_FORMAT which was not found])])
|
||||
AM_CONDITIONAL([WITH_CLANG_FORMAT], [$WITH_CLANG_FORMAT])
|
||||
|
||||
# Subst LIBZMQ_EXTRA_CFLAGS & CXXFLAGS & LDFLAGS
|
||||
AC_SUBST(LIBZMQ_EXTRA_CFLAGS)
|
||||
AC_SUBST(LIBZMQ_EXTRA_CXXFLAGS)
|
||||
|
Loading…
Reference in New Issue
Block a user