From 1e8e3c274db4719e5235ea5191fa7410bdb2abb3 Mon Sep 17 00:00:00 2001 From: Khalid Zubair Date: Tue, 6 Oct 2015 11:00:55 -0700 Subject: [PATCH] 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(-) diff --git a/envsetup.sh b/envsetup.sh index a80b0b2c3..dfc6d9fb2 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -2182,14 +2182,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() { -- 2.11.0