Add clang-format call to pretty Makefile target
This commit is contained in:
parent
f2b3572799
commit
6393acc1b0
@ -129,10 +129,5 @@ PenaltyBreakString: 1000
|
|||||||
PenaltyExcessCharacter: 1000000
|
PenaltyExcessCharacter: 1000000
|
||||||
PenaltyReturnTypeOnItsOwnLine: 60
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
|
||||||
# Misc
|
|
||||||
RawStringFormats:
|
|
||||||
- Delimiter: pb
|
|
||||||
Language: TextProto
|
|
||||||
BasedOnStyle: google
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|||||||
2
.github/CONTRIBUTING.md
vendored
2
.github/CONTRIBUTING.md
vendored
@ -50,7 +50,7 @@ To make changes, you need to edit the following files:
|
|||||||
## Note
|
## Note
|
||||||
|
|
||||||
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
|
- If you open a pull request, the code will be automatically tested with [Valgrind](http://valgrind.org)'s Memcheck tool to detect memory leaks. Please be aware that the execution with Valgrind _may_ in rare cases yield different behavior than running the code directly. This can result in failing unit tests which run successfully without Valgrind.
|
||||||
- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation. If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
|
- There is a Makefile target `make pretty` which runs [Artistic Style](http://astyle.sourceforge.net) to fix indentation and [clang-format](https://clang.llvm.org/docs/ClangFormat.html). If possible, run it before opening the pull request. Otherwise, we shall run it afterward.
|
||||||
|
|
||||||
## Please don't
|
## Please don't
|
||||||
|
|
||||||
|
|||||||
10
Makefile
10
Makefile
@ -54,7 +54,7 @@ all:
|
|||||||
@echo "json_unit - create single-file test executable"
|
@echo "json_unit - create single-file test executable"
|
||||||
@echo "pedantic_clang - run Clang with maximal warning flags"
|
@echo "pedantic_clang - run Clang with maximal warning flags"
|
||||||
@echo "pedantic_gcc - run GCC with maximal warning flags"
|
@echo "pedantic_gcc - run GCC with maximal warning flags"
|
||||||
@echo "pretty - beautify code with Artistic Style"
|
@echo "pretty - beautify code with Artistic Style and clang-format"
|
||||||
@echo "run_benchmarks - build and run benchmarks"
|
@echo "run_benchmarks - build and run benchmarks"
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -276,9 +276,12 @@ clang_analyze:
|
|||||||
##########################################################################
|
##########################################################################
|
||||||
# maintainer targets
|
# maintainer targets
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
ASTYLE := $(shell command -v astyle 2> /dev/null)
|
||||||
|
CLANG_FORMAT := $(shell command -v clang-format 2> /dev/null)
|
||||||
|
|
||||||
# pretty printer
|
# pretty printer
|
||||||
pretty:
|
pretty:
|
||||||
|
ifdef ASTYLE
|
||||||
astyle --style=allman --indent=spaces=4 --indent-modifiers \
|
astyle --style=allman --indent=spaces=4 --indent-modifiers \
|
||||||
--indent-switches --indent-preproc-block --indent-preproc-define \
|
--indent-switches --indent-preproc-block --indent-preproc-define \
|
||||||
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
|
--indent-col1-comments --pad-oper --pad-header --align-pointer=type \
|
||||||
@ -286,6 +289,11 @@ pretty:
|
|||||||
--lineend=linux --preserve-date --suffix=none --formatted \
|
--lineend=linux --preserve-date --suffix=none --formatted \
|
||||||
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp \
|
$(SRCS) $(AMALGAMATED_FILE) test/src/*.cpp \
|
||||||
benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
benchmarks/src/benchmarks.cpp doc/examples/*.cpp
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifdef CLANG_FORMAT
|
||||||
|
clang-format -i $(SRCS)
|
||||||
|
endif
|
||||||
|
|
||||||
# create single header file
|
# create single header file
|
||||||
amalgamate: $(AMALGAMATED_FILE)
|
amalgamate: $(AMALGAMATED_FILE)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user