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