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