1#!/bin/bash 2# 3# Copyright (C) 2012 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17 18# This script is useful for learning the path of the active toolchain 19# components within the ndk. 20# Run this script without parameters, for usage hints. 21 22# show usage if no parameter given 23WHICH=$1 24if [ "$WHICH" == "" ]; then 25 echo "USAGE: ndk-which <tool>" 26 echo "where tool is 'gdb', 'gcc', 'objdump', etc." 27 exit 1 28fi 29 30MYNDKDIR=`dirname $0` 31 32# create a temporary skeleton project so that we can leverage build-local.mk 33TMPDIR=/tmp/ndk-which-$$ 34mkdir -p $TMPDIR/jni 35cat >$TMPDIR/jni/Android.mk << "END_OF_FILE" 36include $(CLEAR_VARS) 37END_OF_FILE 38 39# 'get_build_var_for_abi' was copied from ndk-gdb 40get_build_var_for_abi () 41{ 42 if [ -z "$GNUMAKE" ] ; then 43 GNUMAKE=make 44 fi 45 NDK_PROJECT_PATH=$TMPDIR $GNUMAKE --no-print-dir -f $MYNDKDIR/build/core/build-local.mk DUMP_$1 APP_ABI=$2 46} 47 48TOOLCHAIN_PREFIX=`get_build_var_for_abi TOOLCHAIN_PREFIX armeabi` 49rm -Rf $TMPDIR 50 51# fully qualified file name 52FQFN=${TOOLCHAIN_PREFIX}$WHICH 53 54# use the host system's 'which' to decide/report if the file exists or not, and is executable 55which "$FQFN" 56 57