Merge "ndk-which: support all ABIs."
diff --git a/ndk-which b/ndk-which
index ce83970..67aec48 100755
--- a/ndk-which
+++ b/ndk-which
@@ -15,18 +15,48 @@
# limitations under the License.
#
-# This script is useful for learning the path of the active toolchain
-# components within the ndk.
-# Run this script without parameters, for usage hints.
+#
+# DEPRECATED
+#
-# show usage if no parameter given
-WHICH=$1
-if [ "$WHICH" == "" ]; then
- echo "USAGE: ndk-which <tool>"
- echo "where tool is 'gdb', 'gcc', 'objdump', etc."
+# This script shows the path of the active toolchain components within
+# the ndk. This was necessary for GCC and binutils, where each ABI had
+# its own tools, but is not needed for LLVM-based tools which should be
+# used in preference.
+
+usage() {
+ echo "USAGE: ndk-which [--abi ABI] TOOL"
+ echo "ABI is 'armeabi-v7a', 'arm64-v8a', 'x86', or 'x86_64'"
+ echo "TOOL is 'gdb', 'objdump', 'readelf', etc."
+ echo
+ echo "Note that LLVM replacements for binutils tools work for all ABIs."
exit 1
+}
+
+ABI=armeabi-v7a
+
+while (( "$#" )); do
+ case "$1" in
+ --abi)
+ ABI=$2
+ shift 2
+ abis="armeabi-v7a|arm64-v8a|x86|x86_64"
+ if [[ ! "$ABI" =~ $abis ]]; then usage; fi
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
+
+TOOL=$1
+shift
+
+if [ "$#" != 0 -o "$TOOL" == "" ]; then
+ usage
fi
+# This tool is installed in prebuilt/linux-x86_64/bin/.
MYNDKDIR=`dirname $0`/../../..
# create a temporary skeleton project so that we can leverage build-local.mk
@@ -36,21 +66,18 @@
include $(CLEAR_VARS)
END_OF_FILE
-# 'get_build_var_for_abi' was copied from ndk-gdb
-get_build_var_for_abi ()
-{
- if [ -z "$GNUMAKE" ] ; then
- GNUMAKE=make
- fi
- NDK_PROJECT_PATH=$TMPDIR $GNUMAKE --no-print-dir -f $MYNDKDIR/build/core/build-local.mk DUMP_$1 APP_ABI=$2
+get_build_var_for_abi() {
+ if [ -z "$GNUMAKE" ] ; then
+ GNUMAKE=make
+ fi
+ NDK_PROJECT_PATH=$TMPDIR $GNUMAKE --no-print-dir -f $MYNDKDIR/build/core/build-local.mk DUMP_$1 APP_ABI=$2
}
-TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX armeabi`
+TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX $ABI`
rm -Rf $TMPDIR
# fully qualified file name
-FQFN=${TOOLCHAIN_PREFIX}$WHICH
+FQFN=${TOOLCHAIN_PREFIX}$TOOL
# use the host system's 'which' to decide/report if the file exists or not, and is executable
which "$FQFN"
-