Copy the prebuilt analyzer.

This is copied into the platform prebuilts now, so we don't need to
copy our own (and can remove external/clang from the manifest).

Bug: http://b/22183733
Change-Id: I08770d69fb687ccb32275ad571f83963c19a8149
diff --git a/README.md b/README.md
index 2dce39e..80d2866 100644
--- a/README.md
+++ b/README.md
@@ -43,8 +43,6 @@
       when this toolchain is used.
 * `prebuilt/$HOST_ARCH/` contains various tools to make the build system hermetic.
     * make, awk, sed, perl, python, yasm, and for Windows: cmp.exe and echo.exe
-* `prebuilt/common` contains the `scan-build` and `scan-view` scripts used by
-  static analyzer via `NDK_ANALYZE=1`.
 * `ndk-depends` and `ndk-stack` should probably go in `prebuilt/` to avoid
   collisions between host variants.
 
diff --git a/build/tools/build-analyzer.sh b/build/tools/build-analyzer.sh
deleted file mode 100755
index 88a541d..0000000
--- a/build/tools/build-analyzer.sh
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/sh
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-#  This shell script is used to copy clang tool "scan-build" and "scan-view"
-#  for the Android NDK.
-#
-
-# include common function and variable definitions
-. `dirname $0`/prebuilt-common.sh
-
-PROGRAM_PARAMETERS="<ndk-dir>"
-
-PROGRAM_DESCRIPTION=\
-"Copy clang static code analyzer for the Android NDK.
-
-Where <ndk-dir> is the top-level NDK installation path."
-
-RELEASE=`date +%Y%m%d`
-
-PACKAGE_DIR=
-register_var_option "--package-dir=<path>" PACKAGE_DIR "Create archive tarball in specific directory"
-
-extract_parameters "$@"
-
-set_parameters ()
-{
-    NDK_DIR="$1"
-    CLANG_DIR=$ANDROID_BUILD_TOP/external/clang
-
-    SCAN_BUILD_SRC_DIR=$CLANG_DIR/tools/scan-build
-    if [ ! -d "$SCAN_BUILD_SRC_DIR" ] ; then
-        echo "ERROR: Source directory does not contain scan-build: $SCAN_BUILD_SRC_DIR"
-        exit 1
-    fi
-
-    SCAN_VIEW_SRC_DIR=$CLANG_DIR/tools/scan-view
-    if [ ! -d "$SCAN_VIEW_SRC_DIR" ] ; then
-        echo "ERROR: Source directory does not contain scan-view: $SCAN_VIEW_SRC_DIR"
-        exit 1
-    fi
-
-    LICENSE_FILE=$CLANG_DIR/LICENSE.TXT
-    if [ ! -f "$LICENSE_FILE" ] ; then
-        echo "ERROR: Source directory does not contain clang license file: $LICENSE_FILE"
-        exit 1
-    fi
-
-    # Check NDK installation directory
-    #
-    if [ -z "$NDK_DIR" ] ; then
-        echo "ERROR: Missing NDK directory parameter. See --help for details."
-        exit 1
-    fi
-
-    if [ ! -d "$NDK_DIR" ] ; then
-        mkdir -p $NDK_DIR
-        fail_panic "Could not create target NDK installation path: $NDK_DIR"
-    fi
-
-    log "Using NDK directory: $NDK_DIR"
-}
-
-set_parameters $PARAMETERS
-
-if [ "$PACKAGE_DIR" ]; then
-    mkdir -p "$PACKAGE_DIR"
-    fail_panic "Could not create package directory: $PACKAGE_DIR"
-fi
-
-# copy scan_build and scan_view
-SCAN_BUILD_SUBDIR="prebuilt/common/scan-build"
-run copy_directory "$SCAN_BUILD_SRC_DIR" "$NDK_DIR/$SCAN_BUILD_SUBDIR"
-cp -p "$LICENSE_FILE" "$NDK_DIR/$SCAN_BUILD_SUBDIR"
-rm -f $NDK_DIR/$SCAN_BUILD_SUBDIR/scan-build.1
-
-SCAN_VIEW_SUBDIR="prebuilt/common/scan-view"
-run copy_directory "$SCAN_VIEW_SRC_DIR" "$NDK_DIR/$SCAN_VIEW_SUBDIR"
-cp -p "$LICENSE_FILE" "$NDK_DIR/$SCAN_VIEW_SUBDIR"
-
-if [ "$PACKAGE_DIR" ]; then
-    ARCHIVE="scan-build-view.tar.bz2"
-    dump "Packaging $ARCHIVE"
-    pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SCAN_BUILD_SUBDIR" "$SCAN_VIEW_SUBDIR"
-fi
-
-dump "Done."
diff --git a/build/tools/build-host-prebuilts.sh b/build/tools/build-host-prebuilts.sh
index f339304..cf21aee 100755
--- a/build/tools/build-host-prebuilts.sh
+++ b/build/tools/build-host-prebuilts.sh
@@ -339,10 +339,6 @@
     # We're done for this system.
 done
 
-# Build tools common to all systems.
-run $BUILDTOOLS/build-analyzer.sh "$NDK_DIR" --package-dir="$PACKAGE_DIR"
-fail_panic "Could not build analyzer!"
-
 if [ "$PACKAGE_DIR" ]; then
     echo "Done, please look at $PACKAGE_DIR"
 else
diff --git a/build/tools/package-release.sh b/build/tools/package-release.sh
index 5107e03..366b3f0 100755
--- a/build/tools/package-release.sh
+++ b/build/tools/package-release.sh
@@ -496,9 +496,6 @@
         fi
     fi
 
-    # Unpack other host tools
-    unpack_prebuilt scan-build-view "$DSTDIR" "$DSTDIR64"
-
     # Unpack renderscript headers/libs; http://b/22377128.
     echo "WARNING: no renderscript headers/libs! http://b/22377128"
     #unpack_prebuilt renderscript "$DSTDIR" "$DSTDIR64"
diff --git a/ndk-build b/ndk-build
index 62d6dc8..2bb06b8 100755
--- a/ndk-build
+++ b/ndk-build
@@ -313,8 +313,9 @@
     APP_ABIS=`get_build_var APP_ABI`
     for ABI in $APP_ABIS; do
         TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $ABI`
-        PERL5LIB="$HOST_PERL_LIB" "$HOST_PERL" $PROGDIR/prebuilt/common/scan-build/scan-build \
-            --use-analyzer $PROGDIR/toolchains/llvm-${DEFAULT_LLVM_VERSION}/prebuilt/$HOST_TAG/bin/${ABI}/analyzer \
+        LLVM_PATH=$PROGDIR/toolchains/llvm-${DEFAULT_LLVM_VERSION}/prebuilt/$HOST_TAG
+        PERL5LIB="$HOST_PERL_LIB" "$HOST_PERL" $LLVM_PATH/tools/scan-build/scan-build \
+            --use-analyzer $LLVM_PATH/bin/clang \
             --use-cc ${TOOLCHAIN_PREFIX}gcc \
             --use-c++ ${TOOLCHAIN_PREFIX}g++ \
             --status-bugs \