2012-03-08 09:15:06 +08:00
|
|
|
function hmm() {
|
2008-10-21 22:00:00 +08:00
|
|
|
cat <<EOF
|
2017-05-31 08:12:37 +08:00
|
|
|
|
|
|
|
Run "m help" for help with the build system itself.
|
|
|
|
|
2008-12-18 10:03:49 +08:00
|
|
|
Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
|
2015-10-01 05:10:48 +08:00
|
|
|
- lunch: lunch <product_name>-<build_variant>
|
2017-05-31 08:12:37 +08:00
|
|
|
Selects <product_name> as the product to build, and <build_variant> as the variant to
|
|
|
|
build, and stores those selections in the environment to be read by subsequent
|
|
|
|
invocations of 'm' etc.
|
2018-01-09 07:26:16 +08:00
|
|
|
- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|arm64|x86_64|mips64] [eng|userdebug|user]
|
2015-10-01 05:10:48 +08:00
|
|
|
- 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, but not their dependencies.
|
|
|
|
- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
|
|
|
|
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.
|
|
|
|
- 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.
|
|
|
|
- jgrep: Greps on all local Java files.
|
|
|
|
- resgrep: Greps on all local res/*.xml files.
|
|
|
|
- mangrep: Greps on all local AndroidManifest.xml files.
|
|
|
|
- mgrep: Greps on all local Makefiles files.
|
|
|
|
- sepgrep: Greps on all local sepolicy files.
|
|
|
|
- sgrep: Greps on all local source files.
|
|
|
|
- godir: Go to the directory containing a file.
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2015-10-20 19:48:19 +08:00
|
|
|
Environment options:
|
2014-11-01 07:23:08 +08:00
|
|
|
- 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
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local A=""
|
|
|
|
local i
|
2015-05-15 22:12:53 +08:00
|
|
|
for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
|
2008-10-21 22:00:00 +08:00
|
|
|
A="$A $i"
|
|
|
|
done
|
|
|
|
echo $A
|
|
|
|
}
|
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
# Get all the build variables needed by this script in a single call to the build system.
|
|
|
|
function build_build_var_cache()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2016-03-04 12:57:21 +08:00
|
|
|
# Grep out the variable names from the script.
|
|
|
|
cached_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
|
|
|
|
cached_abs_vars=`cat $T/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/get_abs_build_var/) print $(i+1)}' | sort -u | tr '\n' ' '`
|
|
|
|
# Call the build system to dump the "<val>=<value>" pairs as a shell script.
|
2018-01-06 04:13:11 +08:00
|
|
|
build_dicts_script=`\builtin cd $T; build/soong/soong_ui.bash --dumpvars-mode \
|
2017-07-15 02:29:44 +08:00
|
|
|
--vars="$cached_vars" \
|
|
|
|
--abs-vars="$cached_abs_vars" \
|
|
|
|
--var-prefix=var_cache_ \
|
|
|
|
--abs-var-prefix=abs_var_cache_`
|
2016-03-04 12:57:21 +08:00
|
|
|
local ret=$?
|
|
|
|
if [ $ret -ne 0 ]
|
|
|
|
then
|
|
|
|
unset build_dicts_script
|
|
|
|
return $ret
|
|
|
|
fi
|
2017-07-15 02:29:44 +08:00
|
|
|
# Execute the script to store the "<val>=<value>" pairs as shell variables.
|
2016-03-04 12:57:21 +08:00
|
|
|
eval "$build_dicts_script"
|
|
|
|
ret=$?
|
2016-03-05 05:56:23 +08:00
|
|
|
unset build_dicts_script
|
2016-03-04 12:57:21 +08:00
|
|
|
if [ $ret -ne 0 ]
|
|
|
|
then
|
|
|
|
return $ret
|
|
|
|
fi
|
|
|
|
BUILD_VAR_CACHE_READY="true"
|
|
|
|
}
|
|
|
|
|
2016-03-05 05:56:23 +08:00
|
|
|
# Delete the build var cache, so that we can still call into the build system
|
2016-03-04 12:57:21 +08:00
|
|
|
# to get build variables not listed in this script.
|
|
|
|
function destroy_build_var_cache()
|
|
|
|
{
|
|
|
|
unset BUILD_VAR_CACHE_READY
|
2017-03-24 02:08:58 +08:00
|
|
|
local v
|
2016-03-04 12:57:21 +08:00
|
|
|
for v in $cached_vars; do
|
|
|
|
unset var_cache_$v
|
|
|
|
done
|
|
|
|
unset cached_vars
|
|
|
|
for v in $cached_abs_vars; do
|
|
|
|
unset abs_var_cache_$v
|
|
|
|
done
|
|
|
|
unset cached_abs_vars
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
# Get the value of a build variable as an absolute path.
|
|
|
|
function get_abs_build_var()
|
|
|
|
{
|
2016-03-04 12:57:21 +08:00
|
|
|
if [ "$BUILD_VAR_CACHE_READY" = "true" ]
|
|
|
|
then
|
2016-03-12 02:00:40 +08:00
|
|
|
eval "echo \"\${abs_var_cache_$1}\""
|
2016-03-04 12:57:21 +08:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2017-07-15 02:29:44 +08:00
|
|
|
(\cd $T; build/soong/soong_ui.bash --dumpvar-mode --abs $1)
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# Get the exact value of a build variable.
|
|
|
|
function get_build_var()
|
|
|
|
{
|
2016-03-04 12:57:21 +08:00
|
|
|
if [ "$BUILD_VAR_CACHE_READY" = "true" ]
|
|
|
|
then
|
2016-03-12 02:00:40 +08:00
|
|
|
eval "echo \"\${var_cache_$1}\""
|
2016-03-04 12:57:21 +08:00
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP." >&2
|
|
|
|
return
|
|
|
|
fi
|
2017-07-15 02:29:44 +08:00
|
|
|
(\cd $T; build/soong/soong_ui.bash --dumpvar-mode $1)
|
2008-12-18 10:03:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# check to see if the supplied product is one we can build
|
|
|
|
function check_product()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-12-18 10:03:49 +08:00
|
|
|
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()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local v
|
2008-12-18 10:03:49 +08:00
|
|
|
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()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
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
|
2017-03-24 02:08:58 +08:00
|
|
|
local prebuiltdir=$(getprebuilt)
|
|
|
|
local 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
|
2017-03-24 02:08:58 +08:00
|
|
|
local targetgccversion=$(get_build_var TARGET_GCC_VERSION)
|
|
|
|
local 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)
|
2017-03-24 02:08:58 +08:00
|
|
|
local toolchaindir toolchaindir2=
|
2012-04-17 20:50:47 +08:00
|
|
|
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
|
|
|
|
2017-03-24 02:08:58 +08:00
|
|
|
if [ "$toolchaindir2" -a -d "$gccprebuiltdir/$toolchaindir2" ]; then
|
2014-02-26 02:27:07 +08:00
|
|
|
export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
|
|
|
|
fi
|
|
|
|
|
2015-06-13 00:56:39 +08:00
|
|
|
export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin
|
2017-04-08 05:11:54 +08:00
|
|
|
|
|
|
|
# add kernel specific binaries
|
|
|
|
case $(uname -s) in
|
|
|
|
Linux)
|
|
|
|
export ANDROID_DEV_SCRIPTS=$ANDROID_DEV_SCRIPTS:$T/prebuilts/misc/linux-x86/dtc:$T/prebuilts/misc/linux-x86/libufdt
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2017-10-04 04:31:18 +08:00
|
|
|
ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN
|
|
|
|
if [ -n "$ANDROID_TOOLCHAIN_2ND_ARCH" ]; then
|
|
|
|
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ANDROID_TOOLCHAIN_2ND_ARCH
|
|
|
|
fi
|
|
|
|
ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ANDROID_DEV_SCRIPTS:
|
|
|
|
export ANDROID_BUILD_PATHS
|
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
|
2015-09-19 04:23:56 +08:00
|
|
|
export PYTHONPATH=$T/development/python-packages:$PYTHONPATH
|
2008-12-18 10:03:49 +08:00
|
|
|
|
2017-07-01 07:01:45 +08:00
|
|
|
export ANDROID_JAVA_HOME=$(get_abs_build_var ANDROID_JAVA_HOME)
|
|
|
|
export JAVA_HOME=$ANDROID_JAVA_HOME
|
|
|
|
export ANDROID_JAVA_TOOLCHAIN=$(get_abs_build_var ANDROID_JAVA_TOOLCHAIN)
|
|
|
|
export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
|
|
|
|
export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
|
2010-06-22 07:26:38 +08:00
|
|
|
|
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)
|
|
|
|
|
2017-02-14 05:46:48 +08:00
|
|
|
unset ANDROID_HOST_OUT_TESTCASES
|
|
|
|
export ANDROID_HOST_OUT_TESTCASES=$(get_abs_build_var HOST_OUT_TESTCASES)
|
|
|
|
|
|
|
|
unset ANDROID_TARGET_OUT_TESTCASES
|
|
|
|
export ANDROID_TARGET_OUT_TESTCASES=$(get_abs_build_var TARGET_OUT_TESTCASES)
|
|
|
|
|
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()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-12-18 10:03:49 +08:00
|
|
|
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
|
|
|
|
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()
|
|
|
|
{
|
2017-03-22 08:41:03 +08:00
|
|
|
export BUILD_ENV_SEQUENCE_NUMBER=13
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function settitle()
|
|
|
|
{
|
2017-12-08 05:51:23 +08:00
|
|
|
# This used to be opt-out with STAY_OFF_MY_LAWN, but this breaks folks
|
|
|
|
# actually using PROMPT_COMMAND (https://issuetracker.google.com/38402256),
|
|
|
|
# and the attempt to set the title doesn't do anything for the default
|
|
|
|
# window manager in debian right now, so switch it to opt-in for anyone
|
|
|
|
# who actually wants this.
|
|
|
|
if [ "$ANDROID_BUILD_SET_WINDOW_TITLE" = "true" ]; 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
|
2016-10-21 07:39:49 +08:00
|
|
|
|
|
|
|
complete -C "bit --tab" bit
|
2011-07-16 02:07:06 +08:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
build_build_var_cache
|
2008-10-21 22:00:00 +08:00
|
|
|
set_stuff_for_environment
|
2016-03-04 12:57:21 +08:00
|
|
|
destroy_build_var_cache
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local default_value
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "x$TARGET_PRODUCT" != x ] ; then
|
|
|
|
default_value=$TARGET_PRODUCT
|
|
|
|
else
|
2015-06-09 02:57:26 +08:00
|
|
|
default_value=aosp_arm
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
export TARGET_BUILD_APPS=
|
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
|
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
build_build_var_cache
|
2008-10-21 22:00:00 +08:00
|
|
|
set_stuff_for_environment
|
2016-03-04 12:57:21 +08:00
|
|
|
destroy_build_var_cache
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
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
|
2016-03-04 12:57:21 +08:00
|
|
|
build_build_var_cache
|
2008-10-21 22:00:00 +08:00
|
|
|
set_stuff_for_environment
|
2008-12-18 10:03:49 +08:00
|
|
|
printconfig
|
2016-03-04 12:57:21 +08:00
|
|
|
destroy_build_var_cache
|
2008-12-18 10:03:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# 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
|
2017-03-22 08:41:03 +08:00
|
|
|
else
|
2008-12-18 10:03:49 +08:00
|
|
|
selection=$answer
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
|
2010-06-10 09:18:31 +08:00
|
|
|
export TARGET_BUILD_APPS=
|
|
|
|
|
2017-03-22 08:41:03 +08:00
|
|
|
local product variant_and_version variant version
|
|
|
|
|
|
|
|
product=${selection%%-*} # Trim everything after first dash
|
|
|
|
variant_and_version=${selection#*-} # Trim everything up to first dash
|
|
|
|
if [ "$variant_and_version" != "$selection" ]; then
|
|
|
|
variant=${variant_and_version%%-*}
|
|
|
|
if [ "$variant" != "$variant_and_version" ]; then
|
|
|
|
version=${variant_and_version#*-}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$product" ]
|
2011-07-12 13:11:46 +08:00
|
|
|
then
|
|
|
|
echo
|
2017-03-22 08:41:03 +08:00
|
|
|
echo "Invalid lunch combo: $selection"
|
|
|
|
return 1
|
2011-07-12 13:11:46 +08:00
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
TARGET_PRODUCT=$product \
|
|
|
|
TARGET_BUILD_VARIANT=$variant \
|
2017-03-22 08:41:03 +08:00
|
|
|
TARGET_PLATFORM_VERSION=$version \
|
2016-03-04 12:57:21 +08:00
|
|
|
build_build_var_cache
|
|
|
|
if [ $? -ne 0 ]
|
|
|
|
then
|
2011-07-12 13:11:46 +08:00
|
|
|
return 1
|
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
|
2017-03-22 08:41:03 +08:00
|
|
|
export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT)
|
|
|
|
export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT)
|
2017-05-02 05:21:28 +08:00
|
|
|
if [ -n "$version" ]; then
|
|
|
|
export TARGET_PLATFORM_VERSION=$(get_build_var TARGET_PLATFORM_VERSION)
|
|
|
|
else
|
|
|
|
unset TARGET_PLATFORM_VERSION
|
|
|
|
fi
|
2011-07-12 13:11:46 +08:00
|
|
|
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
|
2016-03-04 12:57:21 +08:00
|
|
|
destroy_build_var_cache
|
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()
|
|
|
|
{
|
2017-08-22 09:27:00 +08:00
|
|
|
local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)"
|
2018-01-09 07:26:16 +08:00
|
|
|
local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|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-09-05 12:28:00 +08:00
|
|
|
local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
|
2018-01-09 07:26:16 +08:00
|
|
|
local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|arm64|x86_64|mips64|ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
|
2010-06-10 09:18:31 +08:00
|
|
|
|
2017-08-22 09:27:00 +08:00
|
|
|
if [ "$showHelp" != "" ]; then
|
|
|
|
$(gettop)/build/make/tapasHelp.sh
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
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
|
2014-09-05 12:28:00 +08:00
|
|
|
if [ $(echo $density | wc -w) -gt 1 ]; then
|
|
|
|
echo "tapas: Error: Multiple densities supplied: $density"
|
|
|
|
return
|
|
|
|
fi
|
2012-08-23 01:25:20 +08:00
|
|
|
|
2015-06-09 02:57:26 +08:00
|
|
|
local product=aosp_arm
|
2012-08-23 01:25:20 +08:00
|
|
|
case $arch in
|
2015-06-09 02:57:26 +08:00
|
|
|
x86) product=aosp_x86;;
|
|
|
|
mips) product=aosp_mips;;
|
2014-05-30 08:57:40 +08:00
|
|
|
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
|
2014-11-05 03:35:51 +08:00
|
|
|
if [ -z "$density" ]; then
|
|
|
|
density=alldpi
|
|
|
|
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
|
2014-09-05 12:28:00 +08:00
|
|
|
export TARGET_BUILD_DENSITY=$density
|
2010-06-10 09:18:31 +08:00
|
|
|
export TARGET_BUILD_TYPE=release
|
|
|
|
export TARGET_BUILD_APPS=$apps
|
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
build_build_var_cache
|
2010-06-10 09:18:31 +08:00
|
|
|
set_stuff_for_environment
|
|
|
|
printconfig
|
2016-03-04 12:57:21 +08:00
|
|
|
destroy_build_var_cache
|
2010-06-10 09:18:31 +08:00
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function gettop
|
|
|
|
{
|
2017-10-21 02:37:33 +08:00
|
|
|
local TOPFILE=build/make/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
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=
|
2008-10-21 22:00:00 +08:00
|
|
|
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
|
2016-02-25 08:42:15 +08:00
|
|
|
# Use scan-build to collect all static analyzer reports into directory
|
|
|
|
# /tmp/scan-build-yyyy-mm-dd-hhmmss-*
|
|
|
|
# The clang compiler passed by --use-analyzer here is not important.
|
2017-10-21 02:37:33 +08:00
|
|
|
# build/make/core/binary.mk will set CLANG_CXX and CLANG before calling
|
2016-02-25 08:42:15 +08:00
|
|
|
# c++-analyzer and ccc-analyzer.
|
|
|
|
local CLANG_VERSION=$(get_build_var LLVM_PREBUILTS_VERSION)
|
|
|
|
local BUILD_OS=$(get_build_var BUILD_OS)
|
|
|
|
local CLANG_DIR="$T/prebuilts/clang/host/${BUILD_OS}-x86/${CLANG_VERSION}"
|
2013-09-10 17:37:14 +08:00
|
|
|
echo "\
|
2016-02-25 08:42:15 +08:00
|
|
|
${CLANG_DIR}/tools/scan-build/bin/scan-build \
|
|
|
|
--use-analyzer ${CLANG_DIR}/bin/clang \
|
|
|
|
--status-bugs"
|
2013-09-10 17:37:14 +08:00
|
|
|
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
|
2017-07-13 07:14:50 +08:00
|
|
|
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function findmakefile()
|
|
|
|
{
|
2017-10-21 02:37:33 +08:00
|
|
|
local TOPFILE=build/make/core/envsetup.mk
|
2008-12-18 10:03:49 +08:00
|
|
|
local HERE=$PWD
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=
|
2008-10-21 22:00:00 +08:00
|
|
|
while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
|
2012-10-12 06:05:07 +08:00
|
|
|
T=`PWD= /bin/pwd`
|
2016-05-27 06:32:15 +08:00
|
|
|
if [ -f "$T/Android.mk" -o -f "$T/Android.bp" ]; then
|
2008-10-21 22:00:00 +08:00
|
|
|
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
|
2017-07-13 07:14:50 +08:00
|
|
|
# normal build.
|
|
|
|
if [ -f build/soong/soong_ui.bash ]; then
|
|
|
|
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@
|
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."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2008-10-21 22:00:00 +08:00
|
|
|
elif [ ! "$M" ]; then
|
|
|
|
echo "Couldn't locate a makefile from the current directory."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
2017-03-24 02:08:58 +08:00
|
|
|
local ARG
|
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=
|
2016-08-12 08:20:33 +08:00
|
|
|
ARGS=GET-INSTALL-PATH-IN-$(dirname ${M})
|
|
|
|
ARGS=${ARGS//\//-}
|
2013-08-17 04:24:47 +08:00
|
|
|
else
|
2016-05-27 06:32:15 +08:00
|
|
|
MODULES=MODULES-IN-$(dirname ${M})
|
|
|
|
# Convert "/" to "-".
|
|
|
|
MODULES=${MODULES//\//-}
|
2013-08-17 04:24:47 +08:00
|
|
|
ARGS=$@
|
|
|
|
fi
|
2016-04-01 07:30:23 +08:00
|
|
|
if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then
|
|
|
|
MODULES=tidy_only
|
|
|
|
fi
|
2017-07-13 07:14:50 +08:00
|
|
|
ONE_SHOT_MAKEFILE=$M _wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $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=
|
2016-05-27 06:32:15 +08:00
|
|
|
local MODULES_IN_PATHS=
|
2008-12-18 10:03:49 +08:00
|
|
|
local ARGS=
|
|
|
|
local DIR TO_CHOP
|
2016-05-27 06:32:15 +08:00
|
|
|
local DIR_MODULES
|
2013-08-17 04:24:47 +08:00
|
|
|
local GET_INSTALL_PATH=
|
2016-08-12 08:20:33 +08:00
|
|
|
local GET_INSTALL_PATHS=
|
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
|
2016-05-27 06:32:15 +08:00
|
|
|
DIR_MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
|
2011-12-01 04:40:19 +08:00
|
|
|
DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
|
2016-05-27 06:32:15 +08:00
|
|
|
# Remove the leading ./ and trailing / if any exists.
|
|
|
|
DIR=${DIR#./}
|
|
|
|
DIR=${DIR%/}
|
|
|
|
if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; 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`
|
2016-09-01 08:22:36 +08:00
|
|
|
local MDIR=`echo $START | cut -c${TO_CHOP}-`
|
|
|
|
if [ "$MDIR" = "" ] ; then
|
|
|
|
MDIR=$DIR
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
2016-09-01 08:22:36 +08:00
|
|
|
MDIR=$MDIR/$DIR
|
|
|
|
fi
|
|
|
|
MDIR=${MDIR%/.}
|
|
|
|
if [ "$DIR_MODULES" = "" ]; then
|
|
|
|
MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$MDIR"
|
|
|
|
GET_INSTALL_PATHS="$GET_INSTALL_PATHS GET-INSTALL-PATH-IN-$MDIR"
|
|
|
|
else
|
|
|
|
MODULES="$MODULES $DIR_MODULES"
|
2008-10-21 22:00:00 +08:00
|
|
|
fi
|
2016-09-01 08:22:36 +08:00
|
|
|
MAKEFILE="$MAKEFILE $MDIR/Android.mk"
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
2013-08-17 04:24:47 +08:00
|
|
|
case $DIR in
|
2015-09-24 07:08:55 +08:00
|
|
|
showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
|
2013-08-17 04:24:47 +08:00
|
|
|
GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
|
2015-10-19 02:25:48 +08:00
|
|
|
*) if [ -d $DIR ]; then
|
|
|
|
echo "No Android.mk in $DIR.";
|
|
|
|
else
|
|
|
|
echo "Couldn't locate the directory $DIR";
|
|
|
|
fi
|
|
|
|
return 1;;
|
2013-08-17 04:24:47 +08:00
|
|
|
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
|
2016-08-12 08:20:33 +08:00
|
|
|
ARGS=${GET_INSTALL_PATHS//\//-}
|
2013-08-17 04:24:47 +08:00
|
|
|
MODULES=
|
2016-05-27 06:32:15 +08:00
|
|
|
MODULES_IN_PATHS=
|
2013-08-17 04:24:47 +08:00
|
|
|
fi
|
2016-04-01 07:30:23 +08:00
|
|
|
if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then
|
|
|
|
MODULES=tidy_only
|
2016-05-27 06:32:15 +08:00
|
|
|
MODULES_IN_PATHS=
|
2016-04-01 07:30:23 +08:00
|
|
|
fi
|
2016-05-27 06:32:15 +08:00
|
|
|
# Convert "/" to "-".
|
|
|
|
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
|
2017-07-13 07:14:50 +08:00
|
|
|
ONE_SHOT_MAKEFILE="$MAKEFILE" _wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS
|
2008-10-21 22:00:00 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2008-10-21 22:00:00 +08:00
|
|
|
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)
|
2017-07-13 07:14:50 +08:00
|
|
|
if [ -f build/soong/soong_ui.bash ]; then
|
|
|
|
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@
|
2013-02-09 10:01:04 +08:00
|
|
|
else
|
|
|
|
if [ ! "$T" ]; then
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2013-02-09 10:01:04 +08:00
|
|
|
fi
|
2016-09-02 06:30:18 +08:00
|
|
|
local M=$(findmakefile)
|
|
|
|
# Remove the path to top as the makefilepath needs to be relative
|
|
|
|
local M=`echo $M|sed 's:'$T'/::'`
|
|
|
|
local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M})
|
2015-09-25 07:19:19 +08:00
|
|
|
# Convert "/" to "-".
|
|
|
|
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
|
2017-07-13 07:14:50 +08:00
|
|
|
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $@ $MODULES_IN_PATHS
|
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=
|
2015-09-24 07:08:55 +08:00
|
|
|
local MODULES_IN_PATHS=
|
2013-02-09 10:01:04 +08:00
|
|
|
local ARGS=
|
|
|
|
for DIR in $DIRS ; do
|
|
|
|
if [ -d $DIR ]; then
|
2015-09-24 07:08:55 +08:00
|
|
|
# Remove the leading ./ and trailing / if any exists.
|
|
|
|
DIR=${DIR#./}
|
|
|
|
DIR=${DIR%/}
|
|
|
|
if [ "$MY_PWD" != "" ]; then
|
|
|
|
DIR=$MY_PWD/$DIR
|
2013-02-09 10:01:04 +08:00
|
|
|
fi
|
2015-09-25 07:19:19 +08:00
|
|
|
MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$DIR"
|
2013-02-09 10:01:04 +08:00
|
|
|
else
|
|
|
|
case $DIR in
|
2015-09-24 07:08:55 +08:00
|
|
|
showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";;
|
2013-02-09 10:01:04 +08:00
|
|
|
*) echo "Couldn't find directory $DIR"; return 1;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
2015-09-25 07:19:19 +08:00
|
|
|
# Convert "/" to "-".
|
|
|
|
MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-}
|
2017-07-13 07:14:50 +08:00
|
|
|
_wrap_build $DRV $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $ARGS $MODULES_IN_PATHS
|
2013-02-09 10:01:04 +08:00
|
|
|
else
|
|
|
|
echo "Couldn't locate the top of the tree. Try setting TOP."
|
2015-04-02 01:13:02 +08:00
|
|
|
return 1
|
2013-02-09 10:01:04 +08:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function croot()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
if [ "$T" ]; then
|
2016-04-22 07:53:39 +08:00
|
|
|
if [ "$1" ]; then
|
|
|
|
\cd $(gettop)/$1
|
|
|
|
else
|
|
|
|
\cd $(gettop)
|
|
|
|
fi
|
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()
|
|
|
|
{
|
2017-10-21 02:37:33 +08:00
|
|
|
local TOPFILE=build/make/core/envsetup.mk
|
2009-07-31 01:23:21 +08:00
|
|
|
local HERE=$PWD
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=
|
2009-07-31 01:23:21 +08:00
|
|
|
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
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "usage: qpid [[--exact] <process name|pid>"
|
|
|
|
return 255
|
|
|
|
fi
|
2013-07-31 01:23:52 +08:00
|
|
|
|
|
|
|
local EXE="$1"
|
|
|
|
if [ "$EXE" ] ; then
|
2016-03-04 12:57:21 +08:00
|
|
|
qpid | \grep "$prepend$EXE$append"
|
|
|
|
else
|
|
|
|
adb shell ps \
|
|
|
|
| tr -d '\r' \
|
|
|
|
| sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
|
|
|
|
fi
|
2013-07-31 01:23:52 +08:00
|
|
|
}
|
|
|
|
|
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>"
|
2016-03-04 12:57:21 +08:00
|
|
|
return 255
|
2013-07-31 01:23:52 +08:00
|
|
|
fi
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2014-11-04 09:04:47 +08:00
|
|
|
# coredump_setup - enable core dumps globally for any process
|
2014-10-29 09:00:42 +08:00
|
|
|
# that has the core-file-size limit set correctly
|
|
|
|
#
|
2014-11-05 12:57:37 +08:00
|
|
|
# NOTE: You must call also coredump_enable for a specific process
|
2014-10-29 09:00:42 +08:00
|
|
|
# if its core-file-size limit is not set already.
|
|
|
|
# NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
|
|
|
|
|
2014-11-04 09:04:47 +08:00
|
|
|
function coredump_setup()
|
2014-10-29 09:00:42 +08:00
|
|
|
{
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "Getting root...";
|
|
|
|
adb root;
|
|
|
|
adb wait-for-device;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "Remounting root partition read-write...";
|
|
|
|
adb shell mount -w -o remount -t rootfs rootfs;
|
|
|
|
sleep 1;
|
|
|
|
adb wait-for-device;
|
|
|
|
adb shell mkdir -p /cores;
|
|
|
|
adb shell mount -t tmpfs tmpfs /cores;
|
|
|
|
adb shell chmod 0777 /cores;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "Granting SELinux permission to dump in /cores...";
|
|
|
|
adb shell restorecon -R /cores;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "Set core pattern.";
|
|
|
|
adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
echo "Done."
|
2014-10-29 09:00:42 +08:00
|
|
|
}
|
|
|
|
|
2014-11-05 12:57:37 +08:00
|
|
|
# coredump_enable - enable core dumps for the specified process
|
2014-10-29 09:00:42 +08:00
|
|
|
# $1 = PID of process (e.g., $(pid mediaserver))
|
|
|
|
#
|
2014-11-05 12:57:37 +08:00
|
|
|
# NOTE: coredump_setup must have been called as well for a core
|
2014-10-29 09:00:42 +08:00
|
|
|
# dump to actually be generated.
|
|
|
|
|
2014-11-05 12:57:37 +08:00
|
|
|
function coredump_enable()
|
2014-10-29 09:00:42 +08:00
|
|
|
{
|
2016-03-04 12:57:21 +08:00
|
|
|
local PID=$1;
|
|
|
|
if [ -z "$PID" ]; then
|
|
|
|
printf "Expecting a PID!\n";
|
|
|
|
return;
|
|
|
|
fi;
|
|
|
|
echo "Setting core limit for $PID to infinite...";
|
2016-03-08 05:53:53 +08:00
|
|
|
adb shell /system/bin/ulimit -p $PID -c unlimited
|
2014-10-29 09:00:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
# core - send SIGV and pull the core for process
|
|
|
|
# $1 = PID of process (e.g., $(pid mediaserver))
|
|
|
|
#
|
2014-11-05 12:57:37 +08:00
|
|
|
# NOTE: coredump_setup must be called once per boot for core dumps to be
|
2014-10-29 09:00:42 +08:00
|
|
|
# enabled globally.
|
|
|
|
|
|
|
|
function core()
|
|
|
|
{
|
2016-03-04 12:57:21 +08:00
|
|
|
local PID=$1;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
if [ -z "$PID" ]; then
|
|
|
|
printf "Expecting a PID!\n";
|
|
|
|
return;
|
|
|
|
fi;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
local CORENAME=core.$PID;
|
|
|
|
local COREPATH=/cores/$CORENAME;
|
|
|
|
local SIG=SEGV;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
coredump_enable $1;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
local done=0;
|
|
|
|
while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
|
|
|
|
printf "\tSending SIG%s to %d...\n" $SIG $PID;
|
|
|
|
adb shell kill -$SIG $PID;
|
|
|
|
sleep 1;
|
|
|
|
done;
|
2014-10-29 09:00:42 +08:00
|
|
|
|
2016-03-04 12:57:21 +08:00
|
|
|
adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
|
|
|
|
echo "Done: core is under $COREPATH on device.";
|
2014-10-29 09:00:42 +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
|
2017-03-02 03:29:59 +08:00
|
|
|
adb shell debuggerd -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()
|
|
|
|
{
|
2016-02-20 03:06:58 +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|vts)' \
|
2015-09-23 06:13:48 +08:00
|
|
|
-exec grep --color -n "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
function sgrep()
|
|
|
|
{
|
2016-02-20 03:06:58 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \
|
2015-09-23 06:13:48 +08:00
|
|
|
-exec 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()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" \
|
|
|
|
-exec grep --color -n "$@" {} +
|
2014-04-08 01:57:38 +08:00
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
function jgrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" \
|
|
|
|
-exec grep --color -n "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function cgrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +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' \) \
|
|
|
|
-exec grep --color -n "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function resgrep()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local dir
|
2015-09-23 06:13:48 +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' -exec grep --color -n "$@" {} +
|
|
|
|
done
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
2013-03-09 02:20:47 +08:00
|
|
|
function mangrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' \
|
|
|
|
-exec grep --color -n "$@" {} +
|
2013-03-09 02:20:47 +08:00
|
|
|
}
|
|
|
|
|
2013-05-07 05:11:48 +08:00
|
|
|
function sepgrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d \
|
|
|
|
-exec grep --color -n -r --exclude-dir=\.git "$@" {} +
|
2013-05-07 05:11:48 +08:00
|
|
|
}
|
|
|
|
|
2015-02-27 06:13:46 +08:00
|
|
|
function rcgrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" \
|
|
|
|
-exec grep --color -n "$@" {} +
|
2015-02-27 06:13:46 +08:00
|
|
|
}
|
|
|
|
|
2008-10-21 22:00:00 +08:00
|
|
|
case `uname -s` in
|
|
|
|
Darwin)
|
|
|
|
function mgrep()
|
|
|
|
{
|
2017-05-11 01:49:44 +08:00
|
|
|
find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o \( -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk|.*\.bp)' -o -regex '(.*/)?soong/[^/]*.go' \) -type f \
|
2015-09-23 06:13:48 +08:00
|
|
|
-exec grep --color -n "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function treegrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' \
|
|
|
|
-exec grep --color -n -i "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
function mgrep()
|
|
|
|
{
|
2017-05-11 01:49:44 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o \( -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk|.*\.bp)' -o -regextype posix-extended -regex '(.*/)?soong/[^/]*.go' \) -type f \
|
2015-09-23 06:13:48 +08:00
|
|
|
-exec grep --color -n "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function treegrep()
|
|
|
|
{
|
2015-09-23 06:13:48 +08:00
|
|
|
find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f \
|
|
|
|
-exec grep --color -n -i "$@" {} +
|
2008-10-21 22:00:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
function getprebuilt
|
|
|
|
{
|
|
|
|
get_abs_build_var ANDROID_PREBUILTS
|
|
|
|
}
|
|
|
|
|
|
|
|
function tracedmdump()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
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
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-10-21 22:00:00 +08:00
|
|
|
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()
|
|
|
|
{
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
2008-12-18 10:03:49 +08:00
|
|
|
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
|
2017-03-24 02:08:58 +08:00
|
|
|
local T=$(gettop)
|
|
|
|
local FILELIST
|
2015-10-01 11:28:54 +08:00
|
|
|
if [ ! "$OUT_DIR" = "" ]; then
|
|
|
|
mkdir -p $OUT_DIR
|
|
|
|
FILELIST=$OUT_DIR/filelist
|
|
|
|
else
|
|
|
|
FILELIST=$T/filelist
|
|
|
|
fi
|
|
|
|
if [[ ! -f $FILELIST ]]; then
|
2009-03-04 11:28:42 +08:00
|
|
|
echo -n "Creating index..."
|
2015-10-01 11:28:54 +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
|
2015-10-01 11:28:54 +08:00
|
|
|
lines=($(\grep "$1" $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
|
|
|
}
|
|
|
|
|
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
|
2015-05-15 22:12:53 +08:00
|
|
|
echo $'\E'"[0;31mFAILURE\e[00m"
|
2013-03-09 09:34:02 +08:00
|
|
|
else
|
2015-05-15 22:12:53 +08:00
|
|
|
echo $'\E'"[0;32mSUCCESS\e[00m"
|
2013-03-09 09:34:02 +08:00
|
|
|
fi
|
|
|
|
return $retval
|
2013-03-09 07:15:06 +08:00
|
|
|
}
|
|
|
|
|
2014-08-25 13:14:19 +08:00
|
|
|
function get_make_command()
|
|
|
|
{
|
2017-07-13 07:14:50 +08:00
|
|
|
# If we're in the top of an Android tree, use soong_ui.bash instead of make
|
|
|
|
if [ -f build/soong/soong_ui.bash ]; then
|
2017-07-29 04:00:13 +08:00
|
|
|
# Always use the real make if -C is passed in
|
|
|
|
for arg in "$@"; do
|
|
|
|
if [[ $arg == -C* ]]; then
|
|
|
|
echo command make
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
2017-07-13 07:14:50 +08:00
|
|
|
echo build/soong/soong_ui.bash --make-mode
|
|
|
|
else
|
|
|
|
echo command make
|
|
|
|
fi
|
2014-08-25 13:14:19 +08:00
|
|
|
}
|
|
|
|
|
2017-07-13 07:14:50 +08:00
|
|
|
function _wrap_build()
|
2014-06-19 05:55:58 +08:00
|
|
|
{
|
|
|
|
local start_time=$(date +"%s")
|
2017-07-13 07:14:50 +08:00
|
|
|
"$@"
|
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))
|
2014-06-24 05:05:06 +08:00
|
|
|
local ncolors=$(tput colors 2>/dev/null)
|
|
|
|
if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
|
2015-05-15 22:12:53 +08:00
|
|
|
color_failed=$'\E'"[0;31m"
|
|
|
|
color_success=$'\E'"[0;32m"
|
|
|
|
color_reset=$'\E'"[00m"
|
2014-06-24 05:05:06 +08:00
|
|
|
else
|
|
|
|
color_failed=""
|
|
|
|
color_success=""
|
|
|
|
color_reset=""
|
|
|
|
fi
|
2014-06-19 05:55:58 +08:00
|
|
|
echo
|
|
|
|
if [ $ret -eq 0 ] ; then
|
2017-07-13 07:14:50 +08:00
|
|
|
echo -n "${color_success}#### build completed successfully "
|
2014-06-19 05:55:58 +08:00
|
|
|
else
|
2017-07-13 07:14:50 +08:00
|
|
|
echo -n "${color_failed}#### failed to build some targets "
|
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
|
2015-05-15 22:12:53 +08:00
|
|
|
echo " ####${color_reset}"
|
2014-06-19 05:55:58 +08:00
|
|
|
echo
|
|
|
|
return $ret
|
|
|
|
}
|
|
|
|
|
2017-07-13 07:14:50 +08:00
|
|
|
function make()
|
|
|
|
{
|
2017-07-29 04:00:13 +08:00
|
|
|
_wrap_build $(get_make_command "$@") "$@"
|
2017-07-13 07:14:50 +08:00
|
|
|
}
|
|
|
|
|
2015-10-01 05:10:48 +08:00
|
|
|
function provision()
|
|
|
|
{
|
|
|
|
if [ ! "$ANDROID_PRODUCT_OUT" ]; then
|
|
|
|
echo "Couldn't locate output files. Try running 'lunch' first." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
if [ ! -e "$ANDROID_PRODUCT_OUT/provision-device" ]; then
|
|
|
|
echo "There is no provisioning script for the device." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if user really wants to do this.
|
|
|
|
if [ "$1" = "--no-confirmation" ]; then
|
|
|
|
shift 1
|
|
|
|
else
|
|
|
|
echo "This action will reflash your device."
|
|
|
|
echo ""
|
|
|
|
echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED."
|
|
|
|
echo ""
|
2015-11-11 02:41:15 +08:00
|
|
|
echo -n "Are you sure you want to do this (yes/no)? "
|
|
|
|
read
|
2015-10-01 05:10:48 +08:00
|
|
|
if [[ "${REPLY}" != "yes" ]] ; then
|
|
|
|
echo "Not taking any action. Exiting." >&2
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
"$ANDROID_PRODUCT_OUT/provision-device" "$@"
|
|
|
|
}
|
|
|
|
|
2017-08-24 03:03:04 +08:00
|
|
|
function atest()
|
|
|
|
{
|
|
|
|
# TODO (sbasi): Replace this to be a destination in the build out when & if
|
|
|
|
# atest is built by the build system. (This will be necessary if it ever
|
|
|
|
# depends on external pip projects).
|
|
|
|
"$(gettop)"/tools/tradefederation/core/atest/atest.py "$@"
|
|
|
|
}
|
|
|
|
|
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-10-07 00:51:58 +08:00
|
|
|
for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
|
2015-08-21 04:55:45 +08:00
|
|
|
`test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
|
|
|
|
`test -d product && find -L product -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
|
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
|