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