From 38b2bc9a883d88b5257673048f687c5ac1fe7446 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 18:55:32 +0300 Subject: scripts: Make pvs do not patch separate directory, add patch mode --- scripts/pvscheck.sh | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index 2e4f990693..faa6f92c9a 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -12,20 +12,24 @@ help() { echo 'Usage:' echo ' pvscheck.sh [target-directory [branch]]' echo ' pvscheck.sh [--recheck] [target-directory]' + echo ' pvscheck.sh --patch' echo - echo ' --recheck: run analysis on a prepared target directory' + echo ' --patch: patch sources in the current directory.' + echo ' Does not run analysis.' echo - echo ' target-directory: Directory where build should occur' + echo ' --recheck: run analysis on a prepared target directory.' + echo + echo ' target-directory: Directory where build should occur.' echo ' Default: ../neovim-pvs' echo - echo ' branch: Branch to check' - echo ' Default: master' + echo ' branch: Branch to check.' + echo ' Default: master.' } get_pvs_comment() { cat > pvs-comment << EOF -// This is an open source non-commercial project. Dear PVS-Studio, please check it. -// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com +// This is an open source non-commercial project. Dear PVS-Studio, please check +// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com EOF } @@ -75,6 +79,8 @@ patch_sources() { build/src/nvim/auto build/config \ -name '*.[ch]' -not -name '*.test-include.c' \ -exec /bin/sh -c "$sh_script" - '{}' \; + + rm pvs-comment } run_analysis() { @@ -103,8 +109,6 @@ do_check() { create_compile_commands - patch_sources - run_analysis } @@ -128,6 +132,11 @@ main() { set -x + if test "x$1" = "x--patch" ; then + patch_sources + exit $? + fi + local recheck= if test "x$1" = "x--recheck" ; then recheck=1 -- cgit From 9fd048d901e1191dc56066e4be70014c3387c9fe Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:04:00 +0300 Subject: scripts: Do not patch already patched sources in patch mode Also do not patch header files, that is not needed. --- scripts/pvscheck.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index faa6f92c9a..e2d2a2eada 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -15,6 +15,7 @@ help() { echo ' pvscheck.sh --patch' echo echo ' --patch: patch sources in the current directory.' + echo ' Does not patch already patched files.' echo ' Does not run analysis.' echo echo ' --recheck: run analysis on a prepared target directory.' @@ -66,18 +67,22 @@ patch_sources() { get_pvs_comment local sh_script=' - cat pvs-comment "$1" > "$1.tmp" - mv "$1.tmp" "$1" + pvs_comment="$(cat pvs-comment ; echo -n EOS)" + filehead="$(head -c $(( ${#pvs_comment} - 3 )) "$1" ; echo -n EOS)" + if test "x$filehead" != "x$pvs_comment" ; then + cat pvs-comment "$1" > "$1.tmp" + mv "$1.tmp" "$1" + fi ' find \ src/nvim test/functional/fixtures test/unit/fixtures \ - -name '*.[ch]' \ + -name '*.c' \ -exec /bin/sh -c "$sh_script" - '{}' \; find \ build/src/nvim/auto build/config \ - -name '*.[ch]' -not -name '*.test-include.c' \ + -name '*.c' -not -name '*.test-include.c' \ -exec /bin/sh -c "$sh_script" - '{}' \; rm pvs-comment -- cgit From 4555bf9e7f8829053e3a687f814a2036d72ce0e1 Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:08:27 +0300 Subject: scripts: Allow patching only build files --- scripts/pvscheck.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index e2d2a2eada..5020d5f86a 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -12,12 +12,14 @@ help() { echo 'Usage:' echo ' pvscheck.sh [target-directory [branch]]' echo ' pvscheck.sh [--recheck] [target-directory]' - echo ' pvscheck.sh --patch' + echo ' pvscheck.sh --patch [--only-build]' echo echo ' --patch: patch sources in the current directory.' echo ' Does not patch already patched files.' echo ' Does not run analysis.' echo + echo ' --only-build: Only patch files in ./build directory.' + echo echo ' --recheck: run analysis on a prepared target directory.' echo echo ' target-directory: Directory where build should occur.' @@ -75,10 +77,12 @@ patch_sources() { fi ' - find \ - src/nvim test/functional/fixtures test/unit/fixtures \ - -name '*.c' \ - -exec /bin/sh -c "$sh_script" - '{}' \; + if test "x$1" != "x--only-build" ; then + find \ + src/nvim test/functional/fixtures test/unit/fixtures \ + -name '*.c' \ + -exec /bin/sh -c "$sh_script" - '{}' \; + fi find \ build/src/nvim/auto build/config \ @@ -138,7 +142,13 @@ main() { set -x if test "x$1" = "x--patch" ; then - patch_sources + shift + if test "x$1" = "x--only-build" ; then + shift + patch_sources --only-build + else + patch_sources + fi exit $? fi -- cgit From 3351016dcde8f8d400c247baaca4a5575d94535d Mon Sep 17 00:00:00 2001 From: ZyX Date: Wed, 19 Apr 2017 19:11:37 +0300 Subject: scripts: Add newline after the comment --- scripts/pvscheck.sh | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/pvscheck.sh b/scripts/pvscheck.sh index 5020d5f86a..32d63646aa 100755 --- a/scripts/pvscheck.sh +++ b/scripts/pvscheck.sh @@ -33,6 +33,7 @@ get_pvs_comment() { cat > pvs-comment << EOF // This is an open source non-commercial project. Dear PVS-Studio, please check // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com + EOF } -- cgit