summaryrefslogtreecommitdiffstats
path: root/envsetup.sh
diff options
context:
space:
mode:
authorChirayu Desai <chirayudesai1@gmail.com>2012-10-16 19:40:18 +0530
committerAdnan Begovic <adnan@cyngn.com>2015-10-06 16:12:05 -0700
commitae7a4d0c93ef4af53bd44d71394eb98801e26c0e (patch)
tree01124be2558dbe529d5265a2df3aa2203931effd /envsetup.sh
parent9a26f6e690247a672bb6382e0927e3be2739b68f (diff)
downloadbuild-ae7a4d0c93ef4af53bd44d71394eb98801e26c0e.zip
build-ae7a4d0c93ef4af53bd44d71394eb98801e26c0e.tar.gz
build-ae7a4d0c93ef4af53bd44d71394eb98801e26c0e.tar.bz2
dopush: improvements
- use $OUT instead of replacing device name with a new line and then "tail"ing it. - adb shell stop/start if file is SystemUI.apk or framework/* - and some cleanup. Change-Id: I49278406dc53285b4919f7d41116ad849ec38250
Diffstat (limited to 'envsetup.sh')
-rw-r--r--envsetup.sh114
1 files changed, 61 insertions, 53 deletions
diff --git a/envsetup.sh b/envsetup.sh
index 49746c4..81f8b74 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -756,59 +756,6 @@ EOF
return $?
}
-# Credit for color strip sed: http://goo.gl/BoIcm
-function mmmp()
-{
- if [[ $# < 1 || $1 == "--help" || $1 == "-h" ]]; then
- echo "mmmp [make arguments] <path-to-project>"
- return 1
- fi
-
- # Get product name from cm_<product>
- PRODUCT=`echo $TARGET_PRODUCT | tr "_" "\n" | tail -n 1`
-
- adb start-server # Prevent unexpected starting server message from adb get-state in the next line
- if [ $(adb get-state) != device -a $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
- echo "No device is online. Waiting for one..."
- echo "Please connect USB and/or enable USB debugging"
- until [ $(adb get-state) = device -o $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
- sleep 1
- done
- echo "Device Found.."
- fi
-
- adb root &> /dev/null
- sleep 0.3
- adb wait-for-device &> /dev/null
- sleep 0.3
- adb remount &> /dev/null
-
- mmm $* | tee .log
-
- # Install: <file>
- LOC=$(cat .log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Install' | cut -d ':' -f 2)
-
- # Copy: <file>
- LOC=$LOC $(cat .log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Copy' | cut -d ':' -f 2)
-
- for FILE in $LOC; do
- # Get target file name (i.e. system/bin/adb)
- TARGET=$(echo $FILE | sed "s/\/$PRODUCT\//\n/" | tail -n 1)
-
- # Don't send files that are not in /system.
- if ! echo $TARGET | egrep '^system\/' > /dev/null ; then
- continue
- else
- echo "Pushing: $TARGET"
- adb push $FILE $TARGET
- fi
- done
- rm -f .log
- return 0
-}
-
-alias mmp='mmmp .'
-
function gettop
{
local TOPFILE=build/core/envsetup.mk
@@ -1991,6 +1938,67 @@ function repodiff() {
'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;'
}
+# Credit for color strip sed: http://goo.gl/BoIcm
+function dopush()
+{
+ local func=$1
+ shift
+
+ adb start-server # Prevent unexpected starting server message from adb get-state in the next line
+ if [ $(adb get-state) != device -a $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then
+ echo "No device is online. Waiting for one..."
+ echo "Please connect USB and/or enable USB debugging"
+ until [ $(adb get-state) = device -o $(adb shell busybox test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
+ sleep 1
+ done
+ echo "Device Found."
+ fi
+
+ adb root &> /dev/null
+ sleep 0.3
+ adb wait-for-device &> /dev/null
+ sleep 0.3
+ adb remount &> /dev/null
+
+ $func $* | tee $OUT/.log
+
+ # Install: <file>
+ LOC=$(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Install' | cut -d ':' -f 2)
+
+ # Copy: <file>
+ LOC=$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep 'Copy' | cut -d ':' -f 2)
+
+ for FILE in $LOC; do
+ # Get target file name (i.e. system/bin/adb)
+ TARGET=$(echo $FILE | sed "s#$OUT/##")
+
+ # Don't send files that are not in /system.
+ if ! echo $TARGET | egrep '^system\/' > /dev/null ; then
+ continue
+ else
+ case $TARGET in
+ system/app/SystemUI.apk|system/framework/*)
+ stop_n_start=true
+ ;;
+ *)
+ stop_n_start=false
+ ;;
+ esac
+ if $stop_n_start ; then adb shell stop ; fi
+ echo "Pushing: $TARGET"
+ adb push $FILE $TARGET
+ if $stop_n_start ; then adb shell start ; fi
+ fi
+ done
+ rm -f $OUT/.log
+ return 0
+}
+
+alias mmp='dopush mm'
+alias mmmp='dopush mmm'
+alias mkap='dopush mka'
+alias cmkap='dopush cmka'
+
# Force JAVA_HOME to point to java 1.7 or java 1.6 if it isn't already set.
#
# Note that the MacOS path for java 1.7 includes a minor revision number (sigh).