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.
+- mmap: Builds all of the modules in the current directory, and its dependencies, then pushes the package to the device.
- 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.
+- mms: Short circuit builder. Quickly re-build the kernel, rootfs, boot and system images
+ without deep dependencies. Requires the full build to have run before.
- 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.
return 1
fi
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
+ if [ $(adb get-state) != device -a $(adb shell 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
+ until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do
sleep 1
done
echo "Device Found.."
sleep 1
adb wait-for-device
cat << EOF > /tmp/command
---sideload
+--sideload_auto_reboot
EOF
if adb push /tmp/command /cache/recovery/ ; then
echo "Rebooting into recovery for sideload installation"
local M=$(findmakefile)
local MODULES=
local GET_INSTALL_PATH=
- local ARGS=
# Remove the path to top as the makefilepath needs to be relative
local M=`echo $M|sed 's:'$T'/::'`
if [ ! "$T" ]; then
done
if [ -n "$GET_INSTALL_PATH" ]; then
MODULES=
- ARGS=GET-INSTALL-PATH
+ # set all args to 'GET-INSTALL-PATH'
+ set -- GET-INSTALL-PATH
else
MODULES=all_modules
- ARGS=$@
fi
- ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
+ ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES "$@"
fi
fi
}
local ARGS=
local DIR TO_CHOP
local GET_INSTALL_PATH=
- local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
- local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+
+ if [ "$(__detect_shell)" = "zsh" ]; then
+ set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ else
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ fi
+
for DIR in $DIRS ; do
MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
if [ "$MODULES" = "" ]; then
local T=$(gettop)
local DRV=$(getdriver $T)
if [ "$T" ]; then
- local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
- local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ if [ "$(__detect_shell)" = "zsh" ]; then
+ set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ else
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ fi
local MY_PWD=`PWD= /bin/pwd`
if [ "$MY_PWD" = "$T" ]; then
MY_PWD=
function cmremote()
{
- git remote rm cmremote 2> /dev/null
- GERRIT_REMOTE=$(git config --get remote.github.projectname)
- if [ -z "$GERRIT_REMOTE" ]
+ if ! git rev-parse --git-dir &> /dev/null
then
- echo Unable to set up the git remote, are you under a git repo?
- return 0
+ echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+ return 1
fi
+ git remote rm cmremote 2> /dev/null
+ GERRIT_REMOTE=$(git config --get remote.github.projectname)
CMUSER=$(git config --get review.review.cyanogenmod.org.username)
if [ -z "$CMUSER" ]
then
else
git remote add cmremote ssh://$CMUSER@review.cyanogenmod.org:29418/$GERRIT_REMOTE
fi
- echo You can now push to "cmremote".
+ echo "Remote 'cmremote' created"
}
function aospremote()
{
- git remote rm aosp 2> /dev/null
- if [ ! -d .git ]
+ if ! git rev-parse --git-dir &> /dev/null
then
- echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
+ echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+ return 1
fi
- PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g`
+ git remote rm aosp 2> /dev/null
+ PROJECT=$(pwd -P | sed "s#$ANDROID_BUILD_TOP\/##")
if (echo $PROJECT | grep -qv "^device")
then
PFX="platform/"
function cafremote()
{
- git remote rm caf 2> /dev/null
- if [ ! -d .git ]
+ if ! git rev-parse --git-dir &> /dev/null
then
- echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
+ echo ".git directory not found. Please run this from the root directory of the Android repository you wish to set up."
+ return 1
fi
- PROJECT=`pwd -P | sed s#$ANDROID_BUILD_TOP/##g`
+ git remote rm caf 2> /dev/null
+ PROJECT=$(pwd -P | sed "s#$ANDROID_BUILD_TOP\/##")
if (echo $PROJECT | grep -qv "^device")
then
PFX="platform/"
repo forall -c '
- if [ "$REPO_REMOTE" == "github" ]
+ if [ "$REPO_REMOTE" = "github" ]
then
pwd
cmremote
}
function cmgerrit() {
+
+ if [ "$(__detect_shell)" = "zsh" ]; then
+ # zsh does not define FUNCNAME, derive from funcstack
+ local FUNCNAME=$funcstack[1]
+ fi
+
if [ $# -eq 0 ]; then
$FUNCNAME help
return 1
fi
}
+function mms() {
+ local T=$(gettop)
+ if [ -z "$T" ]
+ then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ return 1
+ fi
+
+ case `uname -s` in
+ Darwin)
+ local NUM_CPUS=$(sysctl hw.ncpu|cut -d" " -f2)
+ ONE_SHOT_MAKEFILE="__none__" \
+ make -C $T -j $NUM_CPUS "$@"
+ ;;
+ *)
+ local NUM_CPUS=$(cat /proc/cpuinfo | grep "^processor" | wc -l)
+ ONE_SHOT_MAKEFILE="__none__" \
+ mk_timer schedtool -B -n 1 -e ionice -n 1 \
+ make -C $T -j $NUM_CPUS "$@"
+ ;;
+ esac
+}
+
+
function repolastsync() {
RLSPATH="$ANDROID_BUILD_TOP/.repo/.repo_fetchtimes.json"
RLSLOCAL=$(date -d "$(stat -c %z $RLSPATH)" +"%e %b %Y, %T %Z")
'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;'
}
+# Return success if adb is up and not in recovery
+function _adb_connected {
+ {
+ if [[ "$(adb get-state)" == device &&
+ "$(adb shell test -e /sbin/recovery; echo $?)" == 0 ]]
+ then
+ return 0
+ fi
+ } 2>/dev/null
+
+ return 1
+};
+
# Credit for color strip sed: http://goo.gl/BoIcm
function dopush()
{
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
+ if ! _adb_connected; 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
+ until _adb_connected; do
sleep 1
done
echo "Device Found."
fi
- if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" == "true" ];
+ if (adb shell getprop ro.cm.device | grep -q "$CM_BUILD") || [ "$FORCE_PUSH" = "true" ];
then
# retrieve IP and PORT info if we're using a TCP connection
TCPIPPORT=$(adb devices | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \
fi
# 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)"
+ if [ `uname` = "Linux" ]; then
+ 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)"
+ else
+ LOC="$(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Install: ' | cut -d ':' -f 2)"
+ fi
# 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)"
+ if [ `uname` = "Linux" ]; then
+ 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)"
+ else
+ LOC="$LOC $(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Copy: ' | cut -d ':' -f 2)"
+ fi
# If any files are going to /data, push an octal file permissions reader to device
if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then
alias mmp='dopush mm'
alias mmmp='dopush mmm'
+alias mmap='dopush mma'
alias mkap='dopush mka'
alias cmkap='dopush cmka'
mk_timer $(get_make_command) "$@"
}
-if [ "x$SHELL" != "x/bin/bash" ]; then
+function __detect_shell() {
case `ps -o command -p $$` in
*bash*)
+ echo bash
;;
*zsh*)
+ echo zsh
;;
*)
- echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results"
+ echo unknown
+ return 1
;;
esac
+ return
+}
+
+
+if ! __detect_shell > /dev/null; then
+ echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results"
fi
# Execute the contents of any vendorsetup.sh files we can find.