From 6bfa9efeea91fbd9949f50704bb3d2f86276e52e Mon Sep 17 00:00:00 2001 From: Pavel Hrdina Date: Tue, 30 Jun 2020 19:27:33 +0200 Subject: [PATCH] meson: add static analysis detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pavel Hrdina Reviewed-by: Ján Tomko Reviewed-by: Peter Krempa Reviewed-by: Neal Gompa --- configure.ac | 15 --------------- meson.build | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index d5b3a653dc..f006b7dbe0 100644 --- a/configure.ac +++ b/configure.ac @@ -720,21 +720,6 @@ if test "$want_ifconfig" = "yes"; then AC_DEFINE_UNQUOTED([IFCONFIG_PATH], "$IFCONFIG_PATH", [path to ifconfig binary]) fi -# Detect when running under the clang static analyzer's scan-build driver -# or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly. -AC_CACHE_CHECK([whether this build is done by a static analysis tool], - [lv_cv_static_analysis], [ - lv_cv_static_analysis=no - if test -n "${CCC_ANALYZER_ANALYSIS+set}" || \ - test -n "$COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD"; then - lv_cv_static_analysis=yes - fi - ]) -t=0 -test "x$lv_cv_static_analysis" = xyes && t=1 -AC_DEFINE_UNQUOTED([STATIC_ANALYSIS], [$t], - [Define to 1 when performing static analysis.]) - GNUmakefile=GNUmakefile m4_if(m4_version_compare([2.61a.100], m4_defn([m4_PACKAGE_VERSION])), [1], [], diff --git a/meson.build b/meson.build index ff4fcd3166..530ac720ba 100644 --- a/meson.build +++ b/meson.build @@ -146,6 +146,20 @@ if get_option('test_coverage') endif +# Detect when running under the clang static analyzer's scan-build driver +# or Coverity-prevent's cov-build. Define STATIC_ANALYSIS accordingly. + +rc = run_command( + 'sh', '-c', + 'test -n "${CCC_ANALYZER_HTML}"' + + ' -o -n "${CCC_ANALYZER_ANALYSIS+set}"' + + ' -o -n "$COVERITY_BUILD_COMMAND$COVERITY_LD_PRELOAD"', +) +if rc.returncode() == 0 + conf.set('STATIC_ANALYSIS', 1) +endif + + # figure out libvirt version strings arr_version = meson.project_version().split('.')