2015-02-13 03:14:39 +08:00
|
|
|
# These unsets should stay to clear the old functions from any long running
|
|
|
|
# shells.
|
|
|
|
# TODO(danalbert): Remove this in a day or so.
|
|
|
|
unset -f gdbwrapper
|
|
|
|
unset -f get_symbols_directory
|
|
|
|
unset -f adb_get_product_device
|
|
|
|
unset -f adb_get_traced_by
|
|
|
|
unset -f gdbclient
|
|
|
|
unset -f gdbclient_old
|
|
|
|
|
2012-03-08 09:15:06 +08:00
|
|
|
function hmm() {
|
2008-10-21 22:00:00 +08:00
|
|
|
cat <<EOF
|
2008-12-18 10:03:49 +08:00
|
|
|
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
|
2012-08-23 01:25:20 +08:00
|
|
|
- lunch: lunch <product_name>-<build_variant>
|
2014-05-30 08:57:40 +08:00
|
|
|
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
|
2008-10-21 22:00:00 +08:00
|
|
|
- croot: Changes directory to the top of the tree.
|
|
|
|
- m: Makes from the top of the tree.
|
2013-02-09 10:01:04 +08:00
|
|
|
- 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.
|
2014-02-26 19:09:19 +08:00
|
|
|
To limit the modules being built use the syntax: mmm dir/:target1,target2.
|
2013-02-09 10:01:04 +08:00
|
|
|
- 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.
|
2008-10-21 22:00:00 +08:00
|
|
|
- cgrep: Greps on all local C/C++ files.
|
2014-04-08 01:57:38 +08:00
|
|
|
- ggrep: Greps on all local Gradle files.
|
2008-10-21 22:00:00 +08:00
|
|
|
- jgrep: Greps on all local Java files.
|
|
|
|
- resgrep: Greps on all local res/*.xml files.
|
2015-01-30 12:42:21 +08:00
|
|
|
- mangrep: Greps on all local AndroidManifest.xml files.
|
|
|
|
- sepgrep: Greps on all local sepolicy files.
|
2014-07-27 06:15:41 +08:00
|
|
|
- sgrep: Greps on all local source files.
|
2009-03-04 11:28:42 +08:00
|
|
|
- godir: Go to the directory containing a file.
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2014-11-01 07:23:08 +08:00
|
|
|
Environemnt options:
|
|
|
|
- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
|
|
|
|
ASAN_OPTIONS=detect_leaks=0 will be set by default until the
|
|
|
|
build is leak-check clean.
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
Look at the source to view more functions. The complete list is:
|
|
|
|
EOF
|
|
|
|
T=$(gettop)
|
|
|
|
local A
|
|
|
|
A=""
|
2014-07-27 06:15:41 +08:00
|
|
|
for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
|
2008-10-21 22:00:00 +08:00
|
|
|
A="$A $i"
|
|
|
|
done
|
|
|
|
echo $A
|
|
|
|
}
|
|
|
|
|
|
|
|
# Get the value of a build variable as an absolute path.
|
|
|
|
function get_abs_build_var()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2012-12-14 02:52:07 +08:00
|
|
|
(\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
|
2014-06-28 04:32:39 +08:00
|
|
|
command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1)
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the exact value of a build variable.
|
|
|
|
function get_build_var()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2013-12-20 05:21:46 +08:00
|
|
|
(\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
|
2014-06-28 04:32:39 +08:00
|
|
|
command make --no-print-directory -f build/core/config.mk dumpvar-$1)
|
2008-12-18 10:03:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# check to see if the supplied product is one we can build
|
|
|
|
function check_product()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2011-07-12 13:11:46 +08:00
|
|
|
TARGET_PRODUCT=$1 \
|
|
|
|
TARGET_BUILD_VARIANT= \
|
|
|
|
TARGET_BUILD_TYPE= \
|
2010-06-10 09:18:31 +08:00
|
|
|
TARGET_BUILD_APPS= \
|
2008-12-18 10:03:49 +08:00
|
|
|
get_build_var TARGET_DEVICE > /dev/null
|
|
|
|
# hide successful answers, but allow the errors to show
|
|
|
|
}
|
|
|
|
|
|
|
|
VARIANT_CHOICES=(user userdebug eng)
|
|
|
|
|
|
|
|
# check to see if the supplied variant is valid
|
|
|
|
function check_variant()
|
|
|
|
{
|
|
|
|
for v in ${VARIANT_CHOICES[@]}
|
|
|
|
do
|
|
|
|
if [ "$v" = "$1" ]
|
|
|
|
then
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function setpaths()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
##################################################################
|
|
|
|
# #
|
|
|
|
# Read me before you modify this code #
|
|
|
|
# #
|
|
|
|
# This function sets ANDROID_BUILD_PATHS to what it is adding #
|
|
|
|
# to PATH, and the next time it is run, it removes that from #
|
|
|
|
# PATH. This is required so lunch can be run more than once #
|
|
|
|
# and still have working paths. #
|
|
|
|
# #
|
|
|
|
##################################################################
|
|
|
|
|
2011-06-21 08:25:01 +08:00
|
|
|
# Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
|
|
|
|
# due to "C:\Program Files" being in the path.
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
# out with the old
|
2011-06-21 08:25:01 +08:00
|
|
|
if [ -n "$ANDROID_BUILD_PATHS" ] ; then
|
2008-10-21 22:00:00 +08:00
|
|
|
export PATH=${PATH/$ANDROID_BUILD_PATHS/}
|
|
|
|
fi
|
2011-06-21 08:25:01 +08:00
|
|
|
if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
|
2011-04-22 23:16:56 +08:00
|
|
|
export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
|
2012-11-27 12:51:59 +08:00
|
|
|
# strip leading ':', if any
|
|
|
|
export PATH=${PATH/:%/}
|
2010-06-22 07:26:38 +08:00
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
|
|
|
# and in with the new
|
|
|
|
prebuiltdir=$(getprebuilt)
|
2012-03-30 11:45:50 +08:00
|
|
|
gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
|
2011-06-23 05:35:32 +08:00
|
|
|
|
2012-11-17 05:29:13 +08:00
|
|
|
# defined in core/config.mk
|
|
|
|
targetgccversion=$(get_build_var TARGET_GCC_VERSION)
|
2014-05-23 02:57:43 +08:00
|
|
|
targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
|
2012-12-11 08:04:39 +08:00
|
|
|
export TARGET_GCC_VERSION=$targetgccversion
|
2012-11-17 05:29:13 +08:00
|
|
|
|
2011-06-21 08:25:01 +08:00
|
|
|
# The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
|
2014-02-26 02:27:07 +08:00
|
|
|
export ANDROID_TOOLCHAIN=
|
|
|
|
export ANDROID_TOOLCHAIN_2ND_ARCH=
|
2012-04-17 20:50:47 +08:00
|
|
|
local ARCH=$(get_build_var TARGET_ARCH)
|
|
|
|
case $ARCH in
|
2013-08-23 20:49:21 +08:00
|
|
|
x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
|
2012-03-15 05:20:30 +08:00
|
|
|
;;
|
2012-11-26 13:50:07 +08:00
|
|
|
x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
|
|
|
|
;;
|
2012-11-17 05:29:13 +08:00
|
|
|
arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
|
2012-04-17 20:50:47 +08:00
|
|
|
;;
|
2014-02-26 02:27:07 +08:00
|
|
|
arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;
|
2014-05-23 02:57:43 +08:00
|
|
|
toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin
|
2013-10-05 07:02:59 +08:00
|
|
|
;;
|
2014-07-23 05:34:00 +08:00
|
|
|
mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin
|
2014-01-14 18:33:53 +08:00
|
|
|
;;
|
2012-04-17 20:50:47 +08:00
|
|
|
*)
|
|
|
|
echo "Can't find toolchain for unknown architecture: $ARCH"
|
|
|
|
toolchaindir=xxxxxxxxx
|
2012-03-15 05:20:30 +08:00
|
|
|
;;
|
|
|
|
esac
|
2012-03-30 11:45:50 +08:00
|
|
|
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
|
2014-02-26 02:27:07 +08:00
|
|
|
export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
|
2011-06-21 08:25:01 +08:00
|
|
|
fi
|
2011-06-23 05:35:32 +08:00
|
|
|
|
2014-02-26 02:27:07 +08:00
|
|
|
if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then
|
|
|
|
export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
|
|
|
|
fi
|
|
|
|
|
|
|
|
unset ANDROID_KERNEL_TOOLCHAIN_PATH
|
2012-04-18 09:10:11 +08:00
|
|
|
case $ARCH in
|
2012-07-18 12:40:01 +08:00
|
|
|
arm)
|
2014-02-26 02:27:07 +08:00
|
|
|
# Legacy toolchain configuration used for ARM kernel compilation
|
2012-11-17 05:29:13 +08:00
|
|
|
toolchaindir=arm/arm-eabi-$targetgccversion/bin
|
2012-07-18 12:40:01 +08:00
|
|
|
if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
|
2014-04-25 23:24:22 +08:00
|
|
|
export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
|
|
|
|
ANDROID_KERNEL_TOOLCHAIN_PATH="$ARM_EABI_TOOLCHAIN":
|
2012-07-18 12:40:01 +08:00
|
|
|
fi
|
2012-04-18 09:10:11 +08:00
|
|
|
;;
|
|
|
|
*)
|
2012-07-18 12:40:01 +08:00
|
|
|
# No need to set ARM_EABI_TOOLCHAIN for other ARCHs
|
2012-04-18 09:10:11 +08:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2013-03-30 08:40:14 +08:00
|
|
|
export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools
|
2014-07-01 01:25:33 +08:00
|
|
|
export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN:$ANDROID_TOOLCHAIN_2ND_ARCH:$ANDROID_KERNEL_TOOLCHAIN_PATH$ANDROID_DEV_SCRIPTS:
|
2014-05-05 22:13:50 +08:00
|
|
|
|
|
|
|
# If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH
|
|
|
|
# to ensure that the corresponding 'emulator' binaries are used.
|
|
|
|
case $(uname -s) in
|
|
|
|
Darwin)
|
|
|
|
ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
|
|
|
|
;;
|
|
|
|
Linux)
|
|
|
|
ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
ANDROID_EMULATOR_PREBUILTS=
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
|
2014-05-21 04:56:00 +08:00
|
|
|
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS:
|
2014-05-05 22:13:50 +08:00
|
|
|
export ANDROID_EMULATOR_PREBUILTS
|
|
|
|
fi
|
|
|
|
|
2012-11-27 12:51:59 +08:00
|
|
|
export PATH=$ANDROID_BUILD_PATHS$PATH
|
2008-12-18 10:03:49 +08:00
|
|
|
|
2010-06-22 07:26:38 +08:00
|
|
|
unset ANDROID_JAVA_TOOLCHAIN
|
2011-07-04 13:09:47 +08:00
|
|
|
unset ANDROID_PRE_BUILD_PATHS
|
2010-06-22 07:26:38 +08:00
|
|
|
if [ -n "$JAVA_HOME" ]; then
|
|
|
|
export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
|
2011-07-04 13:09:47 +08:00
|
|
|
export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
|
|
|
|
export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
|
2010-06-22 07:26:38 +08:00
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
unset ANDROID_PRODUCT_OUT
|
2008-10-21 22:00:00 +08:00
|
|
|
export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
|
|
|
|
export OUT=$ANDROID_PRODUCT_OUT
|
|
|
|
|
2011-03-25 08:03:06 +08:00
|
|
|
unset ANDROID_HOST_OUT
|
|
|
|
export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
# needed for building linux on MacOS
|
2008-10-21 22:00:00 +08:00
|
|
|
# TODO: fix the path
|
|
|
|
#export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
|
|
|
|
}
|
|
|
|
|
|
|
|
function printconfig()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
get_build_var report_config
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_stuff_for_environment()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
settitle
|
2010-06-22 07:26:38 +08:00
|
|
|
set_java_home
|
2008-12-18 10:03:49 +08:00
|
|
|
setpaths
|
|
|
|
set_sequence_number
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
export ANDROID_BUILD_TOP=$(gettop)
|
2013-08-14 05:38:15 +08:00
|
|
|
# With this environment variable new GCC can apply colors to warnings/errors
|
|
|
|
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
2014-11-01 07:23:08 +08:00
|
|
|
export ASAN_OPTIONS=detect_leaks=0
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function set_sequence_number()
|
|
|
|
{
|
2010-06-24 05:03:13 +08:00
|
|
|
export BUILD_ENV_SEQUENCE_NUMBER=10
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function settitle()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
if [ "$STAY_OFF_MY_LAWN" = "" ]; then
|
2012-07-26 10:57:22 +08:00
|
|
|
local arch=$(gettargetarch)
|
2010-06-10 09:18:31 +08:00
|
|
|
local product=$TARGET_PRODUCT
|
|
|
|
local variant=$TARGET_BUILD_VARIANT
|
|
|
|
local apps=$TARGET_BUILD_APPS
|
|
|
|
if [ -z "$apps" ]; then
|
2012-07-26 10:57:22 +08:00
|
|
|
export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
|
2010-06-10 09:18:31 +08:00
|
|
|
else
|
2012-07-26 10:57:22 +08:00
|
|
|
export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
|
2010-06-10 09:18:31 +08:00
|
|
|
fi
|
2008-12-18 10:03:49 +08:00
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2011-07-16 02:07:06 +08:00
|
|
|
function addcompletions()
|
|
|
|
{
|
|
|
|
local T dir f
|
|
|
|
|
|
|
|
# Keep us from trying to run in something that isn't bash.
|
|
|
|
if [ -z "${BASH_VERSION}" ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Keep us from trying to run in bash that's too old.
|
|
|
|
if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
dir="sdk/bash_completion"
|
|
|
|
if [ -d ${dir} ]; then
|
2011-07-19 04:11:34 +08:00
|
|
|
for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
|
2011-07-16 02:07:06 +08:00
|
|
|
echo "including $f"
|
|
|
|
. $f
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function choosetype()
|
|
|
|
{
|
|
|
|
echo "Build type choices are:"
|
|
|
|
echo " 1. release"
|
|
|
|
echo " 2. debug"
|
|
|
|
echo
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
local DEFAULT_NUM DEFAULT_VALUE
|
2011-07-12 13:11:46 +08:00
|
|
|
DEFAULT_NUM=1
|
|
|
|
DEFAULT_VALUE=release
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
export TARGET_BUILD_TYPE=
|
|
|
|
local ANSWER
|
2008-10-21 22:00:00 +08:00
|
|
|
while [ -z $TARGET_BUILD_TYPE ]
|
|
|
|
do
|
|
|
|
echo -n "Which would you like? ["$DEFAULT_NUM"] "
|
2008-12-18 10:03:49 +08:00
|
|
|
if [ -z "$1" ] ; then
|
|
|
|
read ANSWER
|
|
|
|
else
|
|
|
|
echo $1
|
|
|
|
ANSWER=$1
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
case $ANSWER in
|
|
|
|
"")
|
|
|
|
export TARGET_BUILD_TYPE=$DEFAULT_VALUE
|
|
|
|
;;
|
|
|
|
1)
|
|
|
|
export TARGET_BUILD_TYPE=release
|
|
|
|
;;
|
2008-12-18 10:03:49 +08:00
|
|
|
release)
|
|
|
|
export TARGET_BUILD_TYPE=release
|
|
|
|
;;
|
2008-10-21 22:00:00 +08:00
|
|
|
2)
|
|
|
|
export TARGET_BUILD_TYPE=debug
|
|
|
|
;;
|
2008-12-18 10:03:49 +08:00
|
|
|
debug)
|
|
|
|
export TARGET_BUILD_TYPE=debug
|
|
|
|
;;
|
2008-10-21 22:00:00 +08:00
|
|
|
*)
|
|
|
|
echo
|
|
|
|
echo "I didn't understand your response. Please try again."
|
|
|
|
echo
|
|
|
|
;;
|
|
|
|
esac
|
2008-12-18 10:03:49 +08:00
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
done
|
|
|
|
|
|
|
|
set_stuff_for_environment
|
|
|
|
}
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
#
|
|
|
|
# This function isn't really right: It chooses a TARGET_PRODUCT
|
|
|
|
# based on the list of boards. Usually, that gets you something
|
|
|
|
# that kinda works with a generic product, but really, you should
|
|
|
|
# pick a product by name.
|
|
|
|
#
|
2008-10-21 22:00:00 +08:00
|
|
|
function chooseproduct()
|
|
|
|
{
|
|
|
|
if [ "x$TARGET_PRODUCT" != x ] ; then
|
|
|
|
default_value=$TARGET_PRODUCT
|
|
|
|
else
|
2011-07-12 13:11:46 +08:00
|
|
|
default_value=full
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
export TARGET_PRODUCT=
|
|
|
|
local ANSWER
|
2008-10-21 22:00:00 +08:00
|
|
|
while [ -z "$TARGET_PRODUCT" ]
|
|
|
|
do
|
2009-04-30 06:56:47 +08:00
|
|
|
echo -n "Which product would you like? [$default_value] "
|
2008-12-18 10:03:49 +08:00
|
|
|
if [ -z "$1" ] ; then
|
|
|
|
read ANSWER
|
|
|
|
else
|
|
|
|
echo $1
|
|
|
|
ANSWER=$1
|
|
|
|
fi
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ -z "$ANSWER" ] ; then
|
|
|
|
export TARGET_PRODUCT=$default_value
|
2008-12-18 10:03:49 +08:00
|
|
|
else
|
|
|
|
if check_product $ANSWER
|
|
|
|
then
|
|
|
|
export TARGET_PRODUCT=$ANSWER
|
|
|
|
else
|
|
|
|
echo "** Not a valid product: $ANSWER"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
break
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
set_stuff_for_environment
|
|
|
|
}
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
function choosevariant()
|
|
|
|
{
|
|
|
|
echo "Variant choices are:"
|
|
|
|
local index=1
|
|
|
|
local v
|
|
|
|
for v in ${VARIANT_CHOICES[@]}
|
|
|
|
do
|
|
|
|
# The product name is the name of the directory containing
|
|
|
|
# the makefile we found, above.
|
|
|
|
echo " $index. $v"
|
|
|
|
index=$(($index+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
local default_value=eng
|
|
|
|
local ANSWER
|
|
|
|
|
|
|
|
export TARGET_BUILD_VARIANT=
|
|
|
|
while [ -z "$TARGET_BUILD_VARIANT" ]
|
|
|
|
do
|
|
|
|
echo -n "Which would you like? [$default_value] "
|
|
|
|
if [ -z "$1" ] ; then
|
|
|
|
read ANSWER
|
|
|
|
else
|
|
|
|
echo $1
|
|
|
|
ANSWER=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$ANSWER" ] ; then
|
|
|
|
export TARGET_BUILD_VARIANT=$default_value
|
|
|
|
elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
|
|
|
|
if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
|
2010-07-05 15:53:47 +08:00
|
|
|
export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
|
2008-12-18 10:03:49 +08:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
if check_variant $ANSWER
|
|
|
|
then
|
|
|
|
export TARGET_BUILD_VARIANT=$ANSWER
|
|
|
|
else
|
|
|
|
echo "** Not a valid variant: $ANSWER"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -n "$1" ] ; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function choosecombo()
|
|
|
|
{
|
2011-07-12 13:11:46 +08:00
|
|
|
choosetype $1
|
2008-10-21 22:00:00 +08:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
2011-07-12 13:11:46 +08:00
|
|
|
chooseproduct $2
|
2008-10-21 22:00:00 +08:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
2011-07-12 13:11:46 +08:00
|
|
|
choosevariant $3
|
2008-12-18 10:03:49 +08:00
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
echo
|
|
|
|
set_stuff_for_environment
|
2008-12-18 10:03:49 +08:00
|
|
|
printconfig
|
|
|
|
}
|
|
|
|
|
|
|
|
# Clear this variable. It will be built up again when the vendorsetup.sh
|
|
|
|
# files are included at the end of this file.
|
|
|
|
unset LUNCH_MENU_CHOICES
|
|
|
|
function add_lunch_combo()
|
|
|
|
{
|
|
|
|
local new_combo=$1
|
|
|
|
local c
|
|
|
|
for c in ${LUNCH_MENU_CHOICES[@]} ; do
|
|
|
|
if [ "$new_combo" = "$c" ] ; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
# add the default one here
|
2013-03-23 06:53:54 +08:00
|
|
|
add_lunch_combo aosp_arm-eng
|
2014-01-14 18:33:53 +08:00
|
|
|
add_lunch_combo aosp_arm64-eng
|
2013-03-23 06:53:54 +08:00
|
|
|
add_lunch_combo aosp_mips-eng
|
2014-02-04 07:01:24 +08:00
|
|
|
add_lunch_combo aosp_mips64-eng
|
2014-01-14 18:33:53 +08:00
|
|
|
add_lunch_combo aosp_x86-eng
|
2012-11-26 13:50:07 +08:00
|
|
|
add_lunch_combo aosp_x86_64-eng
|
2008-12-18 10:03:49 +08:00
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function print_lunch_menu()
|
|
|
|
{
|
|
|
|
local uname=$(uname)
|
|
|
|
echo
|
|
|
|
echo "You're building on" $uname
|
|
|
|
echo
|
|
|
|
echo "Lunch menu... pick a combo:"
|
2008-12-18 10:03:49 +08:00
|
|
|
|
|
|
|
local i=1
|
|
|
|
local choice
|
|
|
|
for choice in ${LUNCH_MENU_CHOICES[@]}
|
|
|
|
do
|
|
|
|
echo " $i. $choice"
|
|
|
|
i=$(($i+1))
|
|
|
|
done
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
function lunch()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
local answer
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$1" ] ; then
|
2008-12-18 10:03:49 +08:00
|
|
|
answer=$1
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
print_lunch_menu
|
2013-03-23 06:53:54 +08:00
|
|
|
echo -n "Which would you like? [aosp_arm-eng] "
|
2008-12-18 10:03:49 +08:00
|
|
|
read answer
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
local selection=
|
|
|
|
|
|
|
|
if [ -z "$answer" ]
|
|
|
|
then
|
2013-03-23 06:53:54 +08:00
|
|
|
selection=aosp_arm-eng
|
2008-12-18 10:03:49 +08:00
|
|
|
elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
|
|
|
|
then
|
|
|
|
if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
|
|
|
|
then
|
2010-07-05 15:53:47 +08:00
|
|
|
selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
|
2008-12-18 10:03:49 +08:00
|
|
|
fi
|
|
|
|
elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
|
2008-10-21 22:00:00 +08:00
|
|
|
then
|
2008-12-18 10:03:49 +08:00
|
|
|
selection=$answer
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
if [ -z "$selection" ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "Invalid lunch combo: $answer"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2010-06-10 09:18:31 +08:00
|
|
|
export TARGET_BUILD_APPS=
|
|
|
|
|
2011-07-12 13:11:46 +08:00
|
|
|
local product=$(echo -n $selection | sed -e "s/-.*$//")
|
|
|
|
check_product $product
|
|
|
|
if [ $? -ne 0 ]
|
2008-12-18 10:03:49 +08:00
|
|
|
then
|
2011-07-12 13:11:46 +08:00
|
|
|
echo
|
|
|
|
echo "** Don't have a product spec for: '$product'"
|
|
|
|
echo "** Do you have the right repo manifest?"
|
|
|
|
product=
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2011-07-12 13:11:46 +08:00
|
|
|
local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
|
|
|
|
check_variant $variant
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
echo "** Invalid variant: '$variant'"
|
|
|
|
echo "** Must be one of ${VARIANT_CHOICES[@]}"
|
|
|
|
variant=
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2011-07-12 13:11:46 +08:00
|
|
|
if [ -z "$product" -o -z "$variant" ]
|
|
|
|
then
|
|
|
|
echo
|
|
|
|
return 1
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2011-07-12 13:11:46 +08:00
|
|
|
export TARGET_PRODUCT=$product
|
|
|
|
export TARGET_BUILD_VARIANT=$variant
|
|
|
|
export TARGET_BUILD_TYPE=release
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
echo
|
|
|
|
|
|
|
|
set_stuff_for_environment
|
|
|
|
printconfig
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2010-08-03 01:00:44 +08:00
|
|
|
# Tab completion for lunch.
|
|
|
|
function _lunch()
|
|
|
|
{
|
|
|
|
local cur prev opts
|
|
|
|
COMPREPLY=()
|
|
|
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
|
|
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
|
|
|
|
|
|
|
COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
complete -F _lunch lunch
|
|
|
|
|
2010-06-10 09:18:31 +08:00
|
|
|
# Configures the build to build unbundled apps.
|
2014-04-17 02:34:34 +08:00
|
|
|
# Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
|
2010-06-10 09:18:31 +08:00
|
|
|
function tapas()
|
|
|
|
{
|
2014-05-30 08:57:40 +08:00
|
|
|
local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)"
|
2014-04-17 02:34:34 +08:00
|
|
|
local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
|
2014-05-30 08:57:40 +08:00
|
|
|
local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)"
|
2010-06-10 09:18:31 +08:00
|
|
|
|
2012-08-23 01:25:20 +08:00
|
|
|
if [ $(echo $arch | wc -w) -gt 1 ]; then
|
|
|
|
echo "tapas: Error: Multiple build archs supplied: $arch"
|
|
|
|
return
|
|
|
|
fi
|
2010-06-10 09:18:31 +08:00
|
|
|
if [ $(echo $variant | wc -w) -gt 1 ]; then
|
|
|
|
echo "tapas: Error: Multiple build variants supplied: $variant"
|
|
|
|
return
|
|
|
|
fi
|
2012-08-23 01:25:20 +08:00
|
|
|
|
|
|
|
local product=full
|
|
|
|
case $arch in
|
2014-05-30 08:57:40 +08:00
|
|
|
x86) product=full_x86;;
|
|
|
|
mips) product=full_mips;;
|
|
|
|
armv5) product=generic_armv5;;
|
|
|
|
arm64) product=aosp_arm64;;
|
|
|
|
x86_64) product=aosp_x86_64;;
|
|
|
|
mips64) product=aosp_mips64;;
|
2012-08-23 01:25:20 +08:00
|
|
|
esac
|
2010-06-10 09:18:31 +08:00
|
|
|
if [ -z "$variant" ]; then
|
|
|
|
variant=eng
|
|
|
|
fi
|
2010-06-25 06:08:33 +08:00
|
|
|
if [ -z "$apps" ]; then
|
|
|
|
apps=all
|
|
|
|
fi
|
2010-06-10 09:18:31 +08:00
|
|
|
|
2012-08-23 01:25:20 +08:00
|
|
|
export TARGET_PRODUCT=$product
|
2010-06-10 09:18:31 +08:00
|
|
|
export TARGET_BUILD_VARIANT=$variant
|
|
|
|
export TARGET_BUILD_TYPE=release
|
|
|
|
export TARGET_BUILD_APPS=$apps
|
|
|
|
|
|
|
|
set_stuff_for_environment
|
|
|
|
printconfig
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function gettop
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
local TOPFILE=build/core/envsetup.mk
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
|
2014-09-12 15:33:25 +08:00
|
|
|
# The following circumlocution ensures we remove symlinks from TOP.
|
|
|
|
(cd $TOP; PWD= /bin/pwd)
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
if [ -f $TOPFILE ] ; then
|
2009-11-25 07:48:50 +08:00
|
|
|
# The following circumlocution (repeated below as well) ensures
|
|
|
|
# that we record the true directory name and not one that is
|
|
|
|
# faked up with symlink names.
|
|
|
|
PWD= /bin/pwd
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
2008-12-18 10:03:49 +08:00
|
|
|
local HERE=$PWD
|
2008-10-21 22:00:00 +08:00
|
|
|
T=
|
|
|
|
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd ..
|
2013-07-06 10:47:47 +08:00
|
|
|
T=`PWD= /bin/pwd -P`
|
2008-10-21 22:00:00 +08:00
|
|
|
done
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $HERE
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ -f "$T/$TOPFILE" ]; then
|
|
|
|
echo $T
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-09-10 17:37:14 +08:00
|
|
|
# Return driver for "make", if any (eg. static analyzer)
|
|
|
|
function getdriver()
|
|
|
|
{
|
|
|
|
local T="$1"
|
|
|
|
test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
|
|
|
|
if [ -n "$WITH_STATIC_ANALYZER" ]; then
|
|
|
|
echo "\
|
2014-03-03 16:53:17 +08:00
|
|
|
$T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \
|
|
|
|
--use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \
|
2013-09-10 17:37:14 +08:00
|
|
|
--status-bugs \
|
|
|
|
--top=$T"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function m()
|
|
|
|
{
|
2013-09-10 17:37:14 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local DRV=$(getdriver $T)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$T" ]; then
|
2013-09-10 17:37:14 +08:00
|
|
|
$DRV make -C $T -f build/core/main.mk $@
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function findmakefile()
|
|
|
|
{
|
|
|
|
TOPFILE=build/core/envsetup.mk
|
2008-12-18 10:03:49 +08:00
|
|
|
local HERE=$PWD
|
2008-10-21 22:00:00 +08:00
|
|
|
T=
|
|
|
|
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
|
2012-10-12 06:05:07 +08:00
|
|
|
T=`PWD= /bin/pwd`
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ -f "$T/Android.mk" ]; then
|
|
|
|
echo $T/Android.mk
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $HERE
|
2008-10-21 22:00:00 +08:00
|
|
|
return
|
|
|
|
fi
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd ..
|
2008-10-21 22:00:00 +08:00
|
|
|
done
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $HERE
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function mm()
|
|
|
|
{
|
2013-09-10 17:37:14 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local DRV=$(getdriver $T)
|
2008-10-21 22:00:00 +08:00
|
|
|
# If we're sitting in the root of the build tree, just do a
|
|
|
|
# normal make.
|
|
|
|
if [ -f build/core/envsetup.mk -a -f Makefile ]; then
|
2013-09-10 17:37:14 +08:00
|
|
|
$DRV make $@
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
# Find the closest Android.mk file.
|
2008-12-18 10:03:49 +08:00
|
|
|
local M=$(findmakefile)
|
2013-08-17 04:24:47 +08:00
|
|
|
local MODULES=
|
|
|
|
local GET_INSTALL_PATH=
|
|
|
|
local ARGS=
|
2009-07-16 06:07:44 +08:00
|
|
|
# Remove the path to top as the makefilepath needs to be relative
|
|
|
|
local M=`echo $M|sed 's:'$T'/::'`
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
elif [ ! "$M" ]; then
|
|
|
|
echo "Couldn't locate a makefile from the current directory."
|
|
|
|
else
|
2013-08-17 04:24:47 +08:00
|
|
|
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
|
2013-09-11 09:07:23 +08:00
|
|
|
ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function mmm()
|
|
|
|
{
|
2013-09-10 17:37:14 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local DRV=$(getdriver $T)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$T" ]; then
|
2008-12-18 10:03:49 +08:00
|
|
|
local MAKEFILE=
|
2011-12-01 04:40:19 +08:00
|
|
|
local MODULES=
|
2008-12-18 10:03:49 +08:00
|
|
|
local ARGS=
|
|
|
|
local DIR TO_CHOP
|
2013-08-17 04:24:47 +08:00
|
|
|
local GET_INSTALL_PATH=
|
2009-03-04 11:28:42 +08:00
|
|
|
local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
|
|
|
|
local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
|
|
|
|
for DIR in $DIRS ; do
|
2011-12-01 04:40:19 +08:00
|
|
|
MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
|
|
|
|
if [ "$MODULES" = "" ]; then
|
|
|
|
MODULES=all_modules
|
|
|
|
fi
|
|
|
|
DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ -f $DIR/Android.mk ]; then
|
2013-08-17 04:24:47 +08:00
|
|
|
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}-`
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$MFILE" = "" ] ; then
|
|
|
|
MFILE=$DIR/Android.mk
|
|
|
|
else
|
|
|
|
MFILE=$MFILE/$DIR/Android.mk
|
|
|
|
fi
|
|
|
|
MAKEFILE="$MAKEFILE $MFILE"
|
|
|
|
else
|
2013-08-17 04:24:47 +08:00
|
|
|
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
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
done
|
2013-08-17 04:24:47 +08:00
|
|
|
if [ -n "$GET_INSTALL_PATH" ]; then
|
|
|
|
ARGS=$GET_INSTALL_PATH
|
|
|
|
MODULES=
|
|
|
|
fi
|
2013-09-10 17:37:14 +08:00
|
|
|
ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2013-02-09 10:01:04 +08:00
|
|
|
function mma()
|
|
|
|
{
|
2013-09-10 17:37:14 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local DRV=$(getdriver $T)
|
2013-02-09 10:01:04 +08:00
|
|
|
if [ -f build/core/envsetup.mk -a -f Makefile ]; then
|
2013-09-10 17:37:14 +08:00
|
|
|
$DRV make $@
|
2013-02-09 10:01:04 +08:00
|
|
|
else
|
|
|
|
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'/::'`
|
2013-09-10 17:37:14 +08:00
|
|
|
$DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD"
|
2013-02-09 10:01:04 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function mmma()
|
|
|
|
{
|
2013-09-10 17:37:14 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local DRV=$(getdriver $T)
|
2013-02-09 10:01:04 +08:00
|
|
|
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
|
2013-09-10 17:37:14 +08:00
|
|
|
$DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS"
|
2013-02-09 10:01:04 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function croot()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ "$T" ]; then
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2009-07-31 01:23:21 +08:00
|
|
|
function cproj()
|
|
|
|
{
|
|
|
|
TOPFILE=build/core/envsetup.mk
|
|
|
|
local HERE=$PWD
|
|
|
|
T=
|
|
|
|
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
|
|
|
|
T=$PWD
|
|
|
|
if [ -f "$T/Android.mk" ]; then
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $T
|
2009-07-31 01:23:21 +08:00
|
|
|
return
|
|
|
|
fi
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd ..
|
2009-07-31 01:23:21 +08:00
|
|
|
done
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $HERE
|
2009-07-31 01:23:21 +08:00
|
|
|
echo "can't find Android.mk"
|
|
|
|
}
|
|
|
|
|
2013-07-31 01:23:52 +08:00
|
|
|
# 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
|
2013-08-28 05:15:50 +08:00
|
|
|
qpid | \grep "$prepend$EXE$append"
|
2013-07-31 01:23:52 +08:00
|
|
|
else
|
|
|
|
adb shell ps \
|
|
|
|
| tr -d '\r' \
|
|
|
|
| sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function pid()
|
|
|
|
{
|
2013-07-31 01:23:52 +08:00
|
|
|
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' \
|
2013-08-28 05:15:50 +08:00
|
|
|
| \grep "$prepend$EXE$append" \
|
2013-07-31 01:23:52 +08:00
|
|
|
| sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
|
|
|
|
echo "$PID"
|
|
|
|
else
|
|
|
|
echo "usage: pid [--exact] <process name>"
|
|
|
|
return 255
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2009-11-13 07:33:08 +08:00
|
|
|
# systemstack - dump the current stack trace of all threads in the system process
|
|
|
|
# to the usual ANR traces file
|
|
|
|
function systemstack()
|
|
|
|
{
|
2013-02-20 09:00:46 +08:00
|
|
|
stacks system_server
|
|
|
|
}
|
|
|
|
|
|
|
|
function stacks()
|
|
|
|
{
|
|
|
|
if [[ $1 =~ ^[0-9]+$ ]] ; then
|
|
|
|
local PID="$1"
|
|
|
|
elif [ "$1" ] ; then
|
2013-08-20 06:14:16 +08:00
|
|
|
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
|
2013-02-20 09:00:46 +08:00
|
|
|
else
|
|
|
|
echo "usage: stacks [pid|process name]"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$PID" ] ; then
|
2013-08-20 06:14:16 +08:00
|
|
|
# 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
|
2014-06-20 10:58:12 +08:00
|
|
|
local USE64BIT="$(is64bit $PID)"
|
|
|
|
adb shell debuggerd$USE64BIT -b $PID
|
2013-08-20 06:14:16 +08:00
|
|
|
fi
|
2013-02-20 09:00:46 +08:00
|
|
|
fi
|
2009-11-13 07:33:08 +08:00
|
|
|
}
|
|
|
|
|
2014-06-20 10:58:12 +08:00
|
|
|
# Read the ELF header from /proc/$PID/exe to determine if the process is
|
|
|
|
# 64-bit.
|
2014-02-26 02:27:07 +08:00
|
|
|
function is64bit()
|
|
|
|
{
|
|
|
|
local PID="$1"
|
|
|
|
if [ "$PID" ] ; then
|
2014-06-20 10:58:12 +08:00
|
|
|
if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -ps)" -eq "02" ]] ; then
|
2014-02-26 02:27:07 +08:00
|
|
|
echo "64"
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo ""
|
|
|
|
fi
|
2012-11-10 01:48:04 +08:00
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
case `uname -s` in
|
|
|
|
Darwin)
|
|
|
|
function sgrep()
|
|
|
|
{
|
2014-07-27 06:15:41 +08:00
|
|
|
find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl)' -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
function sgrep()
|
|
|
|
{
|
2014-07-27 06:15:41 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\)' -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2012-07-26 10:57:22 +08:00
|
|
|
function gettargetarch
|
|
|
|
{
|
|
|
|
get_build_var TARGET_ARCH
|
|
|
|
}
|
|
|
|
|
2014-04-08 01:57:38 +08:00
|
|
|
function ggrep()
|
|
|
|
{
|
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function jgrep()
|
|
|
|
{
|
2013-07-05 21:09:25 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function cgrep()
|
|
|
|
{
|
2014-11-23 02:16:01 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f \( -name '*.c' -o -name '*.cc' -o -name '*.cpp' -o -name '*.h' -o -name '*.hpp' \) -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function resgrep()
|
|
|
|
{
|
2013-07-05 21:09:25 +08:00
|
|
|
for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done;
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2013-03-09 02:20:47 +08:00
|
|
|
function mangrep()
|
|
|
|
{
|
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
|
|
|
|
}
|
|
|
|
|
2013-05-07 05:11:48 +08:00
|
|
|
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 "$@"
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
case `uname -s` in
|
|
|
|
Darwin)
|
|
|
|
function mgrep()
|
|
|
|
{
|
2012-08-18 06:03:20 +08:00
|
|
|
find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function treegrep()
|
|
|
|
{
|
2011-03-16 05:15:46 +08:00
|
|
|
find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
function mgrep()
|
|
|
|
{
|
2012-08-18 06:03:20 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function treegrep()
|
|
|
|
{
|
2011-03-16 05:15:46 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@"
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
function getprebuilt
|
|
|
|
{
|
|
|
|
get_abs_build_var ANDROID_PREBUILTS
|
|
|
|
}
|
|
|
|
|
|
|
|
function tracedmdump()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
|
|
|
return
|
|
|
|
fi
|
2008-12-18 10:03:49 +08:00
|
|
|
local prebuiltdir=$(getprebuilt)
|
2012-07-26 10:57:22 +08:00
|
|
|
local arch=$(gettargetarch)
|
|
|
|
local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
local TRACE=$1
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ ! "$TRACE" ] ; then
|
|
|
|
echo "usage: tracedmdump tracename"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2009-04-10 09:12:34 +08:00
|
|
|
if [ ! -r "$KERNEL" ] ; then
|
|
|
|
echo "Error: cannot find kernel: '$KERNEL'"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
local BASETRACE=$(basename $TRACE)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$BASETRACE" = "$TRACE" ] ; then
|
|
|
|
TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "post-processing traces..."
|
|
|
|
rm -f $TRACE/qtrace.dexlist
|
|
|
|
post_trace $TRACE
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "***"
|
|
|
|
echo "*** Error: malformed trace. Did you remember to exit the emulator?"
|
|
|
|
echo "***"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
echo "generating dexlist output..."
|
|
|
|
/bin/ls $ANDROID_PRODUCT_OUT/system/framework/*.jar $ANDROID_PRODUCT_OUT/system/app/*.apk $ANDROID_PRODUCT_OUT/data/app/*.apk 2>/dev/null | xargs dexlist > $TRACE/qtrace.dexlist
|
|
|
|
echo "generating dmtrace data..."
|
|
|
|
q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
|
|
|
|
echo "generating html file..."
|
|
|
|
dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
|
|
|
|
echo "done, see $TRACE/dmtrace.html for details"
|
|
|
|
echo "or run:"
|
|
|
|
echo " traceview $TRACE/dmtrace"
|
|
|
|
}
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
# communicate with a running device or emulator, set up necessary state,
|
|
|
|
# and run the hat command.
|
2008-10-21 22:00:00 +08:00
|
|
|
function runhat()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
# process standard adb options
|
|
|
|
local adbTarget=""
|
2010-07-12 23:00:19 +08:00
|
|
|
if [ "$1" = "-d" -o "$1" = "-e" ]; then
|
2008-12-18 10:03:49 +08:00
|
|
|
adbTarget=$1
|
|
|
|
shift 1
|
2010-07-12 23:00:19 +08:00
|
|
|
elif [ "$1" = "-s" ]; then
|
2008-12-18 10:03:49 +08:00
|
|
|
adbTarget="$1 $2"
|
|
|
|
shift 2
|
|
|
|
fi
|
|
|
|
local adbOptions=${adbTarget}
|
2012-09-27 06:00:59 +08:00
|
|
|
#echo adbOptions = ${adbOptions}
|
2008-12-18 10:03:49 +08:00
|
|
|
|
|
|
|
# runhat options
|
|
|
|
local targetPid=$1
|
2008-10-21 22:00:00 +08:00
|
|
|
|
|
|
|
if [ "$targetPid" = "" ]; then
|
2010-07-12 23:00:19 +08:00
|
|
|
echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
|
2008-10-21 22:00:00 +08:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
# confirm hat is available
|
|
|
|
if [ -z $(which hat) ]; then
|
|
|
|
echo "hat is not available in this configuration."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2010-07-12 23:00:19 +08:00
|
|
|
# issue "am" command to cause the hprof dump
|
2014-07-19 06:45:38 +08:00
|
|
|
local devFile=/data/local/tmp/hprof-$targetPid
|
2008-10-21 22:00:00 +08:00
|
|
|
echo "Poking $targetPid and waiting for data..."
|
2012-09-27 06:00:59 +08:00
|
|
|
echo "Storing data at $devFile"
|
2010-07-12 23:00:19 +08:00
|
|
|
adb ${adbOptions} shell am dumpheap $targetPid $devFile
|
2009-03-04 11:28:42 +08:00
|
|
|
echo "Press enter when logcat shows \"hprof: heap dump completed\""
|
2008-10-21 22:00:00 +08:00
|
|
|
echo -n "> "
|
|
|
|
read
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
local localFile=/tmp/$$-hprof
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
echo "Retrieving file $devFile..."
|
|
|
|
adb ${adbOptions} pull $devFile $localFile
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
adb ${adbOptions} shell rm $devFile
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
echo "Running hat on $localFile"
|
2008-10-21 22:00:00 +08:00
|
|
|
echo "View the output by pointing your browser at http://localhost:7000/"
|
|
|
|
echo ""
|
2011-11-11 07:19:51 +08:00
|
|
|
hat -JXmx512m $localFile
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function getbugreports()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
|
2008-10-21 22:00:00 +08:00
|
|
|
|
|
|
|
if [ ! "$reports" ]; then
|
|
|
|
echo "Could not locate any bugreports."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
local report
|
|
|
|
for report in ${reports[@]}
|
2008-10-21 22:00:00 +08:00
|
|
|
do
|
2008-12-18 10:03:49 +08:00
|
|
|
echo "/sdcard/bugreports/${report}"
|
|
|
|
adb pull /sdcard/bugreports/${report} ${report}
|
|
|
|
gunzip ${report}
|
2008-10-21 22:00:00 +08:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2012-08-22 06:44:06 +08:00
|
|
|
function getsdcardpath()
|
|
|
|
{
|
|
|
|
adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getscreenshotpath()
|
|
|
|
{
|
|
|
|
echo "$(getsdcardpath)/Pictures/Screenshots"
|
|
|
|
}
|
|
|
|
|
|
|
|
function getlastscreenshot()
|
|
|
|
{
|
|
|
|
local screenshot_path=$(getscreenshotpath)
|
|
|
|
local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
|
|
|
|
if [ "$screenshot" = "" ]; then
|
|
|
|
echo "No screenshots found."
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
echo "${screenshot}"
|
|
|
|
adb ${adbOptions} pull ${screenshot_path}/${screenshot}
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function startviewserver()
|
|
|
|
{
|
2008-12-18 10:03:49 +08:00
|
|
|
local port=4939
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ $# -gt 0 ]; then
|
|
|
|
port=$1
|
|
|
|
fi
|
|
|
|
adb shell service call window 1 i32 $port
|
|
|
|
}
|
|
|
|
|
|
|
|
function stopviewserver()
|
|
|
|
{
|
|
|
|
adb shell service call window 2
|
|
|
|
}
|
|
|
|
|
|
|
|
function isviewserverstarted()
|
|
|
|
{
|
|
|
|
adb shell service call window 3
|
|
|
|
}
|
|
|
|
|
2010-10-05 07:56:11 +08:00
|
|
|
function key_home()
|
|
|
|
{
|
|
|
|
adb shell input keyevent 3
|
|
|
|
}
|
|
|
|
|
|
|
|
function key_back()
|
|
|
|
{
|
|
|
|
adb shell input keyevent 4
|
|
|
|
}
|
|
|
|
|
|
|
|
function key_menu()
|
|
|
|
{
|
|
|
|
adb shell input keyevent 82
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function smoketest()
|
|
|
|
{
|
|
|
|
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
|
|
|
|
echo "Couldn't locate output files. Try running 'lunch' first." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2012-12-14 02:52:07 +08:00
|
|
|
(\cd "$T" && mmm tests/SmokeTest) &&
|
2008-10-21 22:00:00 +08:00
|
|
|
adb uninstall com.android.smoketest > /dev/null &&
|
|
|
|
adb uninstall com.android.smoketest.tests > /dev/null &&
|
|
|
|
adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
|
|
|
|
adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
|
|
|
|
adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
|
|
|
|
}
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
# simple shortcut to the runtest command
|
|
|
|
function runtest()
|
|
|
|
{
|
|
|
|
T=$(gettop)
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2009-10-22 11:05:26 +08:00
|
|
|
("$T"/development/testrunner/runtest.py $@)
|
2009-03-28 01:25:11 +08:00
|
|
|
}
|
|
|
|
|
2009-03-04 11:28:42 +08:00
|
|
|
function godir () {
|
|
|
|
if [[ -z "$1" ]]; then
|
|
|
|
echo "Usage: godir <regex>"
|
|
|
|
return
|
|
|
|
fi
|
2010-01-30 08:39:32 +08:00
|
|
|
T=$(gettop)
|
2009-03-04 11:28:42 +08:00
|
|
|
if [[ ! -f $T/filelist ]]; then
|
|
|
|
echo -n "Creating index..."
|
2012-12-14 02:52:07 +08:00
|
|
|
(\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
|
2009-03-04 11:28:42 +08:00
|
|
|
echo " Done"
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
local lines
|
2011-11-19 07:15:25 +08:00
|
|
|
lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
|
2009-03-04 11:28:42 +08:00
|
|
|
if [[ ${#lines[@]} = 0 ]]; then
|
|
|
|
echo "Not found"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
local pathname
|
|
|
|
local choice
|
|
|
|
if [[ ${#lines[@]} > 1 ]]; then
|
|
|
|
while [[ -z "$pathname" ]]; do
|
|
|
|
local index=1
|
|
|
|
local line
|
|
|
|
for line in ${lines[@]}; do
|
|
|
|
printf "%6s %s\n" "[$index]" $line
|
2011-04-22 23:16:56 +08:00
|
|
|
index=$(($index + 1))
|
2009-03-04 11:28:42 +08:00
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo -n "Select one: "
|
|
|
|
unset choice
|
|
|
|
read choice
|
|
|
|
if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
|
|
|
|
echo "Invalid choice"
|
|
|
|
continue
|
|
|
|
fi
|
2010-07-05 15:53:47 +08:00
|
|
|
pathname=${lines[$(($choice-1))]}
|
2009-03-04 11:28:42 +08:00
|
|
|
done
|
|
|
|
else
|
|
|
|
pathname=${lines[0]}
|
|
|
|
fi
|
2012-12-14 02:52:07 +08:00
|
|
|
\cd $T/$pathname
|
2009-03-04 11:28:42 +08:00
|
|
|
}
|
|
|
|
|
2014-10-16 17:23:03 +08:00
|
|
|
# Force JAVA_HOME to point to java 1.7 if it isn't already set.
|
2014-01-17 18:05:25 +08:00
|
|
|
#
|
|
|
|
# Note that the MacOS path for java 1.7 includes a minor revision number (sigh).
|
|
|
|
# For some reason, installing the JDK doesn't make it show up in the
|
|
|
|
# JavaVM.framework/Versions/1.7/ folder.
|
2010-06-22 07:26:38 +08:00
|
|
|
function set_java_home() {
|
2014-01-17 18:05:25 +08:00
|
|
|
# Clear the existing JAVA_HOME value if we set it ourselves, so that
|
2014-04-01 21:16:26 +08:00
|
|
|
# we can reset it later, depending on the version of java the build
|
|
|
|
# system needs.
|
2014-01-17 18:05:25 +08:00
|
|
|
#
|
|
|
|
# If we don't do this, the JAVA_HOME value set by the first call to
|
|
|
|
# build/envsetup.sh will persist forever.
|
|
|
|
if [ -n "$ANDROID_SET_JAVA_HOME" ]; then
|
|
|
|
export JAVA_HOME=""
|
|
|
|
fi
|
|
|
|
|
2010-06-25 03:52:51 +08:00
|
|
|
if [ ! "$JAVA_HOME" ]; then
|
2014-10-16 17:23:03 +08:00
|
|
|
case `uname -s` in
|
|
|
|
Darwin)
|
|
|
|
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
|
|
|
|
;;
|
|
|
|
esac
|
2014-01-17 18:05:25 +08:00
|
|
|
|
|
|
|
# Keep track of the fact that we set JAVA_HOME ourselves, so that
|
|
|
|
# we can change it on the next envsetup.sh, if required.
|
|
|
|
export ANDROID_SET_JAVA_HOME=true
|
2010-06-08 04:03:54 +08:00
|
|
|
fi
|
2010-06-22 07:26:38 +08:00
|
|
|
}
|
2010-06-08 04:03:54 +08:00
|
|
|
|
2013-03-09 07:15:06 +08:00
|
|
|
# Print colored exit condition
|
|
|
|
function pez {
|
2013-03-09 09:34:02 +08:00
|
|
|
"$@"
|
|
|
|
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
|
2013-03-09 07:15:06 +08:00
|
|
|
}
|
|
|
|
|
2014-08-25 13:14:19 +08:00
|
|
|
function get_make_command()
|
|
|
|
{
|
|
|
|
echo command make
|
|
|
|
}
|
|
|
|
|
2014-06-19 05:55:58 +08:00
|
|
|
function make()
|
|
|
|
{
|
|
|
|
local start_time=$(date +"%s")
|
2014-08-25 13:14:19 +08:00
|
|
|
$(get_make_command) "$@"
|
2014-06-19 05:55:58 +08:00
|
|
|
local ret=$?
|
|
|
|
local end_time=$(date +"%s")
|
|
|
|
local tdiff=$(($end_time-$start_time))
|
|
|
|
local hours=$(($tdiff / 3600 ))
|
|
|
|
local mins=$((($tdiff % 3600) / 60))
|
|
|
|
local secs=$(($tdiff % 60))
|
|
|
|
echo
|
|
|
|
if [ $ret -eq 0 ] ; then
|
2014-11-09 14:41:52 +08:00
|
|
|
if [ $(uname) != "Darwin" ]; then
|
|
|
|
echo -n -e "\e[0;32m#### make completed successfully "
|
|
|
|
else
|
|
|
|
echo -n -e "#### make completed successfully "
|
|
|
|
fi
|
2014-06-19 05:55:58 +08:00
|
|
|
else
|
2014-11-09 14:41:52 +08:00
|
|
|
if [ $(uname) != "Darwin" ]; then
|
|
|
|
echo -n -e "\e[0;31m#### make failed to build some targets "
|
|
|
|
else
|
|
|
|
echo -n -e "#### make failed to build some targets "
|
|
|
|
fi
|
2014-06-19 05:55:58 +08:00
|
|
|
fi
|
|
|
|
if [ $hours -gt 0 ] ; then
|
|
|
|
printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
|
|
|
|
elif [ $mins -gt 0 ] ; then
|
|
|
|
printf "(%02g:%02g (mm:ss))" $mins $secs
|
|
|
|
elif [ $secs -gt 0 ] ; then
|
|
|
|
printf "(%s seconds)" $secs
|
|
|
|
fi
|
2014-11-09 14:41:52 +08:00
|
|
|
if [ $(uname) != "Darwin" ]; then
|
|
|
|
echo -e " ####\e[00m"
|
|
|
|
fi
|
2014-06-19 05:55:58 +08:00
|
|
|
echo
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2011-06-21 07:03:14 +08:00
|
|
|
if [ "x$SHELL" != "x/bin/bash" ]; then
|
|
|
|
case `ps -o command -p $$` in
|
|
|
|
*bash*)
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
2008-12-18 10:03:49 +08:00
|
|
|
|
|
|
|
# Execute the contents of any vendorsetup.sh files we can find.
|
2014-07-10 06:37:34 +08:00
|
|
|
for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null` \
|
|
|
|
`test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null`
|
2008-12-18 10:03:49 +08:00
|
|
|
do
|
|
|
|
echo "including $f"
|
|
|
|
. $f
|
|
|
|
done
|
|
|
|
unset f
|
2011-07-16 02:07:06 +08:00
|
|
|
|
|
|
|
addcompletions
|