Add formatting/static analysis (#486)
* Reform source with clang-format. Rules applied with: $ find . -iname *.h -o -iname *.cc | xargs clang-format \ -style=file -i -fallback-style=google * Add clang-format and analyze to build. Based on the excellent work at: https://github.com/ttroy50/cmake-examples * Clean up CMake stuff on macOS. * Remove vim/emacs modelines. * Update copyright dates. * Build fixes. * Build fixes. * Build fixes. * Build fixes. * Build fixes. * Build fixes.
This commit is contained in:
18
cmake/scripts/clang-format-check-changed
Executable file
18
cmake/scripts/clang-format-check-changed
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Required because cmake root isn't git root in this example
|
||||
CLANG_FORMAT_BIN=$1
|
||||
GIT_ROOT=`git rev-parse --show-toplevel`
|
||||
|
||||
pushd ${GIT_ROOT} > /dev/null
|
||||
|
||||
git status --porcelain \
|
||||
| egrep '*\.cpp|*\.h|*\.cxx|*\.hxx|*\.hpp|*\.cc' \
|
||||
| awk -F " " '{print $NF}' \
|
||||
| xargs -r ${CLANG_FORMAT_BIN} -style=file -output-replacements-xml \
|
||||
| grep "replacement offset" 2>&1 > /dev/null
|
||||
|
||||
RET=$?
|
||||
popd > /dev/null
|
||||
|
||||
exit ${RET}
|
Reference in New Issue
Block a user