summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2016-09-07 13:10:50 +0200
committerDamjan Marion <damarion@cisco.com>2016-09-07 15:50:36 +0200
commit24704851584a2b1db4545a2a3cd3fc73dff2ce5f (patch)
tree091a8e835da34a317d12428fc570b086ce13c3a0
parentffa652afd8847438af4d0bdc253789a67a4f1da1 (diff)
checkstyle: improve speed by checking only recently changed files
This change makes checkstyle much faster by checking only recently changed files. It only checks files changed in last commit and files which are localy modified. Old behavior is preserved by specifying argument "--full" when invoking script. In addition "make checkstyle" and "make "fixstyle" actions are added to the top-level Makefile. Change-Id: I7d86225bd282f32ee508e7f52692a3778ac8dcda Signed-off-by: Damjan Marion <damarion@cisco.com>
-rw-r--r--Makefile7
-rwxr-xr-xbuild-root/scripts/checkstyle.sh21
2 files changed, 25 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f218cb082eb..b3bd8d3c906 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,8 @@ help:
@echo " ctags - (re)generate ctags database"
@echo " gtags - (re)generate gtags database"
@echo " cscope - (re)generate cscope database"
+ @echo " checkstyle - check coding style"
+ @echo " fixstyle - fix coding style"
@echo " doxygen - (re)generate documentation"
@echo " bootstrap-doxygen - setup Doxygen dependencies"
@echo " wipe-doxygen - wipe all generated documentation"
@@ -233,6 +235,11 @@ gtags: ctags
cscope: cscope.files
@cscope -b -q -v
+checkstyle:
+ @build-root/scripts/checkstyle.sh
+
+fixstyle:
+ @build-root/scripts/checkstyle.sh --fix
#
# Build the documentation
diff --git a/build-root/scripts/checkstyle.sh b/build-root/scripts/checkstyle.sh
index df72cdb2d8a..60129676a2e 100755
--- a/build-root/scripts/checkstyle.sh
+++ b/build-root/scripts/checkstyle.sh
@@ -3,14 +3,29 @@
VPP_DIR=`dirname $0`/../../
EXIT_CODE=0
FIX="0"
+FULL="0"
CHECKSTYLED_FILES=""
UNCHECKSTYLED_FILES=""
# If the user provides --fix, then actually fix things
# Note: this is meant for use outside of the CI Jobs, by users cleaning things up
-if [ $# -gt 0 ] && [ ${1} == '--fix' ]; then
- FIX="1"
+while true; do
+ case ${1} in
+ --fix)
+ FIX="1"
+ ;;
+ --full)
+ FULL="1"
+ ;;
+ esac
+ shift || break
+done
+
+if [ "${FULL}" == "1" ]; then
+ FILELIST=$(git ls-tree -r HEAD --name-only)
+else
+ FILELIST=$((git diff HEAD~1.. --name-only; git ls-files -m ) | sort -u)
fi
# Check to make sure we have indent. Exit if we don't with an error message, but
@@ -24,7 +39,7 @@ indent --version
cd ${VPP_DIR}
git status
-for i in `git ls-tree -r HEAD --name-only`;do
+for i in ${FILELIST}; do
if [ -f ${i} ] && [ ${i} != "build-root/scripts/checkstyle.sh" ] && [ ${i} != "build-root/emacs-lisp/fix-coding-style.el" ]; then
grep -q "fd.io coding-style-patch-verification: ON" ${i}
if [ $? == 0 ]; then