Remove core/clang/versions.mk and scan-build wrapper

* Use the definitions of ClangDefaultBase and ClangDefaultVersion
  in build/soong/cc/config/global.go.
* scan-build is too old;
  replaced by better clang-tidy's -clang-analyzer-* checks.
* WITH_STATIC_ANALYZER is still effective
  to invoke ccc-analyzer or c++-analyzer.

Test: make checkbuild
Change-Id: Ifd159dd28e529d5d3c9807f5e391911365da8cdb
This commit is contained in:
Chih-Hung Hsieh 2018-02-15 11:20:04 -08:00
parent 2a519d5a9b
commit 7ed0db8d1d
4 changed files with 10 additions and 59 deletions

View File

@ -617,6 +617,9 @@ ifeq ($(strip $(my_cc)),)
my_cc := $(my_cc_wrapper) $(my_cc) my_cc := $(my_cc_wrapper) $(my_cc)
endif endif
SYNTAX_TOOLS_PREFIX := \
$(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/libexec
ifneq ($(LOCAL_NO_STATIC_ANALYZER),true) ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \ my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
$(SYNTAX_TOOLS_PREFIX)/ccc-analyzer $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer

View File

@ -1,4 +0,0 @@
## Clang/LLVM release versions.
LLVM_PREBUILTS_VERSION ?= clang-4579689
LLVM_PREBUILTS_BASE ?= prebuilts/clang/host

View File

@ -413,33 +413,11 @@ ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
WITH_STATIC_ANALYZER := WITH_STATIC_ANALYZER :=
endif endif
# define clang/llvm versions and base directory.
include $(BUILD_SYSTEM)/clang/versions.mk
# Unset WITH_TIDY_ONLY if global WITH_TIDY_ONLY is not true nor 1. # Unset WITH_TIDY_ONLY if global WITH_TIDY_ONLY is not true nor 1.
ifeq (,$(filter 1 true,$(WITH_TIDY_ONLY))) ifeq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
WITH_TIDY_ONLY := WITH_TIDY_ONLY :=
endif endif
PATH_TO_CLANG_TIDY := \
$(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin/clang-tidy
ifeq ($(wildcard $(PATH_TO_CLANG_TIDY)),)
ifneq (,$(filter 1 true,$(WITH_TIDY)))
$(warning *** Disable WITH_TIDY because $(PATH_TO_CLANG_TIDY) does not exist)
endif
PATH_TO_CLANG_TIDY :=
endif
# Disable WITH_STATIC_ANALYZER if tool can't be found
SYNTAX_TOOLS_PREFIX := \
$(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/tools/scan-build/libexec
ifneq ($(strip $(WITH_STATIC_ANALYZER)),)
ifeq ($(wildcard $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer),)
$(warning *** Disable WITH_STATIC_ANALYZER because $(SYNTAX_TOOLS_PREFIX)/ccc-analyzer does not exist)
WITH_STATIC_ANALYZER :=
endif
endif
# Pick a Java compiler. # Pick a Java compiler.
include $(BUILD_SYSTEM)/combo/javac.mk include $(BUILD_SYSTEM)/combo/javac.mk

View File

@ -741,33 +741,11 @@ function gettop
fi fi
} }
# Return driver for "make", if any (eg. static analyzer)
function getdriver()
{
local T="$1"
test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
if [ -n "$WITH_STATIC_ANALYZER" ]; then
# Use scan-build to collect all static analyzer reports into directory
# /tmp/scan-build-yyyy-mm-dd-hhmmss-*
# The clang compiler passed by --use-analyzer here is not important.
# build/make/core/binary.mk will set CLANG_CXX and CLANG before calling
# c++-analyzer and ccc-analyzer.
local CLANG_VERSION=$(get_build_var LLVM_PREBUILTS_VERSION)
local BUILD_OS=$(get_build_var BUILD_OS)
local CLANG_DIR="$T/prebuilts/clang/host/${BUILD_OS}-x86/${CLANG_VERSION}"
echo "\
${CLANG_DIR}/tools/scan-build/bin/scan-build \
--use-analyzer ${CLANG_DIR}/bin/clang \
--status-bugs"
fi
}
function m() function m()
{ {
local T=$(gettop) local T=$(gettop)
local DRV=$(getdriver $T)
if [ "$T" ]; then if [ "$T" ]; then
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@ _wrap_build $T/build/soong/soong_ui.bash --make-mode $@
else else
echo "Couldn't locate the top of the tree. Try setting TOP." echo "Couldn't locate the top of the tree. Try setting TOP."
return 1 return 1
@ -794,11 +772,10 @@ function findmakefile()
function mm() function mm()
{ {
local T=$(gettop) local T=$(gettop)
local DRV=$(getdriver $T)
# If we're sitting in the root of the build tree, just do a # If we're sitting in the root of the build tree, just do a
# normal build. # normal build.
if [ -f build/soong/soong_ui.bash ]; then if [ -f build/soong/soong_ui.bash ]; then
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@ _wrap_build $T/build/soong/soong_ui.bash --make-mode $@
else else
# Find the closest Android.mk file. # Find the closest Android.mk file.
local M=$(findmakefile) local M=$(findmakefile)
@ -833,7 +810,7 @@ function mm()
if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then
MODULES=tidy_only MODULES=tidy_only
fi fi
ONE_SHOT_MAKEFILE=$M _wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $MODULES $ARGS ONE_SHOT_MAKEFILE=$M _wrap_build $T/build/soong/soong_ui.bash --make-mode $MODULES $ARGS
fi fi
fi fi
} }
@ -841,7 +818,6 @@ function mm()
function mmm() function mmm()
{ {
local T=$(gettop) local T=$(gettop)
local DRV=$(getdriver $T)
if [ "$T" ]; then if [ "$T" ]; then
local MAKEFILE= local MAKEFILE=
local MODULES= local MODULES=
@ -901,7 +877,7 @@ function mmm()
fi fi
# Convert "/" to "-". # Convert "/" to "-".
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
ONE_SHOT_MAKEFILE="$MAKEFILE" _wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS ONE_SHOT_MAKEFILE="$MAKEFILE" _wrap_build $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS
else else
echo "Couldn't locate the top of the tree. Try setting TOP." echo "Couldn't locate the top of the tree. Try setting TOP."
return 1 return 1
@ -911,9 +887,8 @@ function mmm()
function mma() function mma()
{ {
local T=$(gettop) local T=$(gettop)
local DRV=$(getdriver $T)
if [ -f build/soong/soong_ui.bash ]; then if [ -f build/soong/soong_ui.bash ]; then
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@ _wrap_build $T/build/soong/soong_ui.bash --make-mode $@
else else
if [ ! "$T" ]; then if [ ! "$T" ]; then
echo "Couldn't locate the top of the tree. Try setting TOP." echo "Couldn't locate the top of the tree. Try setting TOP."
@ -925,14 +900,13 @@ function mma()
local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M}) local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M})
# Convert "/" to "-". # Convert "/" to "-".
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@ $MODULES_IN_PATHS _wrap_build $T/build/soong/soong_ui.bash --make-mode $@ $MODULES_IN_PATHS
fi fi
} }
function mmma() function mmma()
{ {
local T=$(gettop) local T=$(gettop)
local DRV=$(getdriver $T)
if [ "$T" ]; then if [ "$T" ]; then
local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
@ -963,7 +937,7 @@ function mmma()
done done
# Convert "/" to "-". # Convert "/" to "-".
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $ARGS $MODULES_IN_PATHS _wrap_build $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $ARGS $MODULES_IN_PATHS
else else
echo "Couldn't locate the top of the tree. Try setting TOP." echo "Couldn't locate the top of the tree. Try setting TOP."
return 1 return 1