From 683126f05c4cbeb7913ab50f520a3f6611441c15 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Thu, 13 Nov 2014 14:37:12 -0800 Subject: [PATCH] utils: build-kitkat smarter aosp invocation * Attempt to find the aosp binary with the following priority: 1. If AOSP_BIN is set, use that 2. If aosp is found in the shell $PATH 3. Grab it from the web --- tests/build-kitkat.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/tests/build-kitkat.sh b/tests/build-kitkat.sh index fe33903..6c744db 100755 --- a/tests/build-kitkat.sh +++ b/tests/build-kitkat.sh @@ -4,8 +4,6 @@ # set -ex -AOSP_BIN=${AOSP_BIN:-aosp} - if [ "$1" = "docker" ]; then branch=android-4.4.4_r2.0.1 cpus=$(grep ^processor /proc/cpuinfo | wc -l) @@ -15,10 +13,34 @@ if [ "$1" = "docker" ]; then prebuilts/misc/linux-x86/ccache/ccache -M 10G - source build/envsetup.sh + source build/envsetup.sh lunch aosp_arm-eng make -j $cpus -else +else + aosp_url="https://raw.githubusercontent.com/kylemanna/docker-aosp/master/utils/aosp" + args="run.sh docker" export AOSP_EXTRA_ARGS="-v $(readlink -f $0):/usr/local/bin/run.sh:ro" - $AOSP_BIN run.sh docker + + # + # Try to invoke the aosp wrapper with the following priority: + # + # 1. If AOSP_BIN is set, use that + # 2. If aosp is found in the shell $PATH + # 3. Grab it from the web + # + if [ -n "$AOSP_BIN" ]; then + $AOSP_BIN $args + elif [ -x "../utils/aosp" ]; then + ../utils/aosp $args + elif [ -n "$(type -P aosp)" ]; then + aosp $args + else + if [ -n "$(type -P curl)" ]; then + bash <(curl -s $aosp_url) $args + elif [ -n "$(type -P wget)" ]; then + bash <(wget -q $aosp_url -O -) $args + else + echo "Unable to run the aosp binary" + fi + fi fi