Scott Anderson | 1a5fc95 | 2012-03-07 17:15:06 -0800 | [diff] [blame] | 1 | function hmm() { |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 2 | cat <<EOF |
Jeff Gaston | c6dfc4e | 2017-05-30 17:12:37 -0700 | [diff] [blame] | 3 | |
| 4 | Run "m help" for help with the build system itself. |
| 5 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 6 | Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment: |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 7 | - lunch: lunch <product_name>-<build_variant> |
| 8 | Selects <product_name> as the product to build, and <build_variant> as the variant to |
| 9 | build, and stores those selections in the environment to be read by subsequent |
| 10 | invocations of 'm' etc. |
| 11 | - tapas: tapas [<App1> <App2> ...] [arm|x86|mips|arm64|x86_64|mips64] [eng|userdebug|user] |
Anton Hansson | ece9c48 | 2019-02-04 18:15:39 +0000 | [diff] [blame^] | 12 | - croot: Changes directory to the top of the tree, or a subdirectory thereof. |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 13 | - m: Makes from the top of the tree. |
| 14 | - mm: Builds all of the modules in the current directory, but not their dependencies. |
| 15 | - mmm: Builds all of the modules in the supplied directories, but not their dependencies. |
| 16 | To limit the modules being built use the syntax: mmm dir/:target1,target2. |
| 17 | - mma: Builds all of the modules in the current directory, and their dependencies. |
| 18 | - mmma: Builds all of the modules in the supplied directories, and their dependencies. |
| 19 | - provision: Flash device with all required partitions. Options will be passed on to fastboot. |
| 20 | - cgrep: Greps on all local C/C++ files. |
| 21 | - ggrep: Greps on all local Gradle files. |
| 22 | - jgrep: Greps on all local Java files. |
| 23 | - resgrep: Greps on all local res/*.xml files. |
| 24 | - mangrep: Greps on all local AndroidManifest.xml files. |
| 25 | - mgrep: Greps on all local Makefiles files. |
| 26 | - sepgrep: Greps on all local sepolicy files. |
| 27 | - sgrep: Greps on all local source files. |
| 28 | - godir: Go to the directory containing a file. |
| 29 | - allmod: List all modules. |
| 30 | - gomod: Go to the directory containing a module. |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 31 | - pathmod: Get the directory containing a module. |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 32 | - refreshmod: Refresh list of modules for allmod/gomod. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 33 | |
Roland Levillain | 3934192 | 2015-10-20 12:48:19 +0100 | [diff] [blame] | 34 | Environment options: |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 35 | - SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that |
| 36 | ASAN_OPTIONS=detect_leaks=0 will be set by default until the |
| 37 | build is leak-check clean. |
Sasha Smundak | 9f27cc0 | 2019-01-31 13:25:31 -0800 | [diff] [blame] | 38 | - ANDROID_QUIET_BUILD: set to 'true' to display only the essential messages. |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 39 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 40 | Look at the source to view more functions. The complete list is: |
| 41 | EOF |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 42 | local T=$(gettop) |
| 43 | local A="" |
| 44 | local i |
Jacky Cao | 89483b8 | 2015-05-15 22:12:53 +0800 | [diff] [blame] | 45 | for i in `cat $T/build/envsetup.sh | sed -n "/^[[:blank:]]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 46 | A="$A $i" |
| 47 | done |
| 48 | echo $A |
| 49 | } |
| 50 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 51 | # Get all the build variables needed by this script in a single call to the build system. |
| 52 | function build_build_var_cache() |
| 53 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 54 | local T=$(gettop) |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 55 | # Grep out the variable names from the script. |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 56 | 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' ' '`) |
| 57 | 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' ' '`) |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 58 | # Call the build system to dump the "<val>=<value>" pairs as a shell script. |
Steven Moreland | 0540296 | 2018-01-05 12:13:11 -0800 | [diff] [blame] | 59 | build_dicts_script=`\builtin cd $T; build/soong/soong_ui.bash --dumpvars-mode \ |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 60 | --vars="${cached_vars[*]}" \ |
| 61 | --abs-vars="${cached_abs_vars[*]}" \ |
Dan Willemsen | af88c41 | 2017-07-14 11:29:44 -0700 | [diff] [blame] | 62 | --var-prefix=var_cache_ \ |
| 63 | --abs-var-prefix=abs_var_cache_` |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 64 | local ret=$? |
| 65 | if [ $ret -ne 0 ] |
| 66 | then |
| 67 | unset build_dicts_script |
| 68 | return $ret |
| 69 | fi |
Dan Willemsen | af88c41 | 2017-07-14 11:29:44 -0700 | [diff] [blame] | 70 | # Execute the script to store the "<val>=<value>" pairs as shell variables. |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 71 | eval "$build_dicts_script" |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 72 | ret=$? |
Ying Wang | f0cb397 | 2016-03-04 13:56:23 -0800 | [diff] [blame] | 73 | unset build_dicts_script |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 74 | if [ $ret -ne 0 ] |
| 75 | then |
| 76 | return $ret |
| 77 | fi |
| 78 | BUILD_VAR_CACHE_READY="true" |
| 79 | } |
| 80 | |
Ying Wang | f0cb397 | 2016-03-04 13:56:23 -0800 | [diff] [blame] | 81 | # Delete the build var cache, so that we can still call into the build system |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 82 | # to get build variables not listed in this script. |
| 83 | function destroy_build_var_cache() |
| 84 | { |
| 85 | unset BUILD_VAR_CACHE_READY |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 86 | local v |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 87 | for v in $cached_vars; do |
| 88 | unset var_cache_$v |
| 89 | done |
| 90 | unset cached_vars |
| 91 | for v in $cached_abs_vars; do |
| 92 | unset abs_var_cache_$v |
| 93 | done |
| 94 | unset cached_abs_vars |
| 95 | } |
| 96 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 97 | # Get the value of a build variable as an absolute path. |
| 98 | function get_abs_build_var() |
| 99 | { |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 100 | if [ "$BUILD_VAR_CACHE_READY" = "true" ] |
| 101 | then |
Vishwath Mohan | 7d35f00 | 2016-03-11 10:00:40 -0800 | [diff] [blame] | 102 | eval "echo \"\${abs_var_cache_$1}\"" |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 103 | return |
| 104 | fi |
| 105 | |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 106 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 107 | if [ ! "$T" ]; then |
| 108 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 109 | return |
| 110 | fi |
Dan Willemsen | af88c41 | 2017-07-14 11:29:44 -0700 | [diff] [blame] | 111 | (\cd $T; build/soong/soong_ui.bash --dumpvar-mode --abs $1) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | # Get the exact value of a build variable. |
| 115 | function get_build_var() |
| 116 | { |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 117 | if [ "$BUILD_VAR_CACHE_READY" = "true" ] |
| 118 | then |
Vishwath Mohan | 7d35f00 | 2016-03-11 10:00:40 -0800 | [diff] [blame] | 119 | eval "echo \"\${var_cache_$1}\"" |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 120 | return |
| 121 | fi |
| 122 | |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 123 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 124 | if [ ! "$T" ]; then |
| 125 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 126 | return |
| 127 | fi |
Dan Willemsen | af88c41 | 2017-07-14 11:29:44 -0700 | [diff] [blame] | 128 | (\cd $T; build/soong/soong_ui.bash --dumpvar-mode $1) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | # check to see if the supplied product is one we can build |
| 132 | function check_product() |
| 133 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 134 | local T=$(gettop) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 135 | if [ ! "$T" ]; then |
| 136 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 137 | return |
| 138 | fi |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 139 | TARGET_PRODUCT=$1 \ |
| 140 | TARGET_BUILD_VARIANT= \ |
| 141 | TARGET_BUILD_TYPE= \ |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 142 | TARGET_BUILD_APPS= \ |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 143 | get_build_var TARGET_DEVICE > /dev/null |
| 144 | # hide successful answers, but allow the errors to show |
| 145 | } |
| 146 | |
| 147 | VARIANT_CHOICES=(user userdebug eng) |
| 148 | |
| 149 | # check to see if the supplied variant is valid |
| 150 | function check_variant() |
| 151 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 152 | local v |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 153 | for v in ${VARIANT_CHOICES[@]} |
| 154 | do |
| 155 | if [ "$v" = "$1" ] |
| 156 | then |
| 157 | return 0 |
| 158 | fi |
| 159 | done |
| 160 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 161 | } |
| 162 | |
| 163 | function setpaths() |
| 164 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 165 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 166 | if [ ! "$T" ]; then |
| 167 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 168 | return |
| 169 | fi |
| 170 | |
| 171 | ################################################################## |
| 172 | # # |
| 173 | # Read me before you modify this code # |
| 174 | # # |
| 175 | # This function sets ANDROID_BUILD_PATHS to what it is adding # |
| 176 | # to PATH, and the next time it is run, it removes that from # |
| 177 | # PATH. This is required so lunch can be run more than once # |
| 178 | # and still have working paths. # |
| 179 | # # |
| 180 | ################################################################## |
| 181 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 182 | # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces |
| 183 | # due to "C:\Program Files" being in the path. |
| 184 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 185 | # out with the old |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 186 | if [ -n "$ANDROID_BUILD_PATHS" ] ; then |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 187 | export PATH=${PATH/$ANDROID_BUILD_PATHS/} |
| 188 | fi |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 189 | if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 190 | export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/} |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 191 | # strip leading ':', if any |
| 192 | export PATH=${PATH/:%/} |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 193 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 194 | |
| 195 | # and in with the new |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 196 | local prebuiltdir=$(getprebuilt) |
| 197 | local gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS) |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 198 | |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 199 | # defined in core/config.mk |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 200 | local targetgccversion=$(get_build_var TARGET_GCC_VERSION) |
| 201 | local targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION) |
Ben Cheng | 1526670 | 2012-12-10 16:04:39 -0800 | [diff] [blame] | 202 | export TARGET_GCC_VERSION=$targetgccversion |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 203 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 204 | # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it. |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 205 | export ANDROID_TOOLCHAIN= |
| 206 | export ANDROID_TOOLCHAIN_2ND_ARCH= |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 207 | local ARCH=$(get_build_var TARGET_ARCH) |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 208 | local toolchaindir toolchaindir2= |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 209 | case $ARCH in |
Pavel Chupin | c1a5664 | 2013-08-23 16:49:21 +0400 | [diff] [blame] | 210 | x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 211 | ;; |
Pavel Chupin | fd82a49 | 2012-11-26 09:50:07 +0400 | [diff] [blame] | 212 | x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin |
| 213 | ;; |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 214 | arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 215 | ;; |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 216 | arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin; |
Colin Cross | 03b424a | 2014-05-22 11:57:43 -0700 | [diff] [blame] | 217 | toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin |
Ben Cheng | db4fc20 | 2013-10-04 16:02:59 -0700 | [diff] [blame] | 218 | ;; |
Duane Sand | 3c4fcd8 | 2014-07-22 14:34:00 -0700 | [diff] [blame] | 219 | mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin |
Serban Constantinescu | 9b68fb2 | 2014-01-14 10:33:53 +0000 | [diff] [blame] | 220 | ;; |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 221 | *) |
| 222 | echo "Can't find toolchain for unknown architecture: $ARCH" |
| 223 | toolchaindir=xxxxxxxxx |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 224 | ;; |
| 225 | esac |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 226 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 227 | export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 228 | fi |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 229 | |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 230 | if [ "$toolchaindir2" -a -d "$gccprebuiltdir/$toolchaindir2" ]; then |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 231 | export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2 |
| 232 | fi |
| 233 | |
Jeff Vander Stoep | 5f50f05 | 2015-06-12 09:56:39 -0700 | [diff] [blame] | 234 | export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin |
Yueyao Zhu | efc786a | 2017-04-07 14:11:54 -0700 | [diff] [blame] | 235 | |
| 236 | # add kernel specific binaries |
| 237 | case $(uname -s) in |
| 238 | Linux) |
| 239 | export ANDROID_DEV_SCRIPTS=$ANDROID_DEV_SCRIPTS:$T/prebuilts/misc/linux-x86/dtc:$T/prebuilts/misc/linux-x86/libufdt |
| 240 | ;; |
| 241 | *) |
| 242 | ;; |
| 243 | esac |
| 244 | |
Torne (Richard Coles) | 0091bae | 2017-10-03 16:31:18 -0400 | [diff] [blame] | 245 | ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN |
| 246 | if [ -n "$ANDROID_TOOLCHAIN_2ND_ARCH" ]; then |
| 247 | ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ANDROID_TOOLCHAIN_2ND_ARCH |
| 248 | fi |
| 249 | ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS:$ANDROID_DEV_SCRIPTS: |
| 250 | export ANDROID_BUILD_PATHS |
David 'Digit' Turner | 94d16e5 | 2014-05-05 16:13:50 +0200 | [diff] [blame] | 251 | |
| 252 | # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH |
| 253 | # to ensure that the corresponding 'emulator' binaries are used. |
| 254 | case $(uname -s) in |
| 255 | Darwin) |
| 256 | ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64 |
| 257 | ;; |
| 258 | Linux) |
| 259 | ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64 |
| 260 | ;; |
| 261 | *) |
| 262 | ANDROID_EMULATOR_PREBUILTS= |
| 263 | ;; |
| 264 | esac |
| 265 | if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then |
Christopher Ferris | 7110f24 | 2014-05-20 13:56:00 -0700 | [diff] [blame] | 266 | ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS: |
David 'Digit' Turner | 94d16e5 | 2014-05-05 16:13:50 +0200 | [diff] [blame] | 267 | export ANDROID_EMULATOR_PREBUILTS |
| 268 | fi |
| 269 | |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 270 | export PATH=$ANDROID_BUILD_PATHS$PATH |
Jim Tang | 22f4c32 | 2018-12-17 15:21:53 +0800 | [diff] [blame] | 271 | |
| 272 | # out with the duplicate old |
| 273 | if [ -n $ANDROID_PYTHONPATH ]; then |
| 274 | export PYTHONPATH=${PYTHONPATH//$ANDROID_PYTHONPATH/} |
| 275 | fi |
| 276 | # and in with the new |
| 277 | export ANDROID_PYTHONPATH=$T/development/python-packages: |
| 278 | export PYTHONPATH=$ANDROID_PYTHONPATH$PYTHONPATH |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 279 | |
Colin Cross | e97e693 | 2017-06-30 16:01:45 -0700 | [diff] [blame] | 280 | export ANDROID_JAVA_HOME=$(get_abs_build_var ANDROID_JAVA_HOME) |
| 281 | export JAVA_HOME=$ANDROID_JAVA_HOME |
| 282 | export ANDROID_JAVA_TOOLCHAIN=$(get_abs_build_var ANDROID_JAVA_TOOLCHAIN) |
| 283 | export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN: |
| 284 | export PATH=$ANDROID_PRE_BUILD_PATHS$PATH |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 285 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 286 | unset ANDROID_PRODUCT_OUT |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 287 | export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT) |
| 288 | export OUT=$ANDROID_PRODUCT_OUT |
| 289 | |
Jeff Brown | 8fd5cce | 2011-03-24 17:03:06 -0700 | [diff] [blame] | 290 | unset ANDROID_HOST_OUT |
| 291 | export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT) |
| 292 | |
Simran Basi | dd050ed | 2017-02-13 13:46:48 -0800 | [diff] [blame] | 293 | unset ANDROID_HOST_OUT_TESTCASES |
| 294 | export ANDROID_HOST_OUT_TESTCASES=$(get_abs_build_var HOST_OUT_TESTCASES) |
| 295 | |
| 296 | unset ANDROID_TARGET_OUT_TESTCASES |
| 297 | export ANDROID_TARGET_OUT_TESTCASES=$(get_abs_build_var TARGET_OUT_TESTCASES) |
| 298 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 299 | # needed for building linux on MacOS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 300 | # TODO: fix the path |
| 301 | #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include |
| 302 | } |
| 303 | |
| 304 | function printconfig() |
| 305 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 306 | local T=$(gettop) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 307 | if [ ! "$T" ]; then |
| 308 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 309 | return |
| 310 | fi |
| 311 | get_build_var report_config |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | function set_stuff_for_environment() |
| 315 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 316 | setpaths |
| 317 | set_sequence_number |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 318 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 319 | export ANDROID_BUILD_TOP=$(gettop) |
Ben Cheng | aac3f81 | 2013-08-13 14:38:15 -0700 | [diff] [blame] | 320 | # With this environment variable new GCC can apply colors to warnings/errors |
| 321 | export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 322 | export ASAN_OPTIONS=detect_leaks=0 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | function set_sequence_number() |
| 326 | { |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 327 | export BUILD_ENV_SEQUENCE_NUMBER=13 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Makoto Onuki | da97106 | 2018-06-18 10:15:19 -0700 | [diff] [blame] | 330 | # Takes a command name, and check if it's in ENVSETUP_NO_COMPLETION or not. |
| 331 | function should_add_completion() { |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 332 | local cmd="$(basename $1| sed 's/_completion//' |sed 's/\.\(.*\)*sh$//')" |
Makoto Onuki | da97106 | 2018-06-18 10:15:19 -0700 | [diff] [blame] | 333 | case :"$ENVSETUP_NO_COMPLETION": in |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 334 | *:"$cmd":*) |
| 335 | return 1 |
| 336 | ;; |
Makoto Onuki | da97106 | 2018-06-18 10:15:19 -0700 | [diff] [blame] | 337 | esac |
| 338 | return 0 |
| 339 | } |
| 340 | |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 341 | function addcompletions() |
| 342 | { |
| 343 | local T dir f |
| 344 | |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 345 | # Keep us from trying to run in something that's neither bash nor zsh. |
| 346 | if [ -z "$BASH_VERSION" -a -z "$ZSH_VERSION" ]; then |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 347 | return |
| 348 | fi |
| 349 | |
| 350 | # Keep us from trying to run in bash that's too old. |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 351 | if [ -n "$BASH_VERSION" -a ${BASH_VERSINFO[0]} -lt 3 ]; then |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 352 | return |
| 353 | fi |
| 354 | |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 355 | local completion_files=( |
| 356 | system/core/adb/adb.bash |
| 357 | system/core/fastboot/fastboot.bash |
| 358 | tools/tradefederation/core/atest/atest_completion.sh |
| 359 | ) |
Makoto Onuki | da97106 | 2018-06-18 10:15:19 -0700 | [diff] [blame] | 360 | # Completion can be disabled selectively to allow users to use non-standard completion. |
| 361 | # e.g. |
| 362 | # ENVSETUP_NO_COMPLETION=adb # -> disable adb completion |
| 363 | # ENVSETUP_NO_COMPLETION=adb:bit # -> disable adb and bit completion |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 364 | for f in ${completion_files[*]}; do |
| 365 | if [ -f "$f" ] && should_add_completion "$f"; then |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 366 | . $f |
Elliott Hughes | ce18dd4 | 2018-04-03 13:49:48 -0700 | [diff] [blame] | 367 | fi |
| 368 | done |
Joe Onorato | 002a6c7 | 2016-10-20 16:39:49 -0700 | [diff] [blame] | 369 | |
Makoto Onuki | da97106 | 2018-06-18 10:15:19 -0700 | [diff] [blame] | 370 | if should_add_completion bit ; then |
| 371 | complete -C "bit --tab" bit |
| 372 | fi |
Anton Hansson | ece9c48 | 2019-02-04 18:15:39 +0000 | [diff] [blame^] | 373 | if [ -z "$ZSH_VERSION" ]; then |
| 374 | # Doesn't work in zsh. |
| 375 | complete -o nospace -F _croot croot |
| 376 | fi |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 377 | complete -F _lunch lunch |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 378 | |
dimitry | 73b8481 | 2018-12-11 18:06:00 +0100 | [diff] [blame] | 379 | complete -F _complete_android_module_names gomod |
| 380 | complete -F _complete_android_module_names m |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 381 | } |
| 382 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 383 | function choosetype() |
| 384 | { |
| 385 | echo "Build type choices are:" |
| 386 | echo " 1. release" |
| 387 | echo " 2. debug" |
| 388 | echo |
| 389 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 390 | local DEFAULT_NUM DEFAULT_VALUE |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 391 | DEFAULT_NUM=1 |
| 392 | DEFAULT_VALUE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 393 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 394 | export TARGET_BUILD_TYPE= |
| 395 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 396 | while [ -z $TARGET_BUILD_TYPE ] |
| 397 | do |
| 398 | echo -n "Which would you like? ["$DEFAULT_NUM"] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 399 | if [ -z "$1" ] ; then |
| 400 | read ANSWER |
| 401 | else |
| 402 | echo $1 |
| 403 | ANSWER=$1 |
| 404 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 405 | case $ANSWER in |
| 406 | "") |
| 407 | export TARGET_BUILD_TYPE=$DEFAULT_VALUE |
| 408 | ;; |
| 409 | 1) |
| 410 | export TARGET_BUILD_TYPE=release |
| 411 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 412 | release) |
| 413 | export TARGET_BUILD_TYPE=release |
| 414 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 415 | 2) |
| 416 | export TARGET_BUILD_TYPE=debug |
| 417 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 418 | debug) |
| 419 | export TARGET_BUILD_TYPE=debug |
| 420 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 421 | *) |
| 422 | echo |
| 423 | echo "I didn't understand your response. Please try again." |
| 424 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 425 | ;; |
| 426 | esac |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 427 | if [ -n "$1" ] ; then |
| 428 | break |
| 429 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 430 | done |
| 431 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 432 | build_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 433 | set_stuff_for_environment |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 434 | destroy_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 435 | } |
| 436 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 437 | # |
| 438 | # This function isn't really right: It chooses a TARGET_PRODUCT |
| 439 | # based on the list of boards. Usually, that gets you something |
| 440 | # that kinda works with a generic product, but really, you should |
| 441 | # pick a product by name. |
| 442 | # |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 443 | function chooseproduct() |
| 444 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 445 | local default_value |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 446 | if [ "x$TARGET_PRODUCT" != x ] ; then |
| 447 | default_value=$TARGET_PRODUCT |
| 448 | else |
Ying Wang | 0a76df5 | 2015-06-08 11:57:26 -0700 | [diff] [blame] | 449 | default_value=aosp_arm |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 450 | fi |
| 451 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 452 | export TARGET_BUILD_APPS= |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 453 | export TARGET_PRODUCT= |
| 454 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 455 | while [ -z "$TARGET_PRODUCT" ] |
| 456 | do |
Joe Onorato | 8849aed | 2009-04-29 15:56:47 -0700 | [diff] [blame] | 457 | echo -n "Which product would you like? [$default_value] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 458 | if [ -z "$1" ] ; then |
| 459 | read ANSWER |
| 460 | else |
| 461 | echo $1 |
| 462 | ANSWER=$1 |
| 463 | fi |
| 464 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 465 | if [ -z "$ANSWER" ] ; then |
| 466 | export TARGET_PRODUCT=$default_value |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 467 | else |
| 468 | if check_product $ANSWER |
| 469 | then |
| 470 | export TARGET_PRODUCT=$ANSWER |
| 471 | else |
| 472 | echo "** Not a valid product: $ANSWER" |
| 473 | fi |
| 474 | fi |
| 475 | if [ -n "$1" ] ; then |
| 476 | break |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 477 | fi |
| 478 | done |
| 479 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 480 | build_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 481 | set_stuff_for_environment |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 482 | destroy_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 483 | } |
| 484 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 485 | function choosevariant() |
| 486 | { |
| 487 | echo "Variant choices are:" |
| 488 | local index=1 |
| 489 | local v |
| 490 | for v in ${VARIANT_CHOICES[@]} |
| 491 | do |
| 492 | # The product name is the name of the directory containing |
| 493 | # the makefile we found, above. |
| 494 | echo " $index. $v" |
| 495 | index=$(($index+1)) |
| 496 | done |
| 497 | |
| 498 | local default_value=eng |
| 499 | local ANSWER |
| 500 | |
| 501 | export TARGET_BUILD_VARIANT= |
| 502 | while [ -z "$TARGET_BUILD_VARIANT" ] |
| 503 | do |
| 504 | echo -n "Which would you like? [$default_value] " |
| 505 | if [ -z "$1" ] ; then |
| 506 | read ANSWER |
| 507 | else |
| 508 | echo $1 |
| 509 | ANSWER=$1 |
| 510 | fi |
| 511 | |
| 512 | if [ -z "$ANSWER" ] ; then |
| 513 | export TARGET_BUILD_VARIANT=$default_value |
| 514 | elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then |
| 515 | if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 516 | export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 517 | fi |
| 518 | else |
| 519 | if check_variant $ANSWER |
| 520 | then |
| 521 | export TARGET_BUILD_VARIANT=$ANSWER |
| 522 | else |
| 523 | echo "** Not a valid variant: $ANSWER" |
| 524 | fi |
| 525 | fi |
| 526 | if [ -n "$1" ] ; then |
| 527 | break |
| 528 | fi |
| 529 | done |
| 530 | } |
| 531 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 532 | function choosecombo() |
| 533 | { |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 534 | choosetype $1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 535 | |
| 536 | echo |
| 537 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 538 | chooseproduct $2 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 539 | |
| 540 | echo |
| 541 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 542 | choosevariant $3 |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 543 | |
| 544 | echo |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 545 | build_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 546 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 547 | printconfig |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 548 | destroy_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 549 | } |
| 550 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 551 | # Clear this variable. It will be built up again when the vendorsetup.sh |
| 552 | # files are included at the end of this file. |
| 553 | unset LUNCH_MENU_CHOICES |
| 554 | function add_lunch_combo() |
| 555 | { |
| 556 | local new_combo=$1 |
| 557 | local c |
| 558 | for c in ${LUNCH_MENU_CHOICES[@]} ; do |
| 559 | if [ "$new_combo" = "$c" ] ; then |
| 560 | return |
| 561 | fi |
| 562 | done |
| 563 | LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo) |
| 564 | } |
| 565 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 566 | function print_lunch_menu() |
| 567 | { |
| 568 | local uname=$(uname) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 569 | echo |
| 570 | echo "You're building on" $uname |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 571 | echo |
| 572 | echo "Lunch menu... pick a combo:" |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 573 | |
| 574 | local i=1 |
| 575 | local choice |
Dan Willemsen | af2e1f8 | 2018-04-04 15:41:41 -0700 | [diff] [blame] | 576 | for choice in $(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 577 | do |
| 578 | echo " $i. $choice" |
| 579 | i=$(($i+1)) |
| 580 | done |
| 581 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 582 | echo |
| 583 | } |
| 584 | |
| 585 | function lunch() |
| 586 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 587 | local answer |
| 588 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 589 | if [ "$1" ] ; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 590 | answer=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 591 | else |
| 592 | print_lunch_menu |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 593 | echo -n "Which would you like? [aosp_arm-eng] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 594 | read answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 595 | fi |
| 596 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 597 | local selection= |
| 598 | |
| 599 | if [ -z "$answer" ] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 600 | then |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 601 | selection=aosp_arm-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 602 | elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") |
| 603 | then |
Dan Willemsen | af2e1f8 | 2018-04-04 15:41:41 -0700 | [diff] [blame] | 604 | local choices=($(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES)) |
| 605 | if [ $answer -le ${#choices[@]} ] |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 606 | then |
Jim Tang | 0e3397b | 2018-10-03 18:25:50 +0800 | [diff] [blame] | 607 | # array in zsh starts from 1 instead of 0. |
| 608 | if [ -n "$ZSH_VERSION" ] |
| 609 | then |
| 610 | selection=${choices[$(($answer))]} |
| 611 | else |
| 612 | selection=${choices[$(($answer-1))]} |
| 613 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 614 | fi |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 615 | else |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 616 | selection=$answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 617 | fi |
| 618 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 619 | export TARGET_BUILD_APPS= |
| 620 | |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 621 | local product variant_and_version variant version |
| 622 | |
| 623 | product=${selection%%-*} # Trim everything after first dash |
| 624 | variant_and_version=${selection#*-} # Trim everything up to first dash |
| 625 | if [ "$variant_and_version" != "$selection" ]; then |
| 626 | variant=${variant_and_version%%-*} |
| 627 | if [ "$variant" != "$variant_and_version" ]; then |
| 628 | version=${variant_and_version#*-} |
| 629 | fi |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 630 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 631 | |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 632 | if [ -z "$product" ] |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 633 | then |
| 634 | echo |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 635 | echo "Invalid lunch combo: $selection" |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 636 | return 1 |
| 637 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 638 | |
Colin Cross | 8873713 | 2017-03-21 17:41:03 -0700 | [diff] [blame] | 639 | TARGET_PRODUCT=$product \ |
| 640 | TARGET_BUILD_VARIANT=$variant \ |
| 641 | TARGET_PLATFORM_VERSION=$version \ |
| 642 | build_build_var_cache |
| 643 | if [ $? -ne 0 ] |
| 644 | then |
| 645 | return 1 |
| 646 | fi |
| 647 | |
| 648 | export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT) |
| 649 | export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT) |
Colin Cross | b105e36 | 2017-05-01 14:21:28 -0700 | [diff] [blame] | 650 | if [ -n "$version" ]; then |
| 651 | export TARGET_PLATFORM_VERSION=$(get_build_var TARGET_PLATFORM_VERSION) |
| 652 | else |
| 653 | unset TARGET_PLATFORM_VERSION |
| 654 | fi |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 655 | export TARGET_BUILD_TYPE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 656 | |
| 657 | echo |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 658 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 659 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 660 | printconfig |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 661 | destroy_build_var_cache |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 662 | } |
| 663 | |
Dan Willemsen | af2e1f8 | 2018-04-04 15:41:41 -0700 | [diff] [blame] | 664 | unset COMMON_LUNCH_CHOICES_CACHE |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 665 | # Tab completion for lunch. |
| 666 | function _lunch() |
| 667 | { |
| 668 | local cur prev opts |
| 669 | COMPREPLY=() |
| 670 | cur="${COMP_WORDS[COMP_CWORD]}" |
| 671 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 672 | |
Dan Willemsen | af2e1f8 | 2018-04-04 15:41:41 -0700 | [diff] [blame] | 673 | if [ -z "$COMMON_LUNCH_CHOICES_CACHE" ]; then |
| 674 | COMMON_LUNCH_CHOICES_CACHE=$(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES) |
| 675 | fi |
| 676 | |
| 677 | COMPREPLY=( $(compgen -W "${COMMON_LUNCH_CHOICES_CACHE}" -- ${cur}) ) |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 678 | return 0 |
| 679 | } |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 680 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 681 | # Configures the build to build unbundled apps. |
Doug Zongker | 0d8179e | 2014-04-16 11:34:34 -0700 | [diff] [blame] | 682 | # Run tapas with one or more app names (from LOCAL_PACKAGE_NAME) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 683 | function tapas() |
| 684 | { |
Jeff Gaston | 9fb05d8 | 2017-08-21 18:27:00 -0700 | [diff] [blame] | 685 | local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)" |
Dan Willemsen | dd3a273 | 2018-01-08 15:26:16 -0800 | [diff] [blame] | 686 | local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|arm64|x86_64|mips64)$' | xargs)" |
Doug Zongker | 0d8179e | 2014-04-16 11:34:34 -0700 | [diff] [blame] | 687 | local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)" |
Jeff Hamilton | 5069bd6 | 2014-09-04 21:28:00 -0700 | [diff] [blame] | 688 | local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)" |
Dan Willemsen | dd3a273 | 2018-01-08 15:26:16 -0800 | [diff] [blame] | 689 | 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)" |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 690 | |
Jeff Gaston | 9fb05d8 | 2017-08-21 18:27:00 -0700 | [diff] [blame] | 691 | if [ "$showHelp" != "" ]; then |
| 692 | $(gettop)/build/make/tapasHelp.sh |
| 693 | return |
| 694 | fi |
| 695 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 696 | if [ $(echo $arch | wc -w) -gt 1 ]; then |
| 697 | echo "tapas: Error: Multiple build archs supplied: $arch" |
| 698 | return |
| 699 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 700 | if [ $(echo $variant | wc -w) -gt 1 ]; then |
| 701 | echo "tapas: Error: Multiple build variants supplied: $variant" |
| 702 | return |
| 703 | fi |
Jeff Hamilton | 5069bd6 | 2014-09-04 21:28:00 -0700 | [diff] [blame] | 704 | if [ $(echo $density | wc -w) -gt 1 ]; then |
| 705 | echo "tapas: Error: Multiple densities supplied: $density" |
| 706 | return |
| 707 | fi |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 708 | |
Ying Wang | 0a76df5 | 2015-06-08 11:57:26 -0700 | [diff] [blame] | 709 | local product=aosp_arm |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 710 | case $arch in |
Ying Wang | 0a76df5 | 2015-06-08 11:57:26 -0700 | [diff] [blame] | 711 | x86) product=aosp_x86;; |
| 712 | mips) product=aosp_mips;; |
Ying Wang | b541ab6 | 2014-05-29 17:57:40 -0700 | [diff] [blame] | 713 | arm64) product=aosp_arm64;; |
| 714 | x86_64) product=aosp_x86_64;; |
| 715 | mips64) product=aosp_mips64;; |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 716 | esac |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 717 | if [ -z "$variant" ]; then |
| 718 | variant=eng |
| 719 | fi |
Ying Wang | c048c9b | 2010-06-24 15:08:33 -0700 | [diff] [blame] | 720 | if [ -z "$apps" ]; then |
| 721 | apps=all |
| 722 | fi |
Justin Morey | 29d225c | 2014-11-04 13:35:51 -0600 | [diff] [blame] | 723 | if [ -z "$density" ]; then |
| 724 | density=alldpi |
| 725 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 726 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 727 | export TARGET_PRODUCT=$product |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 728 | export TARGET_BUILD_VARIANT=$variant |
Jeff Hamilton | 5069bd6 | 2014-09-04 21:28:00 -0700 | [diff] [blame] | 729 | export TARGET_BUILD_DENSITY=$density |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 730 | export TARGET_BUILD_TYPE=release |
| 731 | export TARGET_BUILD_APPS=$apps |
| 732 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 733 | build_build_var_cache |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 734 | set_stuff_for_environment |
| 735 | printconfig |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 736 | destroy_build_var_cache |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 737 | } |
| 738 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 739 | function gettop |
| 740 | { |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 741 | local TOPFILE=build/make/core/envsetup.mk |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 742 | if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then |
Brian Carlstrom | a5c4f17 | 2014-09-12 00:33:25 -0700 | [diff] [blame] | 743 | # The following circumlocution ensures we remove symlinks from TOP. |
| 744 | (cd $TOP; PWD= /bin/pwd) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 745 | else |
| 746 | if [ -f $TOPFILE ] ; then |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 747 | # The following circumlocution (repeated below as well) ensures |
| 748 | # that we record the true directory name and not one that is |
| 749 | # faked up with symlink names. |
| 750 | PWD= /bin/pwd |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 751 | else |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 752 | local HERE=$PWD |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 753 | local T= |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 754 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 755 | \cd .. |
synergy | b112a40 | 2013-07-05 19:47:47 -0700 | [diff] [blame] | 756 | T=`PWD= /bin/pwd -P` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 757 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 758 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 759 | if [ -f "$T/$TOPFILE" ]; then |
| 760 | echo $T |
| 761 | fi |
| 762 | fi |
| 763 | fi |
| 764 | } |
| 765 | |
| 766 | function m() |
| 767 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 768 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 769 | if [ "$T" ]; then |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 770 | _wrap_build $T/build/soong/soong_ui.bash --make-mode $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 771 | else |
| 772 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 773 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 774 | fi |
| 775 | } |
| 776 | |
| 777 | function findmakefile() |
| 778 | { |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 779 | local TOPFILE=build/make/core/envsetup.mk |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 780 | local HERE=$PWD |
Jaewoong Jung | b6112cd | 2019-01-02 13:36:48 -0800 | [diff] [blame] | 781 | if [ "$1" ]; then |
| 782 | \cd $1 |
| 783 | fi; |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 784 | local T= |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 785 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 11b15b1 | 2012-10-11 15:05:07 -0700 | [diff] [blame] | 786 | T=`PWD= /bin/pwd` |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 787 | if [ -f "$T/Android.mk" -o -f "$T/Android.bp" ]; then |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 788 | echo $T/Android.mk |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 789 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 790 | return |
| 791 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 792 | \cd .. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 793 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 794 | \cd $HERE |
Steven Moreland | 3b99ecf | 2018-06-13 15:31:59 -0700 | [diff] [blame] | 795 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | function mm() |
| 799 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 800 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 801 | # If we're sitting in the root of the build tree, just do a |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 802 | # normal build. |
| 803 | if [ -f build/soong/soong_ui.bash ]; then |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 804 | _wrap_build $T/build/soong/soong_ui.bash --make-mode $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 805 | else |
| 806 | # Find the closest Android.mk file. |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 807 | local M=$(findmakefile) |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 808 | local MODULES= |
| 809 | local GET_INSTALL_PATH= |
| 810 | local ARGS= |
Robert Greenwalt | 3c794d7 | 2009-07-15 15:07:44 -0700 | [diff] [blame] | 811 | # Remove the path to top as the makefilepath needs to be relative |
| 812 | local M=`echo $M|sed 's:'$T'/::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 813 | if [ ! "$T" ]; then |
| 814 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 815 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 816 | elif [ ! "$M" ]; then |
| 817 | echo "Couldn't locate a makefile from the current directory." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 818 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 819 | else |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 820 | local ARG |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 821 | for ARG in $@; do |
| 822 | case $ARG in |
| 823 | GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;; |
| 824 | esac |
| 825 | done |
| 826 | if [ -n "$GET_INSTALL_PATH" ]; then |
| 827 | MODULES= |
Dan Willemsen | 53e3899 | 2016-08-11 17:20:33 -0700 | [diff] [blame] | 828 | ARGS=GET-INSTALL-PATH-IN-$(dirname ${M}) |
| 829 | ARGS=${ARGS//\//-} |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 830 | else |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 831 | MODULES=MODULES-IN-$(dirname ${M}) |
| 832 | # Convert "/" to "-". |
| 833 | MODULES=${MODULES//\//-} |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 834 | ARGS=$@ |
| 835 | fi |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 836 | if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then |
| 837 | MODULES=tidy_only |
| 838 | fi |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 839 | ONE_SHOT_MAKEFILE=$M _wrap_build $T/build/soong/soong_ui.bash --make-mode $MODULES $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 840 | fi |
| 841 | fi |
| 842 | } |
| 843 | |
| 844 | function mmm() |
| 845 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 846 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 847 | if [ "$T" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 848 | local MAKEFILE= |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 849 | local MODULES= |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 850 | local MODULES_IN_PATHS= |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 851 | local ARGS= |
| 852 | local DIR TO_CHOP |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 853 | local DIR_MODULES |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 854 | local GET_INSTALL_PATH= |
Dan Willemsen | 53e3899 | 2016-08-11 17:20:33 -0700 | [diff] [blame] | 855 | local GET_INSTALL_PATHS= |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 856 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 857 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 858 | for DIR in $DIRS ; do |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 859 | DIR_MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 860 | DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'` |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 861 | # Remove the leading ./ and trailing / if any exists. |
| 862 | DIR=${DIR#./} |
| 863 | DIR=${DIR%/} |
Jaewoong Jung | b6112cd | 2019-01-02 13:36:48 -0800 | [diff] [blame] | 864 | local M |
| 865 | if [ "$DIR_MODULES" = "" ]; then |
| 866 | M=$(findmakefile $DIR) |
| 867 | else |
| 868 | # Only check the target directory if a module is specified. |
| 869 | if [ -f $DIR/Android.mk -o -f $DIR/Android.bp ]; then |
| 870 | local HERE=$PWD |
| 871 | cd $DIR |
| 872 | M=`PWD= /bin/pwd` |
| 873 | M=$M/Android.mk |
| 874 | cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 875 | fi |
Jaewoong Jung | b6112cd | 2019-01-02 13:36:48 -0800 | [diff] [blame] | 876 | fi |
| 877 | if [ "$M" ]; then |
| 878 | # Remove the path to top as the makefilepath needs to be relative |
| 879 | local M=`echo $M|sed 's:'$T'/::'` |
Colin Cross | 4bfae06 | 2016-08-31 17:22:36 -0700 | [diff] [blame] | 880 | if [ "$DIR_MODULES" = "" ]; then |
Jaewoong Jung | b6112cd | 2019-01-02 13:36:48 -0800 | [diff] [blame] | 881 | MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$(dirname ${M})" |
| 882 | GET_INSTALL_PATHS="$GET_INSTALL_PATHS GET-INSTALL-PATH-IN-$(dirname ${M})" |
Colin Cross | 4bfae06 | 2016-08-31 17:22:36 -0700 | [diff] [blame] | 883 | else |
| 884 | MODULES="$MODULES $DIR_MODULES" |
| 885 | fi |
Jaewoong Jung | b6112cd | 2019-01-02 13:36:48 -0800 | [diff] [blame] | 886 | MAKEFILE="$MAKEFILE $M" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 887 | else |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 888 | case $DIR in |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 889 | showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";; |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 890 | GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;; |
Abhinav1997 | a72a6e7 | 2015-10-18 20:25:48 +0200 | [diff] [blame] | 891 | *) if [ -d $DIR ]; then |
| 892 | echo "No Android.mk in $DIR."; |
| 893 | else |
| 894 | echo "Couldn't locate the directory $DIR"; |
| 895 | fi |
| 896 | return 1;; |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 897 | esac |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 898 | fi |
| 899 | done |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 900 | if [ -n "$GET_INSTALL_PATH" ]; then |
Dan Willemsen | 53e3899 | 2016-08-11 17:20:33 -0700 | [diff] [blame] | 901 | ARGS=${GET_INSTALL_PATHS//\//-} |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 902 | MODULES= |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 903 | MODULES_IN_PATHS= |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 904 | fi |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 905 | if [ "1" = "${WITH_TIDY_ONLY}" -o "true" = "${WITH_TIDY_ONLY}" ]; then |
| 906 | MODULES=tidy_only |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 907 | MODULES_IN_PATHS= |
Chih-Hung Hsieh | a9a55c7 | 2016-03-31 16:30:23 -0700 | [diff] [blame] | 908 | fi |
Colin Cross | 8642525 | 2016-05-26 15:32:15 -0700 | [diff] [blame] | 909 | # Convert "/" to "-". |
| 910 | MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 911 | ONE_SHOT_MAKEFILE="$MAKEFILE" _wrap_build $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $MODULES $MODULES_IN_PATHS $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 912 | else |
| 913 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 914 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 915 | fi |
| 916 | } |
| 917 | |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 918 | function mma() |
| 919 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 920 | local T=$(gettop) |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 921 | if [ -f build/soong/soong_ui.bash ]; then |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 922 | _wrap_build $T/build/soong/soong_ui.bash --make-mode $@ |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 923 | else |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 924 | if [ ! "$T" ]; then |
| 925 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 926 | return 1 |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 927 | fi |
Steven Moreland | 3b99ecf | 2018-06-13 15:31:59 -0700 | [diff] [blame] | 928 | local M=$(findmakefile || echo $(realpath $PWD)/Android.mk) |
Colin Cross | 127fcea | 2016-09-01 15:30:18 -0700 | [diff] [blame] | 929 | # Remove the path to top as the makefilepath needs to be relative |
| 930 | local M=`echo $M|sed 's:'$T'/::'` |
| 931 | local MODULES_IN_PATHS=MODULES-IN-$(dirname ${M}) |
Ying Wang | 61cd884 | 2015-09-24 16:19:19 -0700 | [diff] [blame] | 932 | # Convert "/" to "-". |
| 933 | MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 934 | _wrap_build $T/build/soong/soong_ui.bash --make-mode $@ $MODULES_IN_PATHS |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 935 | fi |
| 936 | } |
| 937 | |
| 938 | function mmma() |
| 939 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 940 | local T=$(gettop) |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 941 | if [ "$T" ]; then |
| 942 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 943 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 944 | local MY_PWD=`PWD= /bin/pwd` |
| 945 | if [ "$MY_PWD" = "$T" ]; then |
| 946 | MY_PWD= |
| 947 | else |
| 948 | MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'` |
| 949 | fi |
| 950 | local DIR= |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 951 | local MODULES_IN_PATHS= |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 952 | local ARGS= |
| 953 | for DIR in $DIRS ; do |
| 954 | if [ -d $DIR ]; then |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 955 | # Remove the leading ./ and trailing / if any exists. |
| 956 | DIR=${DIR#./} |
| 957 | DIR=${DIR%/} |
| 958 | if [ "$MY_PWD" != "" ]; then |
| 959 | DIR=$MY_PWD/$DIR |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 960 | fi |
Ying Wang | 61cd884 | 2015-09-24 16:19:19 -0700 | [diff] [blame] | 961 | MODULES_IN_PATHS="$MODULES_IN_PATHS MODULES-IN-$DIR" |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 962 | else |
| 963 | case $DIR in |
Ying Wang | caeaa08 | 2015-09-23 16:08:55 -0700 | [diff] [blame] | 964 | showcommands | snod | dist | *=*) ARGS="$ARGS $DIR";; |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 965 | *) echo "Couldn't find directory $DIR"; return 1;; |
| 966 | esac |
| 967 | fi |
| 968 | done |
Ying Wang | 61cd884 | 2015-09-24 16:19:19 -0700 | [diff] [blame] | 969 | # Convert "/" to "-". |
| 970 | MODULES_IN_PATHS=${MODULES_IN_PATHS//\//-} |
Chih-Hung Hsieh | 7ed0db8 | 2018-02-15 11:20:04 -0800 | [diff] [blame] | 971 | _wrap_build $T/build/soong/soong_ui.bash --make-mode $DASH_ARGS $ARGS $MODULES_IN_PATHS |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 972 | else |
| 973 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 974 | return 1 |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 975 | fi |
| 976 | } |
| 977 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 978 | function croot() |
| 979 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 980 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 981 | if [ "$T" ]; then |
Marie Janssen | 32ec50a | 2016-04-21 16:53:39 -0700 | [diff] [blame] | 982 | if [ "$1" ]; then |
| 983 | \cd $(gettop)/$1 |
| 984 | else |
| 985 | \cd $(gettop) |
| 986 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 987 | else |
| 988 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 989 | fi |
| 990 | } |
| 991 | |
Anton Hansson | ece9c48 | 2019-02-04 18:15:39 +0000 | [diff] [blame^] | 992 | function _croot() |
| 993 | { |
| 994 | local T=$(gettop) |
| 995 | if [ "$T" ]; then |
| 996 | local cur="${COMP_WORDS[COMP_CWORD]}" |
| 997 | k=0 |
| 998 | for c in $(compgen -d ${T}/${cur}); do |
| 999 | COMPREPLY[k++]=${c#${T}/}/ |
| 1000 | done |
| 1001 | fi |
| 1002 | } |
| 1003 | |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1004 | function cproj() |
| 1005 | { |
Colin Cross | 6cdc5d2 | 2017-10-20 11:37:33 -0700 | [diff] [blame] | 1006 | local TOPFILE=build/make/core/envsetup.mk |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1007 | local HERE=$PWD |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1008 | local T= |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1009 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 1010 | T=$PWD |
| 1011 | if [ -f "$T/Android.mk" ]; then |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1012 | \cd $T |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1013 | return |
| 1014 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1015 | \cd .. |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1016 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1017 | \cd $HERE |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1018 | echo "can't find Android.mk" |
| 1019 | } |
| 1020 | |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1021 | # simplified version of ps; output in the form |
| 1022 | # <pid> <procname> |
| 1023 | function qpid() { |
| 1024 | local prepend='' |
| 1025 | local append='' |
| 1026 | if [ "$1" = "--exact" ]; then |
| 1027 | prepend=' ' |
| 1028 | append='$' |
| 1029 | shift |
| 1030 | elif [ "$1" = "--help" -o "$1" = "-h" ]; then |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1031 | echo "usage: qpid [[--exact] <process name|pid>" |
| 1032 | return 255 |
| 1033 | fi |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1034 | |
| 1035 | local EXE="$1" |
| 1036 | if [ "$EXE" ] ; then |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1037 | qpid | \grep "$prepend$EXE$append" |
| 1038 | else |
| 1039 | adb shell ps \ |
| 1040 | | tr -d '\r' \ |
| 1041 | | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/' |
| 1042 | fi |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1043 | } |
| 1044 | |
Iliyan Malchev | e675cfb | 2014-11-03 17:04:47 -0800 | [diff] [blame] | 1045 | # coredump_setup - enable core dumps globally for any process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1046 | # that has the core-file-size limit set correctly |
| 1047 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1048 | # NOTE: You must call also coredump_enable for a specific process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1049 | # if its core-file-size limit is not set already. |
| 1050 | # NOTE: Core dumps are written to ramdisk; they will not survive a reboot! |
| 1051 | |
Iliyan Malchev | e675cfb | 2014-11-03 17:04:47 -0800 | [diff] [blame] | 1052 | function coredump_setup() |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1053 | { |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1054 | echo "Getting root..."; |
| 1055 | adb root; |
| 1056 | adb wait-for-device; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1057 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1058 | echo "Remounting root partition read-write..."; |
| 1059 | adb shell mount -w -o remount -t rootfs rootfs; |
| 1060 | sleep 1; |
| 1061 | adb wait-for-device; |
| 1062 | adb shell mkdir -p /cores; |
| 1063 | adb shell mount -t tmpfs tmpfs /cores; |
| 1064 | adb shell chmod 0777 /cores; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1065 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1066 | echo "Granting SELinux permission to dump in /cores..."; |
| 1067 | adb shell restorecon -R /cores; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1068 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1069 | echo "Set core pattern."; |
| 1070 | adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern'; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1071 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1072 | echo "Done." |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1073 | } |
| 1074 | |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1075 | # coredump_enable - enable core dumps for the specified process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1076 | # $1 = PID of process (e.g., $(pid mediaserver)) |
| 1077 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1078 | # NOTE: coredump_setup must have been called as well for a core |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1079 | # dump to actually be generated. |
| 1080 | |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1081 | function coredump_enable() |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1082 | { |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1083 | local PID=$1; |
| 1084 | if [ -z "$PID" ]; then |
| 1085 | printf "Expecting a PID!\n"; |
| 1086 | return; |
| 1087 | fi; |
| 1088 | echo "Setting core limit for $PID to infinite..."; |
Elliott Hughes | 910a355 | 2016-03-07 13:53:53 -0800 | [diff] [blame] | 1089 | adb shell /system/bin/ulimit -p $PID -c unlimited |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | # core - send SIGV and pull the core for process |
| 1093 | # $1 = PID of process (e.g., $(pid mediaserver)) |
| 1094 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1095 | # NOTE: coredump_setup must be called once per boot for core dumps to be |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1096 | # enabled globally. |
| 1097 | |
| 1098 | function core() |
| 1099 | { |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1100 | local PID=$1; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1101 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1102 | if [ -z "$PID" ]; then |
| 1103 | printf "Expecting a PID!\n"; |
| 1104 | return; |
| 1105 | fi; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1106 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1107 | local CORENAME=core.$PID; |
| 1108 | local COREPATH=/cores/$CORENAME; |
| 1109 | local SIG=SEGV; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1110 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1111 | coredump_enable $1; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1112 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1113 | local done=0; |
| 1114 | while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do |
| 1115 | printf "\tSending SIG%s to %d...\n" $SIG $PID; |
| 1116 | adb shell kill -$SIG $PID; |
| 1117 | sleep 1; |
| 1118 | done; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1119 | |
Ying Wang | 08800fd | 2016-03-03 20:57:21 -0800 | [diff] [blame] | 1120 | adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done" |
| 1121 | echo "Done: core is under $COREPATH on device."; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1122 | } |
| 1123 | |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 1124 | # systemstack - dump the current stack trace of all threads in the system process |
| 1125 | # to the usual ANR traces file |
| 1126 | function systemstack() |
| 1127 | { |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1128 | stacks system_server |
| 1129 | } |
| 1130 | |
Michael Wright | aeed721 | 2014-06-19 19:58:12 -0700 | [diff] [blame] | 1131 | # Read the ELF header from /proc/$PID/exe to determine if the process is |
| 1132 | # 64-bit. |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 1133 | function is64bit() |
| 1134 | { |
| 1135 | local PID="$1" |
| 1136 | if [ "$PID" ] ; then |
Elliott Hughes | d3e4725 | 2018-11-15 16:32:14 -0800 | [diff] [blame] | 1137 | if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -p)" -eq "02" ]] ; then |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 1138 | echo "64" |
| 1139 | else |
| 1140 | echo "" |
| 1141 | fi |
| 1142 | else |
| 1143 | echo "" |
| 1144 | fi |
| 1145 | } |
| 1146 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1147 | case `uname -s` in |
| 1148 | Darwin) |
| 1149 | function sgrep() |
| 1150 | { |
Aurelio Jargas | 67edd15 | 2018-11-06 17:25:11 +0100 | [diff] [blame] | 1151 | find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|hpp|S|java|xml|sh|mk|aidl|vts)' \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1152 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1153 | } |
| 1154 | |
| 1155 | ;; |
| 1156 | *) |
| 1157 | function sgrep() |
| 1158 | { |
Aurelio Jargas | 67edd15 | 2018-11-06 17:25:11 +0100 | [diff] [blame] | 1159 | find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|hpp\|S\|java\|xml\|sh\|mk\|aidl\|vts\)' \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1160 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1161 | } |
| 1162 | ;; |
| 1163 | esac |
| 1164 | |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 1165 | function gettargetarch |
| 1166 | { |
| 1167 | get_build_var TARGET_ARCH |
| 1168 | } |
| 1169 | |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame] | 1170 | function ggrep() |
| 1171 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1172 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" \ |
| 1173 | -exec grep --color -n "$@" {} + |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame] | 1174 | } |
| 1175 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1176 | function jgrep() |
| 1177 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1178 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" \ |
| 1179 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1180 | } |
| 1181 | |
| 1182 | function cgrep() |
| 1183 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1184 | 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' \) \ |
| 1185 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1186 | } |
| 1187 | |
| 1188 | function resgrep() |
| 1189 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1190 | local dir |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1191 | for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do |
| 1192 | find $dir -type f -name '*\.xml' -exec grep --color -n "$@" {} + |
| 1193 | done |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
Jeff Sharkey | 50b61e9 | 2013-03-08 10:20:47 -0800 | [diff] [blame] | 1196 | function mangrep() |
| 1197 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1198 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' \ |
| 1199 | -exec grep --color -n "$@" {} + |
Jeff Sharkey | 50b61e9 | 2013-03-08 10:20:47 -0800 | [diff] [blame] | 1200 | } |
| 1201 | |
Alex Klyubin | ba5fc8e | 2013-05-06 14:11:48 -0700 | [diff] [blame] | 1202 | function sepgrep() |
| 1203 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1204 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d \ |
| 1205 | -exec grep --color -n -r --exclude-dir=\.git "$@" {} + |
Alex Klyubin | ba5fc8e | 2013-05-06 14:11:48 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Jeff Sharkey | ea0068a | 2015-02-26 14:13:46 -0800 | [diff] [blame] | 1208 | function rcgrep() |
| 1209 | { |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1210 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" \ |
| 1211 | -exec grep --color -n "$@" {} + |
Jeff Sharkey | ea0068a | 2015-02-26 14:13:46 -0800 | [diff] [blame] | 1212 | } |
| 1213 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1214 | case `uname -s` in |
| 1215 | Darwin) |
| 1216 | function mgrep() |
| 1217 | { |
David Gross | d1d6fc5 | 2017-05-10 10:49:44 -0700 | [diff] [blame] | 1218 | 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 \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1219 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1220 | } |
| 1221 | |
| 1222 | function treegrep() |
| 1223 | { |
Aurelio Jargas | 67edd15 | 2018-11-06 17:25:11 +0100 | [diff] [blame] | 1224 | find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|hpp|S|java|xml)' \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1225 | -exec grep --color -n -i "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1226 | } |
| 1227 | |
| 1228 | ;; |
| 1229 | *) |
| 1230 | function mgrep() |
| 1231 | { |
David Gross | d1d6fc5 | 2017-05-10 10:49:44 -0700 | [diff] [blame] | 1232 | 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 \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1233 | -exec grep --color -n "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1234 | } |
| 1235 | |
| 1236 | function treegrep() |
| 1237 | { |
Aurelio Jargas | 67edd15 | 2018-11-06 17:25:11 +0100 | [diff] [blame] | 1238 | find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|hpp|S|java|xml)' -type f \ |
Mike Frysinger | 5e47973 | 2015-09-22 18:13:48 -0400 | [diff] [blame] | 1239 | -exec grep --color -n -i "$@" {} + |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1240 | } |
| 1241 | |
| 1242 | ;; |
| 1243 | esac |
| 1244 | |
| 1245 | function getprebuilt |
| 1246 | { |
| 1247 | get_abs_build_var ANDROID_PREBUILTS |
| 1248 | } |
| 1249 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1250 | function tracedmdump() |
| 1251 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1252 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1253 | if [ ! "$T" ]; then |
| 1254 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1255 | return |
| 1256 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1257 | local prebuiltdir=$(getprebuilt) |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 1258 | local arch=$(gettargetarch) |
| 1259 | local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1260 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1261 | local TRACE=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1262 | if [ ! "$TRACE" ] ; then |
| 1263 | echo "usage: tracedmdump tracename" |
| 1264 | return |
| 1265 | fi |
| 1266 | |
Jack Veenstra | 60116fc | 2009-04-09 18:12:34 -0700 | [diff] [blame] | 1267 | if [ ! -r "$KERNEL" ] ; then |
| 1268 | echo "Error: cannot find kernel: '$KERNEL'" |
| 1269 | return |
| 1270 | fi |
| 1271 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1272 | local BASETRACE=$(basename $TRACE) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1273 | if [ "$BASETRACE" = "$TRACE" ] ; then |
| 1274 | TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE |
| 1275 | fi |
| 1276 | |
| 1277 | echo "post-processing traces..." |
| 1278 | rm -f $TRACE/qtrace.dexlist |
| 1279 | post_trace $TRACE |
| 1280 | if [ $? -ne 0 ]; then |
| 1281 | echo "***" |
| 1282 | echo "*** Error: malformed trace. Did you remember to exit the emulator?" |
| 1283 | echo "***" |
| 1284 | return |
| 1285 | fi |
| 1286 | echo "generating dexlist output..." |
| 1287 | /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 |
| 1288 | echo "generating dmtrace data..." |
| 1289 | q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return |
| 1290 | echo "generating html file..." |
| 1291 | dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return |
| 1292 | echo "done, see $TRACE/dmtrace.html for details" |
| 1293 | echo "or run:" |
| 1294 | echo " traceview $TRACE/dmtrace" |
| 1295 | } |
| 1296 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1297 | # communicate with a running device or emulator, set up necessary state, |
| 1298 | # and run the hat command. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1299 | function runhat() |
| 1300 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1301 | # process standard adb options |
| 1302 | local adbTarget="" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1303 | if [ "$1" = "-d" -o "$1" = "-e" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1304 | adbTarget=$1 |
| 1305 | shift 1 |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1306 | elif [ "$1" = "-s" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1307 | adbTarget="$1 $2" |
| 1308 | shift 2 |
| 1309 | fi |
| 1310 | local adbOptions=${adbTarget} |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1311 | #echo adbOptions = ${adbOptions} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1312 | |
| 1313 | # runhat options |
| 1314 | local targetPid=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1315 | |
| 1316 | if [ "$targetPid" = "" ]; then |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1317 | echo "Usage: runhat [ -d | -e | -s serial ] target-pid" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1318 | return |
| 1319 | fi |
| 1320 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1321 | # confirm hat is available |
| 1322 | if [ -z $(which hat) ]; then |
| 1323 | echo "hat is not available in this configuration." |
| 1324 | return |
| 1325 | fi |
| 1326 | |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1327 | # issue "am" command to cause the hprof dump |
Nick Kralevich | 9948b1e | 2014-07-18 15:45:38 -0700 | [diff] [blame] | 1328 | local devFile=/data/local/tmp/hprof-$targetPid |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1329 | echo "Poking $targetPid and waiting for data..." |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1330 | echo "Storing data at $devFile" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1331 | adb ${adbOptions} shell am dumpheap $targetPid $devFile |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1332 | echo "Press enter when logcat shows \"hprof: heap dump completed\"" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1333 | echo -n "> " |
| 1334 | read |
| 1335 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1336 | local localFile=/tmp/$$-hprof |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1337 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1338 | echo "Retrieving file $devFile..." |
| 1339 | adb ${adbOptions} pull $devFile $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1340 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1341 | adb ${adbOptions} shell rm $devFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1342 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1343 | echo "Running hat on $localFile" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1344 | echo "View the output by pointing your browser at http://localhost:7000/" |
| 1345 | echo "" |
Dianne Hackborn | 6e4e1bb | 2011-11-10 15:19:51 -0800 | [diff] [blame] | 1346 | hat -JXmx512m $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | function getbugreports() |
| 1350 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1351 | local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1352 | |
| 1353 | if [ ! "$reports" ]; then |
| 1354 | echo "Could not locate any bugreports." |
| 1355 | return |
| 1356 | fi |
| 1357 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1358 | local report |
| 1359 | for report in ${reports[@]} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1360 | do |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1361 | echo "/sdcard/bugreports/${report}" |
| 1362 | adb pull /sdcard/bugreports/${report} ${report} |
| 1363 | gunzip ${report} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1364 | done |
| 1365 | } |
| 1366 | |
Victoria Lease | 1b296b4 | 2012-08-21 15:44:06 -0700 | [diff] [blame] | 1367 | function getsdcardpath() |
| 1368 | { |
| 1369 | adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\} |
| 1370 | } |
| 1371 | |
| 1372 | function getscreenshotpath() |
| 1373 | { |
| 1374 | echo "$(getsdcardpath)/Pictures/Screenshots" |
| 1375 | } |
| 1376 | |
| 1377 | function getlastscreenshot() |
| 1378 | { |
| 1379 | local screenshot_path=$(getscreenshotpath) |
| 1380 | local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1` |
| 1381 | if [ "$screenshot" = "" ]; then |
| 1382 | echo "No screenshots found." |
| 1383 | return |
| 1384 | fi |
| 1385 | echo "${screenshot}" |
| 1386 | adb ${adbOptions} pull ${screenshot_path}/${screenshot} |
| 1387 | } |
| 1388 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1389 | function startviewserver() |
| 1390 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1391 | local port=4939 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1392 | if [ $# -gt 0 ]; then |
| 1393 | port=$1 |
| 1394 | fi |
| 1395 | adb shell service call window 1 i32 $port |
| 1396 | } |
| 1397 | |
| 1398 | function stopviewserver() |
| 1399 | { |
| 1400 | adb shell service call window 2 |
| 1401 | } |
| 1402 | |
| 1403 | function isviewserverstarted() |
| 1404 | { |
| 1405 | adb shell service call window 3 |
| 1406 | } |
| 1407 | |
Romain Guy | b84049a | 2010-10-04 16:56:11 -0700 | [diff] [blame] | 1408 | function key_home() |
| 1409 | { |
| 1410 | adb shell input keyevent 3 |
| 1411 | } |
| 1412 | |
| 1413 | function key_back() |
| 1414 | { |
| 1415 | adb shell input keyevent 4 |
| 1416 | } |
| 1417 | |
| 1418 | function key_menu() |
| 1419 | { |
| 1420 | adb shell input keyevent 82 |
| 1421 | } |
| 1422 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1423 | function smoketest() |
| 1424 | { |
| 1425 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1426 | echo "Couldn't locate output files. Try running 'lunch' first." >&2 |
| 1427 | return |
| 1428 | fi |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1429 | local T=$(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1430 | if [ ! "$T" ]; then |
| 1431 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1432 | return |
| 1433 | fi |
| 1434 | |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1435 | (\cd "$T" && mmm tests/SmokeTest) && |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1436 | adb uninstall com.android.smoketest > /dev/null && |
| 1437 | adb uninstall com.android.smoketest.tests > /dev/null && |
| 1438 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk && |
| 1439 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk && |
| 1440 | adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner |
| 1441 | } |
| 1442 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1443 | # simple shortcut to the runtest command |
| 1444 | function runtest() |
| 1445 | { |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1446 | local T=$(gettop) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1447 | if [ ! "$T" ]; then |
| 1448 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1449 | return |
| 1450 | fi |
Brett Chabot | 3fb149d | 2009-10-21 20:05:26 -0700 | [diff] [blame] | 1451 | ("$T"/development/testrunner/runtest.py $@) |
Brett Chabot | 762748c | 2009-03-27 10:25:11 -0700 | [diff] [blame] | 1452 | } |
| 1453 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1454 | function godir () { |
| 1455 | if [[ -z "$1" ]]; then |
| 1456 | echo "Usage: godir <regex>" |
| 1457 | return |
| 1458 | fi |
Christopher Ferris | 55257d2 | 2017-03-23 11:08:58 -0700 | [diff] [blame] | 1459 | local T=$(gettop) |
| 1460 | local FILELIST |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1461 | if [ ! "$OUT_DIR" = "" ]; then |
| 1462 | mkdir -p $OUT_DIR |
| 1463 | FILELIST=$OUT_DIR/filelist |
| 1464 | else |
| 1465 | FILELIST=$T/filelist |
| 1466 | fi |
| 1467 | if [[ ! -f $FILELIST ]]; then |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1468 | echo -n "Creating index..." |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1469 | (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1470 | echo " Done" |
| 1471 | echo "" |
| 1472 | fi |
| 1473 | local lines |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1474 | lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1475 | if [[ ${#lines[@]} = 0 ]]; then |
| 1476 | echo "Not found" |
| 1477 | return |
| 1478 | fi |
| 1479 | local pathname |
| 1480 | local choice |
| 1481 | if [[ ${#lines[@]} > 1 ]]; then |
| 1482 | while [[ -z "$pathname" ]]; do |
| 1483 | local index=1 |
| 1484 | local line |
| 1485 | for line in ${lines[@]}; do |
| 1486 | printf "%6s %s\n" "[$index]" $line |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 1487 | index=$(($index + 1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1488 | done |
| 1489 | echo |
| 1490 | echo -n "Select one: " |
| 1491 | unset choice |
| 1492 | read choice |
| 1493 | if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then |
| 1494 | echo "Invalid choice" |
| 1495 | continue |
| 1496 | fi |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 1497 | pathname=${lines[$(($choice-1))]} |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1498 | done |
| 1499 | else |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1500 | pathname=${lines[0]} |
| 1501 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1502 | \cd $T/$pathname |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1503 | } |
| 1504 | |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1505 | # Update module-info.json in out. |
| 1506 | function refreshmod() { |
| 1507 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1508 | echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2 |
| 1509 | return 1 |
| 1510 | fi |
| 1511 | |
| 1512 | echo "Refreshing modules (building module-info.json). Log at $ANDROID_PRODUCT_OUT/module-info.json.build.log." >&2 |
| 1513 | |
| 1514 | # for the output of the next command |
| 1515 | mkdir -p $ANDROID_PRODUCT_OUT || return 1 |
| 1516 | |
| 1517 | # Note, can't use absolute path because of the way make works. |
| 1518 | m out/target/product/$(get_build_var TARGET_DEVICE)/module-info.json \ |
| 1519 | > $ANDROID_PRODUCT_OUT/module-info.json.build.log 2>&1 |
| 1520 | } |
| 1521 | |
| 1522 | # List all modules for the current device, as cached in module-info.json. If any build change is |
| 1523 | # made and it should be reflected in the output, you should run 'refreshmod' first. |
| 1524 | function allmod() { |
| 1525 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1526 | echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2 |
| 1527 | return 1 |
| 1528 | fi |
| 1529 | |
| 1530 | if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then |
| 1531 | echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2 |
| 1532 | refreshmod || return 1 |
| 1533 | fi |
| 1534 | |
| 1535 | python -c "import json; print '\n'.join(sorted(json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')).keys()))" |
| 1536 | } |
| 1537 | |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 1538 | # Get the path of a specific module in the android tree, as cached in module-info.json. If any build change |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1539 | # is made, and it should be reflected in the output, you should run 'refreshmod' first. |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 1540 | function pathmod() { |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1541 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1542 | echo "No ANDROID_PRODUCT_OUT. Try running 'lunch' first." >&2 |
| 1543 | return 1 |
| 1544 | fi |
| 1545 | |
| 1546 | if [[ $# -ne 1 ]]; then |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 1547 | echo "usage: pathmod <module>" >&2 |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1548 | return 1 |
| 1549 | fi |
| 1550 | |
| 1551 | if [ ! -f "$ANDROID_PRODUCT_OUT/module-info.json" ]; then |
| 1552 | echo "Could not find module-info.json. It will only be built once, and it can be updated with 'refreshmod'" >&2 |
| 1553 | refreshmod || return 1 |
| 1554 | fi |
| 1555 | |
| 1556 | local relpath=$(python -c "import json, os |
| 1557 | module = '$1' |
| 1558 | module_info = json.load(open('$ANDROID_PRODUCT_OUT/module-info.json')) |
| 1559 | if module not in module_info: |
| 1560 | exit(1) |
| 1561 | print module_info[module]['path'][0]" 2>/dev/null) |
| 1562 | |
| 1563 | if [ -z "$relpath" ]; then |
| 1564 | echo "Could not find module '$1' (try 'refreshmod' if there have been build changes?)." >&2 |
| 1565 | return 1 |
| 1566 | else |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 1567 | echo "$ANDROID_BUILD_TOP/$relpath" |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1568 | fi |
| 1569 | } |
| 1570 | |
Rett Berg | 78d1c93 | 2019-01-24 14:34:23 -0800 | [diff] [blame] | 1571 | # Go to a specific module in the android tree, as cached in module-info.json. If any build change |
| 1572 | # is made, and it should be reflected in the output, you should run 'refreshmod' first. |
| 1573 | function gomod() { |
| 1574 | if [[ $# -ne 1 ]]; then |
| 1575 | echo "usage: gomod <module>" >&2 |
| 1576 | return 1 |
| 1577 | fi |
| 1578 | |
| 1579 | local path="$(pathmod $@)" |
| 1580 | if [ -z "$path" ]; then |
| 1581 | return 1 |
| 1582 | fi |
| 1583 | cd $path |
| 1584 | } |
| 1585 | |
dimitry | 73b8481 | 2018-12-11 18:06:00 +0100 | [diff] [blame] | 1586 | function _complete_android_module_names() { |
Steven Moreland | 62054a4 | 2018-12-06 10:11:40 -0800 | [diff] [blame] | 1587 | local word=${COMP_WORDS[COMP_CWORD]} |
| 1588 | COMPREPLY=( $(allmod | grep -E "^$word") ) |
| 1589 | } |
| 1590 | |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 1591 | # Print colored exit condition |
| 1592 | function pez { |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 1593 | "$@" |
| 1594 | local retval=$? |
| 1595 | if [ $retval -ne 0 ] |
| 1596 | then |
Jacky Cao | 89483b8 | 2015-05-15 22:12:53 +0800 | [diff] [blame] | 1597 | echo $'\E'"[0;31mFAILURE\e[00m" |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 1598 | else |
Jacky Cao | 89483b8 | 2015-05-15 22:12:53 +0800 | [diff] [blame] | 1599 | echo $'\E'"[0;32mSUCCESS\e[00m" |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 1600 | fi |
| 1601 | return $retval |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 1602 | } |
| 1603 | |
Ying Wang | ed21d4c | 2014-08-24 22:14:19 -0700 | [diff] [blame] | 1604 | function get_make_command() |
| 1605 | { |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1606 | # If we're in the top of an Android tree, use soong_ui.bash instead of make |
| 1607 | if [ -f build/soong/soong_ui.bash ]; then |
Dan Willemsen | e984224 | 2017-07-28 13:00:13 -0700 | [diff] [blame] | 1608 | # Always use the real make if -C is passed in |
| 1609 | for arg in "$@"; do |
| 1610 | if [[ $arg == -C* ]]; then |
| 1611 | echo command make |
| 1612 | return |
| 1613 | fi |
| 1614 | done |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1615 | echo build/soong/soong_ui.bash --make-mode |
| 1616 | else |
| 1617 | echo command make |
| 1618 | fi |
Ying Wang | ed21d4c | 2014-08-24 22:14:19 -0700 | [diff] [blame] | 1619 | } |
| 1620 | |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1621 | function _wrap_build() |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1622 | { |
Sasha Smundak | 9f27cc0 | 2019-01-31 13:25:31 -0800 | [diff] [blame] | 1623 | if [[ "${ANDROID_QUIET_BUILD:-}" == true ]]; then |
| 1624 | "$@" |
| 1625 | return $? |
| 1626 | fi |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1627 | local start_time=$(date +"%s") |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1628 | "$@" |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1629 | local ret=$? |
| 1630 | local end_time=$(date +"%s") |
| 1631 | local tdiff=$(($end_time-$start_time)) |
| 1632 | local hours=$(($tdiff / 3600 )) |
| 1633 | local mins=$((($tdiff % 3600) / 60)) |
| 1634 | local secs=$(($tdiff % 60)) |
Greg Hackmann | d95c7f7 | 2014-06-23 14:05:06 -0700 | [diff] [blame] | 1635 | local ncolors=$(tput colors 2>/dev/null) |
| 1636 | if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then |
Jacky Cao | 89483b8 | 2015-05-15 22:12:53 +0800 | [diff] [blame] | 1637 | color_failed=$'\E'"[0;31m" |
| 1638 | color_success=$'\E'"[0;32m" |
| 1639 | color_reset=$'\E'"[00m" |
Greg Hackmann | d95c7f7 | 2014-06-23 14:05:06 -0700 | [diff] [blame] | 1640 | else |
| 1641 | color_failed="" |
| 1642 | color_success="" |
| 1643 | color_reset="" |
| 1644 | fi |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1645 | echo |
| 1646 | if [ $ret -eq 0 ] ; then |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1647 | echo -n "${color_success}#### build completed successfully " |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1648 | else |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1649 | echo -n "${color_failed}#### failed to build some targets " |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1650 | fi |
| 1651 | if [ $hours -gt 0 ] ; then |
| 1652 | printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs |
| 1653 | elif [ $mins -gt 0 ] ; then |
| 1654 | printf "(%02g:%02g (mm:ss))" $mins $secs |
| 1655 | elif [ $secs -gt 0 ] ; then |
| 1656 | printf "(%s seconds)" $secs |
| 1657 | fi |
Jacky Cao | 89483b8 | 2015-05-15 22:12:53 +0800 | [diff] [blame] | 1658 | echo " ####${color_reset}" |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 1659 | echo |
| 1660 | return $ret |
| 1661 | } |
| 1662 | |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1663 | function make() |
| 1664 | { |
Dan Willemsen | e984224 | 2017-07-28 13:00:13 -0700 | [diff] [blame] | 1665 | _wrap_build $(get_make_command "$@") "$@" |
Dan Willemsen | d41ec5a | 2017-07-12 16:14:50 -0700 | [diff] [blame] | 1666 | } |
| 1667 | |
David Zeuthen | 1b126ff | 2015-09-30 17:10:48 -0400 | [diff] [blame] | 1668 | function provision() |
| 1669 | { |
| 1670 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1671 | echo "Couldn't locate output files. Try running 'lunch' first." >&2 |
| 1672 | return 1 |
| 1673 | fi |
| 1674 | if [ ! -e "$ANDROID_PRODUCT_OUT/provision-device" ]; then |
| 1675 | echo "There is no provisioning script for the device." >&2 |
| 1676 | return 1 |
| 1677 | fi |
| 1678 | |
| 1679 | # Check if user really wants to do this. |
| 1680 | if [ "$1" = "--no-confirmation" ]; then |
| 1681 | shift 1 |
| 1682 | else |
| 1683 | echo "This action will reflash your device." |
| 1684 | echo "" |
| 1685 | echo "ALL DATA ON THE DEVICE WILL BE IRREVOCABLY ERASED." |
| 1686 | echo "" |
Marie Janssen | 4afc2c0 | 2015-11-10 10:41:15 -0800 | [diff] [blame] | 1687 | echo -n "Are you sure you want to do this (yes/no)? " |
| 1688 | read |
David Zeuthen | 1b126ff | 2015-09-30 17:10:48 -0400 | [diff] [blame] | 1689 | if [[ "${REPLY}" != "yes" ]] ; then |
| 1690 | echo "Not taking any action. Exiting." >&2 |
| 1691 | return 1 |
| 1692 | fi |
| 1693 | fi |
| 1694 | "$ANDROID_PRODUCT_OUT/provision-device" "$@" |
| 1695 | } |
| 1696 | |
Simran Basi | 424b876 | 2017-08-23 12:03:04 -0700 | [diff] [blame] | 1697 | function atest() |
| 1698 | { |
Jim Tang | f258e7e | 2018-11-01 18:00:05 +0800 | [diff] [blame] | 1699 | # Let's use the built version over the prebuilt, then source code. |
| 1700 | local os_arch=$(get_build_var HOST_PREBUILT_TAG) |
| 1701 | local built_atest=${ANDROID_HOST_OUT}/bin/atest |
| 1702 | local prebuilt_atest="$(gettop)"/prebuilts/asuite/atest/$os_arch/atest |
| 1703 | if [[ -x $built_atest ]]; then |
| 1704 | $built_atest "$@" |
| 1705 | elif [[ -x $prebuilt_atest ]]; then |
| 1706 | $prebuilt_atest "$@" |
| 1707 | else |
| 1708 | # TODO: once prebuilt atest released, remove the source code section |
| 1709 | # and change the location of atest_completion.sh in addcompletions(). |
| 1710 | "$(gettop)"/tools/tradefederation/core/atest/atest.py "$@" |
| 1711 | fi |
Simran Basi | 424b876 | 2017-08-23 12:03:04 -0700 | [diff] [blame] | 1712 | } |
| 1713 | |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1714 | # Zsh needs bashcompinit called to support bash-style completion. |
Patrik Fimml | df248e6 | 2018-10-15 18:15:12 +0200 | [diff] [blame] | 1715 | function enable_zsh_completion() { |
| 1716 | # Don't override user's options if bash-style completion is already enabled. |
| 1717 | if ! declare -f complete >/dev/null; then |
| 1718 | autoload -U compinit && compinit |
| 1719 | autoload -U bashcompinit && bashcompinit |
| 1720 | fi |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1721 | } |
| 1722 | |
| 1723 | function validate_current_shell() { |
| 1724 | local current_sh="$(ps -o command -p $$)" |
| 1725 | case "$current_sh" in |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1726 | *bash*) |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1727 | function check_type() { type -t "$1"; } |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1728 | ;; |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1729 | *zsh*) |
| 1730 | function check_type() { type "$1"; } |
Patrik Fimml | df248e6 | 2018-10-15 18:15:12 +0200 | [diff] [blame] | 1731 | enable_zsh_completion ;; |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1732 | *) |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1733 | echo -e "WARNING: Only bash and zsh are supported.\nUse of other shell would lead to erroneous results." |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 1734 | ;; |
| 1735 | esac |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1736 | } |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1737 | |
Kevin Cheng | bf89aff | 2018-05-22 14:07:50 -0700 | [diff] [blame] | 1738 | function acloud() |
| 1739 | { |
| 1740 | # Let's use the built version over the prebuilt. |
| 1741 | local built_acloud=${ANDROID_HOST_OUT}/bin/acloud |
| 1742 | if [ -f $built_acloud ]; then |
| 1743 | $built_acloud "$@" |
| 1744 | return $? |
| 1745 | fi |
| 1746 | |
| 1747 | local host_os_arch=$(get_build_var HOST_PREBUILT_TAG) |
| 1748 | case $host_os_arch in |
| 1749 | linux-x86) "$(gettop)"/prebuilts/asuite/acloud/linux-x86/acloud "$@" |
| 1750 | ;; |
Kevin Cheng | f0497e4 | 2018-12-03 01:01:27 -0800 | [diff] [blame] | 1751 | darwin-x86) "$(gettop)"/prebuilts/asuite/acloud/darwin-x86/acloud "$@" |
| 1752 | ;; |
Kevin Cheng | bf89aff | 2018-05-22 14:07:50 -0700 | [diff] [blame] | 1753 | *) |
| 1754 | echo "acloud is not supported on your host arch: $host_os_arch" |
| 1755 | ;; |
| 1756 | esac |
| 1757 | } |
| 1758 | |
patricktu | 345c9ae | 2018-11-29 15:25:40 +0800 | [diff] [blame] | 1759 | function aidegen() |
| 1760 | { |
| 1761 | # Always use the prebuilt version. |
| 1762 | local host_os_arch=$(get_build_var HOST_PREBUILT_TAG) |
| 1763 | case $host_os_arch in |
| 1764 | linux-x86) "$(gettop)"/prebuilts/asuite/aidegen/linux-x86/aidegen "$@" |
| 1765 | ;; |
| 1766 | *) |
| 1767 | echo "aidegen is not supported on your host arch: $host_os_arch" |
| 1768 | ;; |
| 1769 | esac |
| 1770 | } |
| 1771 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1772 | # Execute the contents of any vendorsetup.sh files we can find. |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1773 | function source_vendorsetup() { |
| 1774 | for dir in device vendor product; do |
| 1775 | for f in $(test -d $dir && \ |
| 1776 | find -L $dir -maxdepth 4 -name 'vendorsetup.sh' 2>/dev/null | sort); do |
| 1777 | echo "including $f"; . $f |
| 1778 | done |
| 1779 | done |
| 1780 | } |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 1781 | |
Jim Tang | a881a25 | 2018-06-19 16:34:41 +0800 | [diff] [blame] | 1782 | validate_current_shell |
| 1783 | source_vendorsetup |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 1784 | addcompletions |