Add support for clang to the android build scripts

Review URL: https://codereview.chromium.org/692953002
diff --git a/platform_tools/android/bin/android_setup.sh b/platform_tools/android/bin/android_setup.sh
index 65774e5..e97b045 100755
--- a/platform_tools/android/bin/android_setup.sh
+++ b/platform_tools/android/bin/android_setup.sh
@@ -23,6 +23,8 @@
     shift
   elif [[ "$1" == "--release" ]]; then
     BUILDTYPE=Release
+  elif [[ "$1" == "--clang" ]]; then
+    USE_CLANG="true"
   else
     APP_ARGS=("${APP_ARGS[@]}" "${1}")
   fi
diff --git a/platform_tools/android/bin/utils/setup_toolchain.sh b/platform_tools/android/bin/utils/setup_toolchain.sh
index 1866971..6bb6b00 100755
--- a/platform_tools/android/bin/utils/setup_toolchain.sh
+++ b/platform_tools/android/bin/utils/setup_toolchain.sh
@@ -46,6 +46,12 @@
   fi
   exportVar ANDROID_TOOLCHAIN "${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}/bin"
 
+  # Hack for NDK_REV == 10c to ensure that clang is present as it was
+  # added to the tarball after it was initially distributed.
+  if [ ! -x ${ANDROID_TOOLCHAIN}/clang ]; then
+    rm -rf ${TOOLCHAIN_DIR}/${TOOLCHAIN_TYPE}
+  fi
+
   # if the toolchain doesn't exist on your machine then we need to fetch it
   if [ ! -d "$ANDROID_TOOLCHAIN" ]; then
     mkdir -p $TOOLCHAIN_DIR
@@ -59,9 +65,9 @@
     tar -xzf $TARBALL $TOOLCHAIN_TYPE
     rm $TARBALL
     popd
-  fi 
+  fi
 
-  verbose "Targeting NDK API $API_LEVEL for use on Android 4.0 (NDK Revision $NDK_REV) and above"  
+  verbose "Targeting NDK API $API_LEVEL (NDK Revision $NDK_REV)"
 }
 
 #check to see if the toolchain has been defined and if not setup the default toolchain
@@ -84,9 +90,17 @@
 
 CCACHE=${ANDROID_MAKE_CCACHE-$(which ccache || true)}
 
-exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
-exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
-exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
+if [ -z $USE_CLANG ]; then
+  exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
+  exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-g++"
+  exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-gcc"
+else
+  # temporarily disable ccache as it is generating errors
+  CCACHE=""
+  exportVar CC "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
+  exportVar CXX "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang++"
+  exportVar LINK "$CCACHE $ANDROID_TOOLCHAIN_PREFIX-clang"
+fi
 
 exportVar AR "$ANDROID_TOOLCHAIN_PREFIX-ar"
 exportVar RANLIB "$ANDROID_TOOLCHAIN_PREFIX-ranlib"
@@ -96,7 +110,10 @@
 # Create symlinks for nm & readelf and add them to the path so that the ninja
 # build uses them instead of attempting to use the one on the system.
 # This is required to build using ninja on a Mac.
-ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm
-ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf
-ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as
+if [ $(uname) == "Darwin" ]; then
+  ln -sf $ANDROID_TOOLCHAIN_PREFIX-nm $ANDROID_TOOLCHAIN/nm
+  ln -sf $ANDROID_TOOLCHAIN_PREFIX-readelf $ANDROID_TOOLCHAIN/readelf
+  ln -sf $ANDROID_TOOLCHAIN_PREFIX-as $ANDROID_TOOLCHAIN/as
+fi
+
 exportVar PATH $ANDROID_TOOLCHAIN:$PATH