cat <<EOF
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
- lunch: lunch <product_name>-<build_variant>
-- tapas: tapas [<App1> <App2> ...] [arm|x86|mips] [eng|userdebug|user]
+- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5] [eng|userdebug|user]
- croot: Changes directory to the top of the tree.
- m: Makes from the top of the tree.
-- mm: Builds all of the modules in the current directory.
-- mmm: Builds all of the modules in the supplied directories.
+- mm: Builds all of the modules in the current directory, but not their dependencies.
+- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
+- 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.
- cgrep: Greps on all local C/C++ files.
- jgrep: Greps on all local Java files.
- resgrep: Greps on all local res/*.xml files.
}
# add the default one here
-add_lunch_combo full-eng
-add_lunch_combo full_x86-eng
+add_lunch_combo aosp_arm-eng
+add_lunch_combo aosp_x86-eng
+add_lunch_combo aosp_mips-eng
add_lunch_combo vbox_x86-eng
-add_lunch_combo full_mips-eng
function print_lunch_menu()
{
answer=$1
else
print_lunch_menu
- echo -n "Which would you like? [full-eng] "
+ echo -n "Which would you like? [aosp_arm-eng] "
read answer
fi
if [ -z "$answer" ]
then
- selection=full-eng
+ selection=aosp_arm-eng
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
then
if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
# Run tapas with one ore more app names (from LOCAL_PACKAGE_NAME)
function tapas()
{
- local arch=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips)$'))
+ local arch=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5)$'))
local variant=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$'))
- local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips)$'))
+ local apps=$(echo -n $(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5)$'))
if [ $(echo $arch | wc -w) -gt 1 ]; then
echo "tapas: Error: Multiple build archs supplied: $arch"
case $arch in
x86) product=full_x86;;
mips) product=full_mips;;
+ armv5) product=generic_armv5;;
esac
if [ -z "$variant" ]; then
variant=eng
{
T=$(gettop)
if [ "$T" ]; then
- make -C $T $@
+ make -C $T -f build/core/main.mk $@
else
echo "Couldn't locate the top of the tree. Try setting TOP."
fi
# Find the closest Android.mk file.
T=$(gettop)
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
elif [ ! "$M" ]; then
echo "Couldn't locate a makefile from the current directory."
else
- ONE_SHOT_MAKEFILE=$M make -C $T all_modules $@
+ for ARG in $@; do
+ case $ARG in
+ GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
+ esac
+ done
+ if [ -n "$GET_INSTALL_PATH" ]; then
+ MODULES=
+ ARGS=GET-INSTALL-PATH
+ else
+ MODULES=all_modules
+ ARGS=$@
+ fi
+ ONE_SHOT_MAKEFILE=$M make -C $T -f build/core/main.mk $MODULES $ARGS
fi
fi
}
local MODULES=
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=" " '/^[^-].*$/')
for DIR in $DIRS ; do
fi
DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
if [ -f $DIR/Android.mk ]; then
- TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
- TO_CHOP=`expr $TO_CHOP + 1`
- START=`PWD= /bin/pwd`
- MFILE=`echo $START | cut -c${TO_CHOP}-`
+ local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
+ local TO_CHOP=`expr $TO_CHOP + 1`
+ local START=`PWD= /bin/pwd`
+ local MFILE=`echo $START | cut -c${TO_CHOP}-`
if [ "$MFILE" = "" ] ; then
MFILE=$DIR/Android.mk
else
fi
MAKEFILE="$MAKEFILE $MFILE"
else
- if [ "$DIR" = snod ]; then
- ARGS="$ARGS snod"
- elif [ "$DIR" = showcommands ]; then
- ARGS="$ARGS showcommands"
- elif [ "$DIR" = dist ]; then
- ARGS="$ARGS dist"
- elif [ "$DIR" = incrementaljavac ]; then
- ARGS="$ARGS incrementaljavac"
- else
- echo "No Android.mk in $DIR."
- return 1
- fi
+ case $DIR in
+ showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";;
+ GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
+ *) echo "No Android.mk in $DIR."; return 1;;
+ esac
fi
done
- ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T $DASH_ARGS $MODULES $ARGS
+ if [ -n "$GET_INSTALL_PATH" ]; then
+ ARGS=$GET_INSTALL_PATH
+ MODULES=
+ fi
+ ONE_SHOT_MAKEFILE="$MAKEFILE" make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
else
echo "Couldn't locate the top of the tree. Try setting TOP."
fi
}
+function mma()
+{
+ if [ -f build/core/envsetup.mk -a -f Makefile ]; then
+ make $@
+ else
+ T=$(gettop)
+ if [ ! "$T" ]; then
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ fi
+ local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
+ make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD"
+ fi
+}
+
+function mmma()
+{
+ T=$(gettop)
+ if [ "$T" ]; then
+ local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
+ local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
+ local MY_PWD=`PWD= /bin/pwd`
+ if [ "$MY_PWD" = "$T" ]; then
+ MY_PWD=
+ else
+ MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'`
+ fi
+ local DIR=
+ local MODULE_PATHS=
+ local ARGS=
+ for DIR in $DIRS ; do
+ if [ -d $DIR ]; then
+ if [ "$MY_PWD" = "" ]; then
+ MODULE_PATHS="$MODULE_PATHS $DIR"
+ else
+ MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR"
+ fi
+ else
+ case $DIR in
+ showcommands | snod | dist | incrementaljavac) ARGS="$ARGS $DIR";;
+ *) echo "Couldn't find directory $DIR"; return 1;;
+ esac
+ fi
+ done
+ make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS"
+ else
+ echo "Couldn't locate the top of the tree. Try setting TOP."
+ fi
+}
+
function croot()
{
T=$(gettop)
echo "can't find Android.mk"
}
+# simplified version of ps; output in the form
+# <pid> <procname>
+function qpid() {
+ local prepend=''
+ local append=''
+ if [ "$1" = "--exact" ]; then
+ prepend=' '
+ append='$'
+ shift
+ elif [ "$1" = "--help" -o "$1" = "-h" ]; then
+ echo "usage: qpid [[--exact] <process name|pid>"
+ return 255
+ fi
+
+ local EXE="$1"
+ if [ "$EXE" ] ; then
+ qpid | \grep "$prepend$EXE$append"
+ else
+ adb shell ps \
+ | tr -d '\r' \
+ | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
+ fi
+}
+
function pid()
{
- local EXE="$1"
- if [ "$EXE" ] ; then
- local PID=`adb shell ps | fgrep $1 | sed -e 's/[^ ]* *\([0-9]*\).*/\1/'`
- echo "$PID"
- else
- echo "usage: pid name"
- fi
+ local prepend=''
+ local append=''
+ if [ "$1" = "--exact" ]; then
+ prepend=' '
+ append='$'
+ shift
+ fi
+ local EXE="$1"
+ if [ "$EXE" ] ; then
+ local PID=`adb shell ps \
+ | tr -d '\r' \
+ | \grep "$prepend$EXE$append" \
+ | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
+ echo "$PID"
+ else
+ echo "usage: pid [--exact] <process name>"
+ return 255
+ fi
}
# systemstack - dump the current stack trace of all threads in the system process
if [[ $1 =~ ^[0-9]+$ ]] ; then
local PID="$1"
elif [ "$1" ] ; then
- local PID=$(pid $1)
+ local PIDLIST="$(pid $1)"
+ if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
+ local PID="$PIDLIST"
+ elif [ "$PIDLIST" ] ; then
+ echo "more than one process: $1"
+ else
+ echo "no such process: $1"
+ fi
else
echo "usage: stacks [pid|process name]"
fi
if [ "$PID" ] ; then
- local TRACES=/data/anr/traces.txt
- local ORIG=/data/anr/traces.orig
- local TMP=/data/anr/traces.tmp
-
- # Keep original traces to avoid clobbering
- adb shell mv $TRACES $ORIG
-
- # Make sure we have a usable file
- adb shell touch $TRACES
- adb shell chmod 666 $TRACES
-
- # Dump stacks and wait for dump to finish
- adb shell kill -3 $PID
- adb shell notify $TRACES
-
- # Restore original stacks, and show current output
- adb shell mv $TRACES $TMP
- adb shell mv $ORIG $TRACES
- adb shell cat $TMP | less -S
+ # Determine whether the process is native
+ if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
+ # Dump stacks of Dalvik process
+ local TRACES=/data/anr/traces.txt
+ local ORIG=/data/anr/traces.orig
+ local TMP=/data/anr/traces.tmp
+
+ # Keep original traces to avoid clobbering
+ adb shell mv $TRACES $ORIG
+
+ # Make sure we have a usable file
+ adb shell touch $TRACES
+ adb shell chmod 666 $TRACES
+
+ # Dump stacks and wait for dump to finish
+ adb shell kill -3 $PID
+ adb shell notify $TRACES >/dev/null
+
+ # Restore original stacks, and show current output
+ adb shell mv $TRACES $TMP
+ adb shell mv $ORIG $TRACES
+ adb shell cat $TMP
+ else
+ # Dump stacks of native process
+ adb shell debuggerd -b $PID
+ fi
fi
}
PORT=":5039"
fi
- local PID
- local PROG="$3"
- if [ "$PROG" ] ; then
- if [[ "$PROG" =~ ^[0-9]+$ ]] ; then
- PID="$3"
- else
+ local PID="$3"
+ if [ "$PID" ] ; then
+ if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
PID=`pid $3`
+ if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then
+ # that likely didn't work because of returning multiple processes
+ # try again, filtering by root processes (don't contain colon)
+ PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'`
+ if [[ ! "$PID" =~ ^[0-9]+$ ]]
+ then
+ echo "Couldn't resolve '$3' to single PID"
+ return 1
+ else
+ echo ""
+ echo "WARNING: multiple processes matching '$3' observed, using root process"
+ echo ""
+ fi
+ fi
fi
adb forward "tcp$PORT" "tcp$PORT"
adb shell gdbserver $PORT --attach $PID &
echo "If you haven't done so already, do this first on the device:"
echo " gdbserver $PORT /system/bin/$EXE"
echo " or"
- echo " gdbserver $PORT --attach $PID"
+ echo " gdbserver $PORT --attach <PID>"
echo ""
fi
echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS"
echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx"
+ echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb"
echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT"
echo >>"$OUT_ROOT/gdbclient.cmds" ""
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
}
+function sepgrep()
+{
+ find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@"
+}
+
case `uname -s` in
Darwin)
function mgrep()
fi
# issue "am" command to cause the hprof dump
- local sdcard=$(adb shell echo -n '$EXTERNAL_STORAGE')
+ local sdcard=$(adb ${adbOptions} shell echo -n '$EXTERNAL_STORAGE')
local devFile=$sdcard/hprof-$targetPid
#local devFile=/data/local/hprof-$targetPid
echo "Poking $targetPid and waiting for data..."
fi
}
+# Print colored exit condition
+function pez {
+ "$@"
+ local retval=$?
+ if [ $retval -ne 0 ]
+ then
+ echo -e "\e[0;31mFAILURE\e[00m"
+ else
+ echo -e "\e[0;32mSUCCESS\e[00m"
+ fi
+ return $retval
+}
+
if [ "x$SHELL" != "x/bin/bash" ]; then
case `ps -o command -p $$` in
*bash*)
fi
# Execute the contents of any vendorsetup.sh files we can find.
-for f in `/bin/ls vendor/*/vendorsetup.sh vendor/*/*/vendorsetup.sh device/*/*/vendorsetup.sh 2> /dev/null`
+for f in `test -d device && find device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
+ `test -d vendor && find vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
do
echo "including $f"
. $f