From abcd19499d0ba475715dd76a8d0f7c08c630c7ea Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Tue, 6 Oct 2015 11:00:55 -0700 Subject: mka: allow mka to be run from anywhere in the tree The Android build system expects to be launched from the top of the tree. Invoking mka at any other level often has unintended consequence (e.g. targets the host ARCH because ARCH was not set). The various build shortcuts like m and mm invoke Make from the top of the tree. mka now does the same. Change-Id: Id956cf04cbaf1d12d12549ca54e32b9c2ce1fc29 --- envsetup.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'envsetup.sh') diff --git a/envsetup.sh b/envsetup.sh index 8f9dfdb..140f80c 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -2096,14 +2096,20 @@ function cmrebase() { } function mka() { - case `uname -s` in - Darwin) - make -j `sysctl hw.ncpu|cut -d" " -f2` "$@" - ;; - *) - mk_timer schedtool -B -n 1 -e ionice -n 1 make -j$(cat /proc/cpuinfo | grep "^processor" | wc -l) "$@" - ;; - esac + local T=$(gettop) + if [ "$T" ]; then + case `uname -s` in + Darwin) + make -C $T -j `sysctl hw.ncpu|cut -d" " -f2` "$@" + ;; + *) + mk_timer schedtool -B -n 1 -e ionice -n 1 make -C $T -j$(cat /proc/cpuinfo | grep "^processor" | wc -l) "$@" + ;; + esac + + else + echo "Couldn't locate the top of the tree. Try setting TOP." + fi } function cmka() { -- cgit v1.1