clang-format generated code for easier debugging

This commit is contained in:
Nicolas Williams
2021-01-19 14:23:58 -06:00
parent 37ab2a5308
commit 6d85ba384f
2 changed files with 12 additions and 2 deletions

View File

@@ -143,11 +143,20 @@ check-local::
SUFFIXES += .x .z .hx SUFFIXES += .x .z .hx
# It's useful for debugging to format generated sources. The default for all
# clang-format styles is to sort includes, but in many cases in-tree we really
# don't want to do that.
.x.c: .x.c:
@cmp -s $< $@ 2> /dev/null || cp $< $@ @if [ -z "$(CLANG_FORMAT)" ]; then \
cmp -s $< $@ 2> /dev/null || cp $< $@; \
else \
cp $< $@.tmp.c; \
$(CLANG_FORMAT) -style='{BasedOnStyle: Chromium, SortIncludes: false}' -i $@.tmp.c; \
cmp -s $@.tmp.c $@ 2> /dev/null || mv $@.tmp.c $@; \
fi
.hx.h: .hx.h:
@cmp -s $< $@ 2> /dev/null || cp $< $@ @cmp -s $< $@ 2> /dev/null || cp $< $@;
SUFFIXES += .1 .3 .5 .7 .8 .cat1 .cat3 .cat5 .cat7 .cat8 SUFFIXES += .1 .3 .5 .7 .8 .cat1 .cat3 .cat5 .cat7 .cat8

View File

@@ -18,6 +18,7 @@ dnl Checks for programs.
AC_PROG_CC AC_PROG_CC
AM_PROG_CC_C_O AM_PROG_CC_C_O
AC_PROG_CPP AC_PROG_CPP
AC_CHECK_PROG(CLANG_FORMAT, clang-format, [clang-format], [no])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])