From: Daniel Bateman Date: Sat, 4 Aug 2012 08:48:09 +0000 (-0500) Subject: envsetup: Add some more commands X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=51f90022924820d967b0f52a5c0547cc3176db8c;p=android-x86%2Fbuild.git envsetup: Add some more commands * mmp: Like mm but pushes the built files afterward. * mmmp: Like mmm but pushes the built files afterward. These may be useful when doing debugging on a individual library, since it builds the library and pushes the new library to the device. Examples: mmmp -B device/samsung/vibrantmtd/libgps mmmp -B packages/apps/Torch Thanks: tpruvot for revisions Change-Id: Ia6bdd2b63797ea86e164af69496b70ea6d7c5156 --- diff --git a/envsetup.sh b/envsetup.sh index b8264a43a..27db3b8ec 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -10,6 +10,8 @@ Invoke ". build/envsetup.sh" from your shell to add the following functions to y To limit the modules being built use the syntax: mmm dir/:target1,target2. - mma: Builds all of the modules in the current directory, and their dependencies. - mmma: Builds all of the modules in the supplied directories, and their dependencies. +- mmp: Builds all of the modules in the current directory and pushes them to the device. +- mmmp: Builds all of the modules in the supplied directories and pushes them to the device. - provision: Flash device with all required partitions. Options will be passed on to fastboot. - cgrep: Greps on all local C/C++ files. - ggrep: Greps on all local Gradle files. @@ -813,6 +815,59 @@ EOF return $? } +# Credit for color strip sed: http://goo.gl/BoIcm +function mmmp() +{ + if [[ $# < 1 || $1 == "--help" || $1 == "-h" ]]; then + echo "mmmp [make arguments] " + return 1 + fi + + # Get product name from cm_ + 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: + 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: + 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