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 |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 3 | Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment: |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 4 | - lunch: lunch <product_name>-<build_variant> |
Ying Wang | b541ab6 | 2014-05-29 17:57:40 -0700 | [diff] [blame] | 5 | - tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 6 | - croot: Changes directory to the top of the tree. |
nebkat | fb67a1e | 2012-12-28 10:40:45 +0000 | [diff] [blame] | 7 | - cout: Changes directory to out. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 8 | - m: Makes from the top of the tree. |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 9 | - mm: Builds all of the modules in the current directory, but not their dependencies. |
| 10 | - mmm: Builds all of the modules in the supplied directories, but not their dependencies. |
Primiano Tucci | 6a8069d | 2014-02-26 11:09:19 +0000 | [diff] [blame] | 11 | To limit the modules being built use the syntax: mmm dir/:target1,target2. |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 12 | - mma: Builds all of the modules in the current directory, and their dependencies. |
Daniel Bateman | 22185ba | 2012-08-04 03:48:09 -0500 | [diff] [blame] | 13 | - mmp: Builds all of the modules in the current directory and pushes them to the device. |
Martin Brabham | b77db58 | 2016-02-05 15:59:21 -0500 | [diff] [blame] | 14 | - mmap: Builds all of the modules in the current directory, and its dependencies, then pushes the package to the device. |
Daniel Bateman | 22185ba | 2012-08-04 03:48:09 -0500 | [diff] [blame] | 15 | - mmmp: Builds all of the modules in the supplied directories and pushes them to the device. |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 16 | - mmma: Builds all of the modules in the supplied directories, and their dependencies. |
Khalid Zubair | fdc26cd | 2015-10-21 12:43:14 -0700 | [diff] [blame] | 17 | - mms: Short circuit builder. Quickly re-build the kernel, rootfs, boot and system images |
| 18 | without deep dependencies. Requires the full build to have run before. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 19 | - cgrep: Greps on all local C/C++ files. |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame] | 20 | - ggrep: Greps on all local Gradle files. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 21 | - jgrep: Greps on all local Java files. |
| 22 | - resgrep: Greps on all local res/*.xml files. |
Trevor Drake | 9c88976 | 2015-01-30 04:42:21 +0000 | [diff] [blame] | 23 | - mangrep: Greps on all local AndroidManifest.xml files. |
| 24 | - sepgrep: Greps on all local sepolicy files. |
Jeff Brown | 46cbd20 | 2014-07-26 15:15:41 -0700 | [diff] [blame] | 25 | - sgrep: Greps on all local source files. |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 26 | - godir: Go to the directory containing a file. |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 27 | - mka: Builds using SCHED_BATCH on all processors |
Chirayu Desai | cf2bdb6 | 2012-09-28 11:56:02 +0530 | [diff] [blame] | 28 | - mkap: Builds the module(s) using mka and pushes them to the device. |
| 29 | - cmka: Cleans and builds using mka. |
Matt Mower | 8dacaed | 2013-12-29 12:57:20 -0600 | [diff] [blame] | 30 | - repolastsync: Prints date and time of last repo sync. |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 31 | - reposync: Parallel repo sync using ionice and SCHED_BATCH |
Chirayu Desai | 4a319b8 | 2013-06-05 20:14:33 +0530 | [diff] [blame] | 32 | - repopick: Utility to fetch changes from Gerrit. |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 33 | - installboot: Installs a boot.img to the connected device. |
| 34 | - installrecovery: Installs a recovery.img to the connected device. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 35 | |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 36 | Environemnt options: |
| 37 | - SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that |
| 38 | ASAN_OPTIONS=detect_leaks=0 will be set by default until the |
| 39 | build is leak-check clean. |
| 40 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 41 | Look at the source to view more functions. The complete list is: |
| 42 | EOF |
| 43 | T=$(gettop) |
Jeff Brown | 46cbd20 | 2014-07-26 15:15:41 -0700 | [diff] [blame] | 44 | for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do |
Anthony King | 0780f2f | 2015-04-30 23:16:10 +0100 | [diff] [blame] | 45 | echo "$i" |
| 46 | done | column |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | # Get the value of a build variable as an absolute path. |
| 50 | function get_abs_build_var() |
| 51 | { |
| 52 | T=$(gettop) |
| 53 | if [ ! "$T" ]; then |
| 54 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 55 | return |
| 56 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 57 | (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
Ed Heyl | c6d11f8 | 2014-06-27 13:32:39 -0700 | [diff] [blame] | 58 | command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | # Get the exact value of a build variable. |
| 62 | function get_build_var() |
| 63 | { |
| 64 | T=$(gettop) |
| 65 | if [ ! "$T" ]; then |
| 66 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 67 | return |
| 68 | fi |
Andrew Boie | 6905e21 | 2013-12-19 13:21:46 -0800 | [diff] [blame] | 69 | (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \ |
Ed Heyl | c6d11f8 | 2014-06-27 13:32:39 -0700 | [diff] [blame] | 70 | command make --no-print-directory -f build/core/config.mk dumpvar-$1) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | # check to see if the supplied product is one we can build |
| 74 | function check_product() |
| 75 | { |
| 76 | T=$(gettop) |
| 77 | if [ ! "$T" ]; then |
| 78 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 79 | return |
| 80 | fi |
Ricardo Cerqueira | 119d3bb | 2011-11-25 15:30:36 +0000 | [diff] [blame] | 81 | |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 82 | if (echo -n $1 | grep -q -e "^bliss_") ; then |
| 83 | BLISS_BUILD=$(echo -n $1 | sed -e 's/^bliss_//g') |
| 84 | export BUILD_NUMBER=$((date +%s%N ; echo $BLISS_BUILD; hostname) | openssl sha1 | sed -e 's/.*=//g; s/ //g' | cut -c1-10) |
Ricardo Cerqueira | 119d3bb | 2011-11-25 15:30:36 +0000 | [diff] [blame] | 85 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 86 | BLISS_BUILD= |
Ricardo Cerqueira | 119d3bb | 2011-11-25 15:30:36 +0000 | [diff] [blame] | 87 | fi |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 88 | export BLISS_BUILD |
Ricardo Cerqueira | 119d3bb | 2011-11-25 15:30:36 +0000 | [diff] [blame] | 89 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 90 | TARGET_PRODUCT=$1 \ |
| 91 | TARGET_BUILD_VARIANT= \ |
| 92 | TARGET_BUILD_TYPE= \ |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 93 | TARGET_BUILD_APPS= \ |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 94 | get_build_var TARGET_DEVICE > /dev/null |
| 95 | # hide successful answers, but allow the errors to show |
| 96 | } |
| 97 | |
| 98 | VARIANT_CHOICES=(user userdebug eng) |
| 99 | |
| 100 | # check to see if the supplied variant is valid |
| 101 | function check_variant() |
| 102 | { |
| 103 | for v in ${VARIANT_CHOICES[@]} |
| 104 | do |
| 105 | if [ "$v" = "$1" ] |
| 106 | then |
| 107 | return 0 |
| 108 | fi |
| 109 | done |
| 110 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | function setpaths() |
| 114 | { |
| 115 | T=$(gettop) |
| 116 | if [ ! "$T" ]; then |
| 117 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 118 | return |
| 119 | fi |
| 120 | |
| 121 | ################################################################## |
| 122 | # # |
| 123 | # Read me before you modify this code # |
| 124 | # # |
| 125 | # This function sets ANDROID_BUILD_PATHS to what it is adding # |
| 126 | # to PATH, and the next time it is run, it removes that from # |
| 127 | # PATH. This is required so lunch can be run more than once # |
| 128 | # and still have working paths. # |
| 129 | # # |
| 130 | ################################################################## |
| 131 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 132 | # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces |
| 133 | # due to "C:\Program Files" being in the path. |
| 134 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 135 | # out with the old |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 136 | if [ -n "$ANDROID_BUILD_PATHS" ] ; then |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 137 | export PATH=${PATH/$ANDROID_BUILD_PATHS/} |
| 138 | fi |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 139 | if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 140 | export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/} |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 141 | # strip leading ':', if any |
| 142 | export PATH=${PATH/:%/} |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 143 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 144 | |
| 145 | # and in with the new |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 146 | prebuiltdir=$(getprebuilt) |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 147 | gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS) |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 148 | |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 149 | # defined in core/config.mk |
| 150 | targetgccversion=$(get_build_var TARGET_GCC_VERSION) |
Colin Cross | 03b424a | 2014-05-22 11:57:43 -0700 | [diff] [blame] | 151 | targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION) |
Ben Cheng | 1526670 | 2012-12-10 16:04:39 -0800 | [diff] [blame] | 152 | export TARGET_GCC_VERSION=$targetgccversion |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 153 | |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 154 | # 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] | 155 | export ANDROID_TOOLCHAIN= |
| 156 | export ANDROID_TOOLCHAIN_2ND_ARCH= |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 157 | local ARCH=$(get_build_var TARGET_ARCH) |
| 158 | case $ARCH in |
Pavel Chupin | c1a5664 | 2013-08-23 16:49:21 +0400 | [diff] [blame] | 159 | x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 160 | ;; |
Pavel Chupin | fd82a49 | 2012-11-26 09:50:07 +0400 | [diff] [blame] | 161 | x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin |
| 162 | ;; |
Ben Cheng | 8bc4c43 | 2012-11-16 13:29:13 -0800 | [diff] [blame] | 163 | arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 164 | ;; |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 165 | arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin; |
Colin Cross | 03b424a | 2014-05-22 11:57:43 -0700 | [diff] [blame] | 166 | toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin |
Ben Cheng | db4fc20 | 2013-10-04 16:02:59 -0700 | [diff] [blame] | 167 | ;; |
Duane Sand | 3c4fcd8 | 2014-07-22 14:34:00 -0700 | [diff] [blame] | 168 | mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin |
Serban Constantinescu | 9b68fb2 | 2014-01-14 10:33:53 +0000 | [diff] [blame] | 169 | ;; |
David 'Digit' Turner | 2056c25 | 2012-04-17 14:50:47 +0200 | [diff] [blame] | 170 | *) |
| 171 | echo "Can't find toolchain for unknown architecture: $ARCH" |
| 172 | toolchaindir=xxxxxxxxx |
Mark D Horn | 7d0ede7 | 2012-03-14 14:20:30 -0700 | [diff] [blame] | 173 | ;; |
| 174 | esac |
Jing Yu | f5172c7 | 2012-03-29 20:45:50 -0700 | [diff] [blame] | 175 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 176 | export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir |
Raphael Moll | c639c78 | 2011-06-20 17:25:01 -0700 | [diff] [blame] | 177 | fi |
Raphael | 732936d | 2011-06-22 14:35:32 -0700 | [diff] [blame] | 178 | |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 179 | if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then |
| 180 | export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2 |
| 181 | fi |
| 182 | |
| 183 | unset ANDROID_KERNEL_TOOLCHAIN_PATH |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 184 | case $ARCH in |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 185 | arm) |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 186 | # Legacy toolchain configuration used for ARM kernel compilation |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 187 | toolchaindir=arm/arm-eabi-$targetgcckernelversion/bin |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 188 | if [ -d "$gccprebuiltdir/$toolchaindir" ]; then |
Torne (Richard Coles) | f24c356 | 2014-04-25 16:24:22 +0100 | [diff] [blame] | 189 | export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir" |
| 190 | ANDROID_KERNEL_TOOLCHAIN_PATH="$ARM_EABI_TOOLCHAIN": |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 191 | fi |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 192 | ;; |
| 193 | *) |
Bruce Beare | 42ced6d | 2012-07-17 21:40:01 -0700 | [diff] [blame] | 194 | # No need to set ARM_EABI_TOOLCHAIN for other ARCHs |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 195 | ;; |
| 196 | esac |
Ying Wang | 08f5e9a | 2012-04-17 18:10:11 -0700 | [diff] [blame] | 197 | |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 198 | targetgcckernelversion=$(get_build_var TARGET_KERNEL_CUSTOM_TOOLCHAIN) |
| 199 | if [ -z "$targetgcckernelversion" ]; then |
| 200 | export TARGET_GCC_VERSION_KERNEL="4.9-linaro" |
| 201 | else |
| 202 | export TARGET_GCC_VERSION_KERNEL="$targetgcckernelversion" |
| 203 | fi |
| 204 | |
Jeff Vander Stoep | 5aa6832 | 2015-06-12 09:56:39 -0700 | [diff] [blame] | 205 | export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin |
Ying Wang | 2a859d5 | 2014-06-30 10:25:33 -0700 | [diff] [blame] | 206 | export ANDROID_BUILD_PATHS=$(get_build_var ANDROID_BUILD_PATHS):$ANDROID_TOOLCHAIN:$ANDROID_TOOLCHAIN_2ND_ARCH:$ANDROID_KERNEL_TOOLCHAIN_PATH$ANDROID_DEV_SCRIPTS: |
David 'Digit' Turner | 94d16e5 | 2014-05-05 16:13:50 +0200 | [diff] [blame] | 207 | |
| 208 | # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH |
| 209 | # to ensure that the corresponding 'emulator' binaries are used. |
| 210 | case $(uname -s) in |
| 211 | Darwin) |
| 212 | ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64 |
| 213 | ;; |
| 214 | Linux) |
| 215 | ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64 |
| 216 | ;; |
| 217 | *) |
| 218 | ANDROID_EMULATOR_PREBUILTS= |
| 219 | ;; |
| 220 | esac |
| 221 | if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then |
Christopher Ferris | 7110f24 | 2014-05-20 13:56:00 -0700 | [diff] [blame] | 222 | ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS: |
David 'Digit' Turner | 94d16e5 | 2014-05-05 16:13:50 +0200 | [diff] [blame] | 223 | export ANDROID_EMULATOR_PREBUILTS |
| 224 | fi |
| 225 | |
Ying Wang | aa1c9b5 | 2012-11-26 20:51:59 -0800 | [diff] [blame] | 226 | export PATH=$ANDROID_BUILD_PATHS$PATH |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 227 | |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 228 | unset ANDROID_JAVA_TOOLCHAIN |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 229 | unset ANDROID_PRE_BUILD_PATHS |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 230 | if [ -n "$JAVA_HOME" ]; then |
| 231 | export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin |
Ji-Hwan Lee | 752ad06 | 2011-07-04 14:09:47 +0900 | [diff] [blame] | 232 | export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN: |
| 233 | export PATH=$ANDROID_PRE_BUILD_PATHS$PATH |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 234 | fi |
| 235 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 236 | unset ANDROID_PRODUCT_OUT |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 237 | export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT) |
| 238 | export OUT=$ANDROID_PRODUCT_OUT |
| 239 | |
Jeff Brown | 8fd5cce | 2011-03-24 17:03:06 -0700 | [diff] [blame] | 240 | unset ANDROID_HOST_OUT |
| 241 | export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT) |
| 242 | |
Matt Mower | f8ff73e | 2015-06-09 19:35:53 -0500 | [diff] [blame] | 243 | if [ -n "$ANDROID_CCACHE_DIR" ]; then |
| 244 | export CCACHE_DIR=$ANDROID_CCACHE_DIR |
| 245 | fi |
| 246 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 247 | # needed for building linux on MacOS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 248 | # TODO: fix the path |
| 249 | #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include |
| 250 | } |
| 251 | |
| 252 | function printconfig() |
| 253 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 254 | T=$(gettop) |
| 255 | if [ ! "$T" ]; then |
| 256 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 257 | return |
| 258 | fi |
| 259 | get_build_var report_config |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 260 | } |
| 261 | |
| 262 | function set_stuff_for_environment() |
| 263 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 264 | settitle |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 265 | set_java_home |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 266 | setpaths |
| 267 | set_sequence_number |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 268 | |
Ben Cheng | aac3f81 | 2013-08-13 14:38:15 -0700 | [diff] [blame] | 269 | # With this environment variable new GCC can apply colors to warnings/errors |
| 270 | export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' |
Dan Albert | 4ae5d4b | 2014-10-31 16:23:08 -0700 | [diff] [blame] | 271 | export ASAN_OPTIONS=detect_leaks=0 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 272 | } |
| 273 | |
| 274 | function set_sequence_number() |
| 275 | { |
Joe Onorato | aee4daa | 2010-06-23 14:03:13 -0700 | [diff] [blame] | 276 | export BUILD_ENV_SEQUENCE_NUMBER=10 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | function settitle() |
| 280 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 281 | if [ "$STAY_OFF_MY_LAWN" = "" ]; then |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 282 | local arch=$(gettargetarch) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 283 | local product=$TARGET_PRODUCT |
| 284 | local variant=$TARGET_BUILD_VARIANT |
| 285 | local apps=$TARGET_BUILD_APPS |
Steve Kondik | d6fba55 | 2012-12-27 15:28:34 -0800 | [diff] [blame] | 286 | if [ -z "$PROMPT_COMMAND" ]; then |
| 287 | # No prompts |
| 288 | PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}: ${PWD}\007\"" |
| 289 | elif [ -z "$(echo $PROMPT_COMMAND | grep '033]0;')" ]; then |
| 290 | # Prompts exist, but no hardstatus |
| 291 | PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}: ${PWD}\007\";${PROMPT_COMMAND}" |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 292 | fi |
Steve Kondik | d6fba55 | 2012-12-27 15:28:34 -0800 | [diff] [blame] | 293 | if [ ! -z "$ANDROID_PROMPT_PREFIX" ]; then |
Christopher Lais | fa8d935 | 2013-06-03 15:15:39 -0500 | [diff] [blame] | 294 | PROMPT_COMMAND="$(echo $PROMPT_COMMAND | sed -e 's/$ANDROID_PROMPT_PREFIX //g')" |
Steve Kondik | d6fba55 | 2012-12-27 15:28:34 -0800 | [diff] [blame] | 295 | fi |
| 296 | |
| 297 | if [ -z "$apps" ]; then |
| 298 | ANDROID_PROMPT_PREFIX="[${arch}-${product}-${variant}]" |
| 299 | else |
| 300 | ANDROID_PROMPT_PREFIX="[$arch $apps $variant]" |
| 301 | fi |
| 302 | export ANDROID_PROMPT_PREFIX |
| 303 | |
| 304 | # Inject build data into hardstatus |
| 305 | export PROMPT_COMMAND="$(echo $PROMPT_COMMAND | sed -e 's/\\033]0;\(.*\)\\007/\\033]0;$ANDROID_PROMPT_PREFIX \1\\007/g')" |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 306 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 309 | function check_bash_version() |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 310 | { |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 311 | # Keep us from trying to run in something that isn't bash. |
| 312 | if [ -z "${BASH_VERSION}" ]; then |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 313 | return 1 |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 314 | fi |
| 315 | |
| 316 | # Keep us from trying to run in bash that's too old. |
James Roberts-Thomson | 24dd07d | 2013-04-16 15:53:39 +1200 | [diff] [blame] | 317 | if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 318 | return 2 |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 319 | fi |
| 320 | |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 321 | return 0 |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 322 | } |
| 323 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 324 | function choosetype() |
| 325 | { |
| 326 | echo "Build type choices are:" |
| 327 | echo " 1. release" |
| 328 | echo " 2. debug" |
| 329 | echo |
| 330 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 331 | local DEFAULT_NUM DEFAULT_VALUE |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 332 | DEFAULT_NUM=1 |
| 333 | DEFAULT_VALUE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 334 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 335 | export TARGET_BUILD_TYPE= |
| 336 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 337 | while [ -z $TARGET_BUILD_TYPE ] |
| 338 | do |
| 339 | echo -n "Which would you like? ["$DEFAULT_NUM"] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 340 | if [ -z "$1" ] ; then |
| 341 | read ANSWER |
| 342 | else |
| 343 | echo $1 |
| 344 | ANSWER=$1 |
| 345 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 346 | case $ANSWER in |
| 347 | "") |
| 348 | export TARGET_BUILD_TYPE=$DEFAULT_VALUE |
| 349 | ;; |
| 350 | 1) |
| 351 | export TARGET_BUILD_TYPE=release |
| 352 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 353 | release) |
| 354 | export TARGET_BUILD_TYPE=release |
| 355 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 356 | 2) |
| 357 | export TARGET_BUILD_TYPE=debug |
| 358 | ;; |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 359 | debug) |
| 360 | export TARGET_BUILD_TYPE=debug |
| 361 | ;; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 362 | *) |
| 363 | echo |
| 364 | echo "I didn't understand your response. Please try again." |
| 365 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 366 | ;; |
| 367 | esac |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 368 | if [ -n "$1" ] ; then |
| 369 | break |
| 370 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 371 | done |
| 372 | |
| 373 | set_stuff_for_environment |
| 374 | } |
| 375 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 376 | # |
| 377 | # This function isn't really right: It chooses a TARGET_PRODUCT |
| 378 | # based on the list of boards. Usually, that gets you something |
| 379 | # that kinda works with a generic product, but really, you should |
| 380 | # pick a product by name. |
| 381 | # |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 382 | function chooseproduct() |
| 383 | { |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 384 | if [ "x$TARGET_PRODUCT" != x ] ; then |
| 385 | default_value=$TARGET_PRODUCT |
| 386 | else |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 387 | default_value=full |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 388 | fi |
| 389 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 390 | export TARGET_PRODUCT= |
| 391 | local ANSWER |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 392 | while [ -z "$TARGET_PRODUCT" ] |
| 393 | do |
Joe Onorato | 8849aed | 2009-04-29 15:56:47 -0700 | [diff] [blame] | 394 | echo -n "Which product would you like? [$default_value] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 395 | if [ -z "$1" ] ; then |
| 396 | read ANSWER |
| 397 | else |
| 398 | echo $1 |
| 399 | ANSWER=$1 |
| 400 | fi |
| 401 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 402 | if [ -z "$ANSWER" ] ; then |
| 403 | export TARGET_PRODUCT=$default_value |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 404 | else |
| 405 | if check_product $ANSWER |
| 406 | then |
| 407 | export TARGET_PRODUCT=$ANSWER |
| 408 | else |
| 409 | echo "** Not a valid product: $ANSWER" |
| 410 | fi |
| 411 | fi |
| 412 | if [ -n "$1" ] ; then |
| 413 | break |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 414 | fi |
| 415 | done |
| 416 | |
| 417 | set_stuff_for_environment |
| 418 | } |
| 419 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 420 | function choosevariant() |
| 421 | { |
| 422 | echo "Variant choices are:" |
| 423 | local index=1 |
| 424 | local v |
| 425 | for v in ${VARIANT_CHOICES[@]} |
| 426 | do |
| 427 | # The product name is the name of the directory containing |
| 428 | # the makefile we found, above. |
| 429 | echo " $index. $v" |
| 430 | index=$(($index+1)) |
| 431 | done |
| 432 | |
| 433 | local default_value=eng |
| 434 | local ANSWER |
| 435 | |
| 436 | export TARGET_BUILD_VARIANT= |
| 437 | while [ -z "$TARGET_BUILD_VARIANT" ] |
| 438 | do |
| 439 | echo -n "Which would you like? [$default_value] " |
| 440 | if [ -z "$1" ] ; then |
| 441 | read ANSWER |
| 442 | else |
| 443 | echo $1 |
| 444 | ANSWER=$1 |
| 445 | fi |
| 446 | |
| 447 | if [ -z "$ANSWER" ] ; then |
| 448 | export TARGET_BUILD_VARIANT=$default_value |
| 449 | elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then |
| 450 | if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 451 | export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 452 | fi |
| 453 | else |
| 454 | if check_variant $ANSWER |
| 455 | then |
| 456 | export TARGET_BUILD_VARIANT=$ANSWER |
| 457 | else |
| 458 | echo "** Not a valid variant: $ANSWER" |
| 459 | fi |
| 460 | fi |
| 461 | if [ -n "$1" ] ; then |
| 462 | break |
| 463 | fi |
| 464 | done |
| 465 | } |
| 466 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 467 | function choosecombo() |
| 468 | { |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 469 | choosetype $1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 470 | |
| 471 | echo |
| 472 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 473 | chooseproduct $2 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 474 | |
| 475 | echo |
| 476 | echo |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 477 | choosevariant $3 |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 478 | |
| 479 | echo |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 480 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 481 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 482 | } |
| 483 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 484 | # Clear this variable. It will be built up again when the vendorsetup.sh |
| 485 | # files are included at the end of this file. |
| 486 | unset LUNCH_MENU_CHOICES |
| 487 | function add_lunch_combo() |
| 488 | { |
| 489 | local new_combo=$1 |
| 490 | local c |
| 491 | for c in ${LUNCH_MENU_CHOICES[@]} ; do |
| 492 | if [ "$new_combo" = "$c" ] ; then |
| 493 | return |
| 494 | fi |
| 495 | done |
| 496 | LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo) |
| 497 | } |
| 498 | |
| 499 | # add the default one here |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 500 | add_lunch_combo aosp_arm-eng |
Colin Cross | 4f0eb7d | 2014-01-21 19:35:38 -0800 | [diff] [blame] | 501 | add_lunch_combo aosp_arm64-eng |
Serban Constantinescu | 9b68fb2 | 2014-01-14 10:33:53 +0000 | [diff] [blame] | 502 | add_lunch_combo aosp_mips-eng |
Chris Dearman | 1efd9e4 | 2014-02-03 15:01:24 -0800 | [diff] [blame] | 503 | add_lunch_combo aosp_mips64-eng |
Serban Constantinescu | 9b68fb2 | 2014-01-14 10:33:53 +0000 | [diff] [blame] | 504 | add_lunch_combo aosp_x86-eng |
| 505 | add_lunch_combo aosp_x86_64-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 506 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 507 | function print_lunch_menu() |
| 508 | { |
| 509 | local uname=$(uname) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 510 | echo |
| 511 | echo "You're building on" $uname |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 512 | if [ "$(uname)" = "Darwin" ] ; then |
| 513 | echo " (ohai, koush!)" |
| 514 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 515 | echo |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 516 | if [ "z${BLISS_DEVICES_ONLY}" != "z" ]; then |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 517 | echo "Breakfast menu... pick a combo:" |
| 518 | else |
| 519 | echo "Lunch menu... pick a combo:" |
| 520 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 521 | |
| 522 | local i=1 |
| 523 | local choice |
| 524 | for choice in ${LUNCH_MENU_CHOICES[@]} |
| 525 | do |
cybojenix | a5dd6ce | 2013-06-28 20:30:00 +0100 | [diff] [blame] | 526 | echo " $i. $choice " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 527 | i=$(($i+1)) |
cybojenix | a5dd6ce | 2013-06-28 20:30:00 +0100 | [diff] [blame] | 528 | done | column |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 529 | |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 530 | if [ "z${BLISS_DEVICES_ONLY}" != "z" ]; then |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 531 | echo "... and don't forget the bacon!" |
| 532 | fi |
| 533 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 534 | echo |
| 535 | } |
| 536 | |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 537 | function brunch() |
| 538 | { |
| 539 | breakfast $* |
| 540 | if [ $? -eq 0 ]; then |
| 541 | mka bacon |
| 542 | else |
| 543 | echo "No such item in brunch menu. Try 'breakfast'" |
| 544 | return 1 |
| 545 | fi |
| 546 | return $? |
| 547 | } |
| 548 | |
| 549 | function breakfast() |
| 550 | { |
| 551 | target=$1 |
JustArchi | f70c7e6 | 2014-06-22 14:37:30 +0200 | [diff] [blame] | 552 | local variant=$2 |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 553 | BLISS_DEVICES_ONLY="true" |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 554 | unset LUNCH_MENU_CHOICES |
| 555 | add_lunch_combo full-eng |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 556 | for f in `/bin/ls vendor/bliss/vendorsetup.sh 2> /dev/null` |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 557 | do |
| 558 | echo "including $f" |
| 559 | . $f |
| 560 | done |
| 561 | unset f |
| 562 | |
| 563 | if [ $# -eq 0 ]; then |
| 564 | # No arguments, so let's have the full menu |
| 565 | lunch |
| 566 | else |
| 567 | echo "z$target" | grep -q "-" |
| 568 | if [ $? -eq 0 ]; then |
| 569 | # A buildtype was specified, assume a full device name |
| 570 | lunch $target |
| 571 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 572 | # This is probably just the Bliss model name |
JustArchi | f70c7e6 | 2014-06-22 14:37:30 +0200 | [diff] [blame] | 573 | if [ -z "$variant" ]; then |
| 574 | variant="userdebug" |
| 575 | fi |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 576 | lunch bliss_$target-$variant |
Ricardo Cerqueira | 8b2014d | 2011-01-31 00:49:49 +0000 | [diff] [blame] | 577 | fi |
| 578 | fi |
| 579 | return $? |
| 580 | } |
| 581 | |
| 582 | alias bib=breakfast |
| 583 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 584 | function lunch() |
| 585 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 586 | local answer |
Anthony King | 850627c | 2015-04-30 22:57:08 +0100 | [diff] [blame] | 587 | LUNCH_MENU_CHOICES=($(for l in ${LUNCH_MENU_CHOICES[@]}; do echo "$l"; done | sort)) |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 588 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 589 | if [ "$1" ] ; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 590 | answer=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 591 | else |
| 592 | print_lunch_menu |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 593 | echo -n "Which would you like? [aosp_arm-eng] " |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 594 | read answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 595 | fi |
| 596 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 597 | local selection= |
| 598 | |
| 599 | if [ -z "$answer" ] |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 600 | then |
Jean-Baptiste Queru | 324c123 | 2013-03-22 15:53:54 -0700 | [diff] [blame] | 601 | selection=aosp_arm-eng |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 602 | elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") |
| 603 | then |
| 604 | if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] |
| 605 | then |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 606 | selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 607 | fi |
| 608 | elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$") |
| 609 | then |
| 610 | selection=$answer |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 611 | fi |
| 612 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 613 | if [ -z "$selection" ] |
| 614 | then |
| 615 | echo |
| 616 | echo "Invalid lunch combo: $answer" |
| 617 | return 1 |
| 618 | fi |
| 619 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 620 | export TARGET_BUILD_APPS= |
| 621 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 622 | local product=$(echo -n $selection | sed -e "s/-.*$//") |
| 623 | check_product $product |
| 624 | if [ $? -ne 0 ] |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 625 | then |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 626 | # if we can't find a product, try to grab it off the BLISS github |
Koushik Dutta | 780fb5f | 2011-11-26 18:51:42 -0800 | [diff] [blame] | 627 | T=$(gettop) |
| 628 | pushd $T > /dev/null |
| 629 | build/tools/roomservice.py $product |
| 630 | popd > /dev/null |
| 631 | check_product $product |
Diogo Ferreira | 0d10917 | 2012-03-18 21:18:29 +0000 | [diff] [blame] | 632 | else |
| 633 | build/tools/roomservice.py $product true |
Koushik Dutta | 780fb5f | 2011-11-26 18:51:42 -0800 | [diff] [blame] | 634 | fi |
| 635 | if [ $? -ne 0 ] |
| 636 | then |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 637 | echo |
| 638 | echo "** Don't have a product spec for: '$product'" |
| 639 | echo "** Do you have the right repo manifest?" |
| 640 | product= |
| 641 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 642 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 643 | local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//") |
| 644 | check_variant $variant |
| 645 | if [ $? -ne 0 ] |
| 646 | then |
| 647 | echo |
| 648 | echo "** Invalid variant: '$variant'" |
| 649 | echo "** Must be one of ${VARIANT_CHOICES[@]}" |
| 650 | variant= |
| 651 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 652 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 653 | if [ -z "$product" -o -z "$variant" ] |
| 654 | then |
| 655 | echo |
| 656 | return 1 |
| 657 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 658 | |
Jeff Brown | e33ba4c | 2011-07-11 22:11:46 -0700 | [diff] [blame] | 659 | export TARGET_PRODUCT=$product |
| 660 | export TARGET_BUILD_VARIANT=$variant |
| 661 | export TARGET_BUILD_TYPE=release |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 662 | |
| 663 | echo |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 664 | |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 665 | export TARGET_DEVICE=$(get_build_var TARGET_DEVICE) |
| 666 | |
Chirayu Desai | b89b324 | 2013-06-30 10:04:25 +0530 | [diff] [blame] | 667 | fixup_common_out_dir |
| 668 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 669 | set_stuff_for_environment |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 670 | printconfig |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 671 | } |
| 672 | |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 673 | # Tab completion for lunch. |
| 674 | function _lunch() |
| 675 | { |
| 676 | local cur prev opts |
| 677 | COMPREPLY=() |
| 678 | cur="${COMP_WORDS[COMP_CWORD]}" |
| 679 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
| 680 | |
| 681 | COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) ) |
| 682 | return 0 |
| 683 | } |
Emilio López | 9ad6eea | 2013-11-03 13:02:13 -0300 | [diff] [blame] | 684 | complete -F _lunch lunch 2>/dev/null |
Jeff Davidson | 513d7a4 | 2010-08-02 10:00:44 -0700 | [diff] [blame] | 685 | |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 686 | # Configures the build to build unbundled apps. |
Doug Zongker | 0d8179e | 2014-04-16 11:34:34 -0700 | [diff] [blame] | 687 | # Run tapas with one or more app names (from LOCAL_PACKAGE_NAME) |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 688 | function tapas() |
| 689 | { |
Ying Wang | b541ab6 | 2014-05-29 17:57:40 -0700 | [diff] [blame] | 690 | local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)" |
Doug Zongker | 0d8179e | 2014-04-16 11:34:34 -0700 | [diff] [blame] | 691 | 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] | 692 | local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)" |
| 693 | local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|mips|armv5|arm64|x86_64|mips64|ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)" |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 694 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 695 | if [ $(echo $arch | wc -w) -gt 1 ]; then |
| 696 | echo "tapas: Error: Multiple build archs supplied: $arch" |
| 697 | return |
| 698 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 699 | if [ $(echo $variant | wc -w) -gt 1 ]; then |
| 700 | echo "tapas: Error: Multiple build variants supplied: $variant" |
| 701 | return |
| 702 | fi |
Jeff Hamilton | 5069bd6 | 2014-09-04 21:28:00 -0700 | [diff] [blame] | 703 | if [ $(echo $density | wc -w) -gt 1 ]; then |
| 704 | echo "tapas: Error: Multiple densities supplied: $density" |
| 705 | return |
| 706 | fi |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 707 | |
| 708 | local product=full |
| 709 | case $arch in |
Ying Wang | b541ab6 | 2014-05-29 17:57:40 -0700 | [diff] [blame] | 710 | x86) product=full_x86;; |
| 711 | mips) product=full_mips;; |
| 712 | armv5) product=generic_armv5;; |
| 713 | arm64) product=aosp_arm64;; |
| 714 | x86_64) product=aosp_x86_64;; |
| 715 | mips64) product=aosp_mips64;; |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 716 | esac |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 717 | if [ -z "$variant" ]; then |
| 718 | variant=eng |
| 719 | fi |
Ying Wang | c048c9b | 2010-06-24 15:08:33 -0700 | [diff] [blame] | 720 | if [ -z "$apps" ]; then |
| 721 | apps=all |
| 722 | fi |
Justin Morey | 29d225c | 2014-11-04 13:35:51 -0600 | [diff] [blame] | 723 | if [ -z "$density" ]; then |
| 724 | density=alldpi |
| 725 | fi |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 726 | |
Ying Wang | 67f0292 | 2012-08-22 10:25:20 -0700 | [diff] [blame] | 727 | export TARGET_PRODUCT=$product |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 728 | export TARGET_BUILD_VARIANT=$variant |
Jeff Hamilton | 5069bd6 | 2014-09-04 21:28:00 -0700 | [diff] [blame] | 729 | export TARGET_BUILD_DENSITY=$density |
Joe Onorato | da12daf | 2010-06-09 18:18:31 -0700 | [diff] [blame] | 730 | export TARGET_BUILD_TYPE=release |
| 731 | export TARGET_BUILD_APPS=$apps |
| 732 | |
| 733 | set_stuff_for_environment |
| 734 | printconfig |
| 735 | } |
| 736 | |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 737 | function eat() |
| 738 | { |
| 739 | if [ "$OUT" ] ; then |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 740 | MODVERSION=$(get_build_var BLISS_VERSION) |
| 741 | ZIPFILE=bliss-$MODVERSION.zip |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 742 | ZIPPATH=$OUT/$ZIPFILE |
| 743 | if [ ! -f $ZIPPATH ] ; then |
| 744 | echo "Nothing to eat" |
| 745 | return 1 |
| 746 | fi |
| 747 | adb start-server # Prevent unexpected starting server message from adb get-state in the next line |
Steve Kondik | 58fa716 | 2015-11-15 18:47:58 -0800 | [diff] [blame] | 748 | if [ $(adb get-state) != device -a $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) != 0 ] ; then |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 749 | echo "No device is online. Waiting for one..." |
| 750 | echo "Please connect USB and/or enable USB debugging" |
Steve Kondik | 58fa716 | 2015-11-15 18:47:58 -0800 | [diff] [blame] | 751 | until [ $(adb get-state) = device -o $(adb shell test -e /sbin/recovery 2> /dev/null; echo $?) = 0 ];do |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 752 | sleep 1 |
| 753 | done |
| 754 | echo "Device Found.." |
| 755 | fi |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 756 | if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD"); |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 757 | then |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 758 | # if adbd isn't root we can't write to /cache/recovery/ |
| 759 | adb root |
| 760 | sleep 1 |
| 761 | adb wait-for-device |
Steve Kondik | 464574f | 2013-04-13 07:19:52 -0700 | [diff] [blame] | 762 | cat << EOF > /tmp/command |
Steve Kondik | e9f828c | 2015-11-10 23:51:21 +0100 | [diff] [blame] | 763 | --sideload_auto_reboot |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 764 | EOF |
Steve Kondik | 464574f | 2013-04-13 07:19:52 -0700 | [diff] [blame] | 765 | if adb push /tmp/command /cache/recovery/ ; then |
| 766 | echo "Rebooting into recovery for sideload installation" |
| 767 | adb reboot recovery |
| 768 | adb wait-for-sideload |
| 769 | adb sideload $ZIPPATH |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 770 | fi |
Steve Kondik | 464574f | 2013-04-13 07:19:52 -0700 | [diff] [blame] | 771 | rm /tmp/command |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 772 | else |
| 773 | echo "Nothing to eat" |
| 774 | return 1 |
| 775 | fi |
| 776 | return $? |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 777 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 778 | echo "The connected device does not appear to be $BLISS_BUILD, run away!" |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 779 | fi |
Ricardo Cerqueira | dbc3c4e | 2011-08-19 20:37:12 +0100 | [diff] [blame] | 780 | } |
| 781 | |
Nebojsa Cvetkovic | d5c0c87 | 2012-11-09 23:02:54 +0000 | [diff] [blame] | 782 | function omnom |
| 783 | { |
| 784 | brunch $* |
| 785 | eat |
| 786 | } |
| 787 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 788 | function gettop |
| 789 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 790 | local TOPFILE=build/core/envsetup.mk |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 791 | if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then |
Brian Carlstrom | a5c4f17 | 2014-09-12 00:33:25 -0700 | [diff] [blame] | 792 | # The following circumlocution ensures we remove symlinks from TOP. |
| 793 | (cd $TOP; PWD= /bin/pwd) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 794 | else |
| 795 | if [ -f $TOPFILE ] ; then |
Dan Bornstein | d0b274d | 2009-11-24 15:48:50 -0800 | [diff] [blame] | 796 | # The following circumlocution (repeated below as well) ensures |
| 797 | # that we record the true directory name and not one that is |
| 798 | # faked up with symlink names. |
| 799 | PWD= /bin/pwd |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 800 | else |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 801 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 802 | T= |
| 803 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 804 | \cd .. |
synergy | b112a40 | 2013-07-05 19:47:47 -0700 | [diff] [blame] | 805 | T=`PWD= /bin/pwd -P` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 806 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 807 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 808 | if [ -f "$T/$TOPFILE" ]; then |
| 809 | echo $T |
| 810 | fi |
| 811 | fi |
| 812 | fi |
| 813 | } |
| 814 | |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 815 | # Return driver for "make", if any (eg. static analyzer) |
| 816 | function getdriver() |
| 817 | { |
| 818 | local T="$1" |
| 819 | test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER |
| 820 | if [ -n "$WITH_STATIC_ANALYZER" ]; then |
| 821 | echo "\ |
Andrew Hsieh | c4f7fba | 2014-03-03 16:53:17 +0800 | [diff] [blame] | 822 | $T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \ |
| 823 | --use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \ |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 824 | --status-bugs \ |
| 825 | --top=$T" |
| 826 | fi |
| 827 | } |
| 828 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 829 | function m() |
| 830 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 831 | local T=$(gettop) |
| 832 | local DRV=$(getdriver $T) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 833 | if [ "$T" ]; then |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 834 | $DRV make -C $T -f build/core/main.mk $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 835 | else |
| 836 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 837 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 838 | fi |
| 839 | } |
| 840 | |
| 841 | function findmakefile() |
| 842 | { |
| 843 | TOPFILE=build/core/envsetup.mk |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 844 | local HERE=$PWD |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 845 | T= |
| 846 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
Ying Wang | 11b15b1 | 2012-10-11 15:05:07 -0700 | [diff] [blame] | 847 | T=`PWD= /bin/pwd` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 848 | if [ -f "$T/Android.mk" ]; then |
| 849 | echo $T/Android.mk |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 850 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 851 | return |
| 852 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 853 | \cd .. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 854 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 855 | \cd $HERE |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 856 | } |
| 857 | |
| 858 | function mm() |
| 859 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 860 | local T=$(gettop) |
| 861 | local DRV=$(getdriver $T) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 862 | # If we're sitting in the root of the build tree, just do a |
| 863 | # normal make. |
| 864 | if [ -f build/core/envsetup.mk -a -f Makefile ]; then |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 865 | $DRV make $@ |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 866 | else |
| 867 | # Find the closest Android.mk file. |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 868 | local M=$(findmakefile) |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 869 | local MODULES= |
| 870 | local GET_INSTALL_PATH= |
Robert Greenwalt | 3c794d7 | 2009-07-15 15:07:44 -0700 | [diff] [blame] | 871 | # Remove the path to top as the makefilepath needs to be relative |
| 872 | local M=`echo $M|sed 's:'$T'/::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 873 | if [ ! "$T" ]; then |
| 874 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 875 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 876 | elif [ ! "$M" ]; then |
| 877 | echo "Couldn't locate a makefile from the current directory." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 878 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 879 | else |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 880 | for ARG in $@; do |
| 881 | case $ARG in |
| 882 | GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;; |
| 883 | esac |
| 884 | done |
| 885 | if [ -n "$GET_INSTALL_PATH" ]; then |
| 886 | MODULES= |
Khalid Zubair | cbf9692 | 2016-03-02 14:01:45 -0800 | [diff] [blame] | 887 | # set all args to 'GET-INSTALL-PATH' |
| 888 | set -- GET-INSTALL-PATH |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 889 | else |
| 890 | MODULES=all_modules |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 891 | fi |
Khalid Zubair | cbf9692 | 2016-03-02 14:01:45 -0800 | [diff] [blame] | 892 | ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 893 | fi |
| 894 | fi |
| 895 | } |
| 896 | |
| 897 | function mmm() |
| 898 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 899 | local T=$(gettop) |
| 900 | local DRV=$(getdriver $T) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 901 | if [ "$T" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 902 | local MAKEFILE= |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 903 | local MODULES= |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 904 | local ARGS= |
| 905 | local DIR TO_CHOP |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 906 | local GET_INSTALL_PATH= |
Khalid Zubair | 521aa1e | 2016-02-11 14:34:12 -0800 | [diff] [blame] | 907 | |
Roman Birg | 5771f5d | 2016-03-01 10:27:51 -0800 | [diff] [blame] | 908 | if [ "$(__detect_shell)" = "zsh" ]; then |
Khalid Zubair | 521aa1e | 2016-02-11 14:34:12 -0800 | [diff] [blame] | 909 | set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 910 | set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 911 | else |
| 912 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 913 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 914 | fi |
| 915 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 916 | for DIR in $DIRS ; do |
Alon Albert | 68895a9 | 2011-11-30 12:40:19 -0800 | [diff] [blame] | 917 | MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'` |
| 918 | if [ "$MODULES" = "" ]; then |
| 919 | MODULES=all_modules |
| 920 | fi |
| 921 | DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 922 | if [ -f $DIR/Android.mk ]; then |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 923 | local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '` |
| 924 | local TO_CHOP=`expr $TO_CHOP + 1` |
| 925 | local START=`PWD= /bin/pwd` |
| 926 | local MFILE=`echo $START | cut -c${TO_CHOP}-` |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 927 | if [ "$MFILE" = "" ] ; then |
| 928 | MFILE=$DIR/Android.mk |
| 929 | else |
| 930 | MFILE=$MFILE/$DIR/Android.mk |
| 931 | fi |
| 932 | MAKEFILE="$MAKEFILE $MFILE" |
| 933 | else |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 934 | case $DIR in |
Adrian Roos | afa958f | 2015-03-05 19:52:55 +0100 | [diff] [blame] | 935 | showcommands | snod | dist | incrementaljavac | *=*) ARGS="$ARGS $DIR";; |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 936 | GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;; |
Abhinav1997 | c3eb107 | 2015-10-18 19:49:13 +0200 | [diff] [blame] | 937 | *) if [ -d $DIR ]; then |
| 938 | echo "No Android.mk in $DIR."; |
| 939 | else |
| 940 | echo "Couldn't locate the directory $DIR"; |
| 941 | fi |
| 942 | return 1;; |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 943 | esac |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 944 | fi |
| 945 | done |
Ying Wang | a7deb08 | 2013-08-16 13:24:47 -0700 | [diff] [blame] | 946 | if [ -n "$GET_INSTALL_PATH" ]; then |
| 947 | ARGS=$GET_INSTALL_PATH |
| 948 | MODULES= |
| 949 | fi |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 950 | ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 951 | else |
| 952 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 953 | return 1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 954 | fi |
| 955 | } |
| 956 | |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 957 | function mma() |
| 958 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 959 | local T=$(gettop) |
| 960 | local DRV=$(getdriver $T) |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 961 | if [ -f build/core/envsetup.mk -a -f Makefile ]; then |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 962 | $DRV make $@ |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 963 | else |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 964 | if [ ! "$T" ]; then |
| 965 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 966 | return 1 |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 967 | fi |
| 968 | local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'` |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 969 | $DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD" |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 970 | fi |
| 971 | } |
| 972 | |
| 973 | function mmma() |
| 974 | { |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 975 | local T=$(gettop) |
| 976 | local DRV=$(getdriver $T) |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 977 | if [ "$T" ]; then |
Roman Birg | 5771f5d | 2016-03-01 10:27:51 -0800 | [diff] [blame] | 978 | if [ "$(__detect_shell)" = "zsh" ]; then |
Khalid Zubair | 521aa1e | 2016-02-11 14:34:12 -0800 | [diff] [blame] | 979 | set -lA DASH_ARGS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 980 | set -lA DIRS $(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 981 | else |
| 982 | local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/') |
| 983 | local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/') |
| 984 | fi |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 985 | local MY_PWD=`PWD= /bin/pwd` |
| 986 | if [ "$MY_PWD" = "$T" ]; then |
| 987 | MY_PWD= |
| 988 | else |
| 989 | MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'` |
| 990 | fi |
| 991 | local DIR= |
| 992 | local MODULE_PATHS= |
| 993 | local ARGS= |
| 994 | for DIR in $DIRS ; do |
| 995 | if [ -d $DIR ]; then |
| 996 | if [ "$MY_PWD" = "" ]; then |
| 997 | MODULE_PATHS="$MODULE_PATHS $DIR" |
| 998 | else |
| 999 | MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR" |
| 1000 | fi |
| 1001 | else |
| 1002 | case $DIR in |
Adrian Roos | afa958f | 2015-03-05 19:52:55 +0100 | [diff] [blame] | 1003 | showcommands | snod | dist | incrementaljavac | *=*) ARGS="$ARGS $DIR";; |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 1004 | *) echo "Couldn't find directory $DIR"; return 1;; |
| 1005 | esac |
| 1006 | fi |
| 1007 | done |
Andrew Hsieh | 906cb78 | 2013-09-10 17:37:14 +0800 | [diff] [blame] | 1008 | $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS" |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 1009 | else |
| 1010 | echo "Couldn't locate the top of the tree. Try setting TOP." |
Ying Wang | 0c1374c | 2015-04-01 10:13:02 -0700 | [diff] [blame] | 1011 | return 1 |
Ying Wang | b607f7b | 2013-02-08 18:01:04 -0800 | [diff] [blame] | 1012 | fi |
| 1013 | } |
| 1014 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1015 | function croot() |
| 1016 | { |
| 1017 | T=$(gettop) |
| 1018 | if [ "$T" ]; then |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1019 | \cd $(gettop) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1020 | else |
| 1021 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1022 | fi |
| 1023 | } |
| 1024 | |
nebkat | fb67a1e | 2012-12-28 10:40:45 +0000 | [diff] [blame] | 1025 | function cout() |
| 1026 | { |
| 1027 | if [ "$OUT" ]; then |
| 1028 | cd $OUT |
| 1029 | else |
| 1030 | echo "Couldn't locate out directory. Try setting OUT." |
| 1031 | fi |
| 1032 | } |
| 1033 | |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1034 | function cproj() |
| 1035 | { |
| 1036 | TOPFILE=build/core/envsetup.mk |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1037 | local HERE=$PWD |
| 1038 | T= |
| 1039 | while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do |
| 1040 | T=$PWD |
| 1041 | if [ -f "$T/Android.mk" ]; then |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1042 | \cd $T |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1043 | return |
| 1044 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1045 | \cd .. |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1046 | done |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1047 | \cd $HERE |
Joe Onorato | 2a5d4d8 | 2009-07-30 10:23:21 -0700 | [diff] [blame] | 1048 | echo "can't find Android.mk" |
| 1049 | } |
| 1050 | |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1051 | # simplified version of ps; output in the form |
| 1052 | # <pid> <procname> |
| 1053 | function qpid() { |
| 1054 | local prepend='' |
| 1055 | local append='' |
| 1056 | if [ "$1" = "--exact" ]; then |
| 1057 | prepend=' ' |
| 1058 | append='$' |
| 1059 | shift |
| 1060 | elif [ "$1" = "--help" -o "$1" = "-h" ]; then |
| 1061 | echo "usage: qpid [[--exact] <process name|pid>" |
| 1062 | return 255 |
| 1063 | fi |
| 1064 | |
| 1065 | local EXE="$1" |
| 1066 | if [ "$EXE" ] ; then |
Mathias Agopian | 4458327 | 2013-08-27 14:15:50 -0700 | [diff] [blame] | 1067 | qpid | \grep "$prepend$EXE$append" |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1068 | else |
| 1069 | adb shell ps \ |
| 1070 | | tr -d '\r' \ |
| 1071 | | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/' |
| 1072 | fi |
| 1073 | } |
| 1074 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1075 | function pid() |
| 1076 | { |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1077 | local prepend='' |
| 1078 | local append='' |
| 1079 | if [ "$1" = "--exact" ]; then |
| 1080 | prepend=' ' |
| 1081 | append='$' |
| 1082 | shift |
| 1083 | fi |
| 1084 | local EXE="$1" |
| 1085 | if [ "$EXE" ] ; then |
| 1086 | local PID=`adb shell ps \ |
| 1087 | | tr -d '\r' \ |
Mathias Agopian | 4458327 | 2013-08-27 14:15:50 -0700 | [diff] [blame] | 1088 | | \grep "$prepend$EXE$append" \ |
Daniel Sandler | 47e0a88 | 2013-07-30 13:23:52 -0400 | [diff] [blame] | 1089 | | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'` |
| 1090 | echo "$PID" |
| 1091 | else |
| 1092 | echo "usage: pid [--exact] <process name>" |
| 1093 | return 255 |
| 1094 | fi |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1095 | } |
| 1096 | |
Iliyan Malchev | e675cfb | 2014-11-03 17:04:47 -0800 | [diff] [blame] | 1097 | # coredump_setup - enable core dumps globally for any process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1098 | # that has the core-file-size limit set correctly |
| 1099 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1100 | # NOTE: You must call also coredump_enable for a specific process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1101 | # if its core-file-size limit is not set already. |
| 1102 | # NOTE: Core dumps are written to ramdisk; they will not survive a reboot! |
| 1103 | |
Iliyan Malchev | e675cfb | 2014-11-03 17:04:47 -0800 | [diff] [blame] | 1104 | function coredump_setup() |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1105 | { |
| 1106 | echo "Getting root..."; |
| 1107 | adb root; |
| 1108 | adb wait-for-device; |
| 1109 | |
| 1110 | echo "Remounting root parition read-write..."; |
| 1111 | adb shell mount -w -o remount -t rootfs rootfs; |
| 1112 | sleep 1; |
| 1113 | adb wait-for-device; |
| 1114 | adb shell mkdir -p /cores; |
Nick Kralevich | a94282c | 2014-11-04 11:17:20 -0800 | [diff] [blame] | 1115 | adb shell mount -t tmpfs tmpfs /cores; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1116 | adb shell chmod 0777 /cores; |
| 1117 | |
| 1118 | echo "Granting SELinux permission to dump in /cores..."; |
| 1119 | adb shell restorecon -R /cores; |
| 1120 | |
| 1121 | echo "Set core pattern."; |
| 1122 | adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern'; |
| 1123 | |
| 1124 | echo "Done." |
| 1125 | } |
| 1126 | |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1127 | # coredump_enable - enable core dumps for the specified process |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1128 | # $1 = PID of process (e.g., $(pid mediaserver)) |
| 1129 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1130 | # NOTE: coredump_setup must have been called as well for a core |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1131 | # dump to actually be generated. |
| 1132 | |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1133 | function coredump_enable() |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1134 | { |
| 1135 | local PID=$1; |
| 1136 | if [ -z "$PID" ]; then |
| 1137 | printf "Expecting a PID!\n"; |
| 1138 | return; |
| 1139 | fi; |
| 1140 | echo "Setting core limit for $PID to infinite..."; |
| 1141 | adb shell prlimit $PID 4 -1 -1 |
| 1142 | } |
| 1143 | |
| 1144 | # core - send SIGV and pull the core for process |
| 1145 | # $1 = PID of process (e.g., $(pid mediaserver)) |
| 1146 | # |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1147 | # 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] | 1148 | # enabled globally. |
| 1149 | |
| 1150 | function core() |
| 1151 | { |
| 1152 | local PID=$1; |
| 1153 | |
| 1154 | if [ -z "$PID" ]; then |
| 1155 | printf "Expecting a PID!\n"; |
| 1156 | return; |
| 1157 | fi; |
| 1158 | |
| 1159 | local CORENAME=core.$PID; |
| 1160 | local COREPATH=/cores/$CORENAME; |
| 1161 | local SIG=SEGV; |
| 1162 | |
Iliyan Malchev | af5de97 | 2014-11-04 20:57:37 -0800 | [diff] [blame] | 1163 | coredump_enable $1; |
Iliyan Malchev | 248f4d5 | 2014-10-28 18:00:42 -0700 | [diff] [blame] | 1164 | |
| 1165 | local done=0; |
| 1166 | while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do |
| 1167 | printf "\tSending SIG%s to %d...\n" $SIG $PID; |
| 1168 | adb shell kill -$SIG $PID; |
| 1169 | sleep 1; |
| 1170 | done; |
| 1171 | |
| 1172 | adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done" |
| 1173 | echo "Done: core is under $COREPATH on device."; |
| 1174 | } |
| 1175 | |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 1176 | # systemstack - dump the current stack trace of all threads in the system process |
| 1177 | # to the usual ANR traces file |
| 1178 | function systemstack() |
| 1179 | { |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1180 | stacks system_server |
| 1181 | } |
| 1182 | |
| 1183 | function stacks() |
| 1184 | { |
| 1185 | if [[ $1 =~ ^[0-9]+$ ]] ; then |
| 1186 | local PID="$1" |
| 1187 | elif [ "$1" ] ; then |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1188 | local PIDLIST="$(pid $1)" |
| 1189 | if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then |
| 1190 | local PID="$PIDLIST" |
| 1191 | elif [ "$PIDLIST" ] ; then |
| 1192 | echo "more than one process: $1" |
| 1193 | else |
| 1194 | echo "no such process: $1" |
| 1195 | fi |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1196 | else |
| 1197 | echo "usage: stacks [pid|process name]" |
| 1198 | fi |
| 1199 | |
| 1200 | if [ "$PID" ] ; then |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1201 | # Determine whether the process is native |
| 1202 | if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then |
| 1203 | # Dump stacks of Dalvik process |
| 1204 | local TRACES=/data/anr/traces.txt |
| 1205 | local ORIG=/data/anr/traces.orig |
| 1206 | local TMP=/data/anr/traces.tmp |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1207 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1208 | # Keep original traces to avoid clobbering |
| 1209 | adb shell mv $TRACES $ORIG |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1210 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1211 | # Make sure we have a usable file |
| 1212 | adb shell touch $TRACES |
| 1213 | adb shell chmod 666 $TRACES |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1214 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1215 | # Dump stacks and wait for dump to finish |
| 1216 | adb shell kill -3 $PID |
| 1217 | adb shell notify $TRACES >/dev/null |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1218 | |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1219 | # Restore original stacks, and show current output |
| 1220 | adb shell mv $TRACES $TMP |
| 1221 | adb shell mv $ORIG $TRACES |
| 1222 | adb shell cat $TMP |
| 1223 | else |
| 1224 | # Dump stacks of native process |
Michael Wright | aeed721 | 2014-06-19 19:58:12 -0700 | [diff] [blame] | 1225 | local USE64BIT="$(is64bit $PID)" |
| 1226 | adb shell debuggerd$USE64BIT -b $PID |
Jeff Brown | b12c2e5 | 2013-08-19 15:14:16 -0700 | [diff] [blame] | 1227 | fi |
Jeff Sharkey | f582437 | 2013-02-19 17:00:46 -0800 | [diff] [blame] | 1228 | fi |
Christopher Tate | 744ee80 | 2009-11-12 15:33:08 -0800 | [diff] [blame] | 1229 | } |
| 1230 | |
Michael Wright | aeed721 | 2014-06-19 19:58:12 -0700 | [diff] [blame] | 1231 | # Read the ELF header from /proc/$PID/exe to determine if the process is |
| 1232 | # 64-bit. |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 1233 | function is64bit() |
| 1234 | { |
| 1235 | local PID="$1" |
| 1236 | if [ "$PID" ] ; then |
Michael Wright | aeed721 | 2014-06-19 19:58:12 -0700 | [diff] [blame] | 1237 | if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -ps)" -eq "02" ]] ; then |
Ben Cheng | fba67bf | 2014-02-25 10:27:07 -0800 | [diff] [blame] | 1238 | echo "64" |
| 1239 | else |
| 1240 | echo "" |
| 1241 | fi |
| 1242 | else |
| 1243 | echo "" |
| 1244 | fi |
| 1245 | } |
| 1246 | |
Clark Scheff | 75b36a4 | 2014-12-23 13:30:51 -0800 | [diff] [blame] | 1247 | function dddclient() |
| 1248 | { |
| 1249 | local OUT_ROOT=$(get_abs_build_var PRODUCT_OUT) |
| 1250 | local OUT_SYMBOLS=$(get_abs_build_var TARGET_OUT_UNSTRIPPED) |
| 1251 | local OUT_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED) |
| 1252 | local OUT_VENDOR_SO_SYMBOLS=$(get_abs_build_var TARGET_OUT_VENDOR_SHARED_LIBRARIES_UNSTRIPPED) |
| 1253 | local OUT_EXE_SYMBOLS=$(get_symbols_directory) |
| 1254 | local PREBUILTS=$(get_abs_build_var ANDROID_PREBUILTS) |
| 1255 | local ARCH=$(get_build_var TARGET_ARCH) |
| 1256 | local GDB |
| 1257 | case "$ARCH" in |
| 1258 | arm) GDB=arm-linux-androideabi-gdb;; |
| 1259 | arm64) GDB=arm-linux-androideabi-gdb; GDB64=aarch64-linux-android-gdb;; |
| 1260 | mips|mips64) GDB=mips64el-linux-android-gdb;; |
| 1261 | x86) GDB=x86_64-linux-android-gdb;; |
| 1262 | x86_64) GDB=x86_64-linux-android-gdb;; |
| 1263 | *) echo "Unknown arch $ARCH"; return 1;; |
| 1264 | esac |
| 1265 | |
| 1266 | if [ "$OUT_ROOT" -a "$PREBUILTS" ]; then |
| 1267 | local EXE="$1" |
| 1268 | if [ "$EXE" ] ; then |
| 1269 | EXE=$1 |
| 1270 | if [[ $EXE =~ ^[^/].* ]] ; then |
| 1271 | EXE="system/bin/"$EXE |
| 1272 | fi |
| 1273 | else |
| 1274 | EXE="app_process" |
| 1275 | fi |
| 1276 | |
| 1277 | local PORT="$2" |
| 1278 | if [ "$PORT" ] ; then |
| 1279 | PORT=$2 |
| 1280 | else |
| 1281 | PORT=":5039" |
| 1282 | fi |
| 1283 | |
| 1284 | local PID="$3" |
| 1285 | if [ "$PID" ] ; then |
| 1286 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
| 1287 | PID=`pid $3` |
| 1288 | if [[ ! "$PID" =~ ^[0-9]+$ ]] ; then |
| 1289 | # that likely didn't work because of returning multiple processes |
| 1290 | # try again, filtering by root processes (don't contain colon) |
| 1291 | PID=`adb shell ps | \grep $3 | \grep -v ":" | awk '{print $2}'` |
| 1292 | if [[ ! "$PID" =~ ^[0-9]+$ ]] |
| 1293 | then |
| 1294 | echo "Couldn't resolve '$3' to single PID" |
| 1295 | return 1 |
| 1296 | else |
| 1297 | echo "" |
| 1298 | echo "WARNING: multiple processes matching '$3' observed, using root process" |
| 1299 | echo "" |
| 1300 | fi |
| 1301 | fi |
| 1302 | fi |
| 1303 | adb forward "tcp$PORT" "tcp$PORT" |
| 1304 | local USE64BIT="$(is64bit $PID)" |
| 1305 | adb shell gdbserver$USE64BIT $PORT --attach $PID & |
| 1306 | sleep 2 |
| 1307 | else |
| 1308 | echo "" |
| 1309 | echo "If you haven't done so already, do this first on the device:" |
| 1310 | echo " gdbserver $PORT /system/bin/$EXE" |
| 1311 | echo " or" |
| 1312 | echo " gdbserver $PORT --attach <PID>" |
| 1313 | echo "" |
| 1314 | fi |
| 1315 | |
| 1316 | OUT_SO_SYMBOLS=$OUT_SO_SYMBOLS$USE64BIT |
| 1317 | OUT_VENDOR_SO_SYMBOLS=$OUT_VENDOR_SO_SYMBOLS$USE64BIT |
| 1318 | |
| 1319 | echo >|"$OUT_ROOT/gdbclient.cmds" "set solib-absolute-prefix $OUT_SYMBOLS" |
| 1320 | echo >>"$OUT_ROOT/gdbclient.cmds" "set solib-search-path $OUT_SO_SYMBOLS:$OUT_SO_SYMBOLS/hw:$OUT_SO_SYMBOLS/ssl/engines:$OUT_SO_SYMBOLS/drm:$OUT_SO_SYMBOLS/egl:$OUT_SO_SYMBOLS/soundfx:$OUT_VENDOR_SO_SYMBOLS:$OUT_VENDOR_SO_SYMBOLS/hw:$OUT_VENDOR_SO_SYMBOLS/egl" |
| 1321 | echo >>"$OUT_ROOT/gdbclient.cmds" "source $ANDROID_BUILD_TOP/development/scripts/gdb/dalvik.gdb" |
| 1322 | echo >>"$OUT_ROOT/gdbclient.cmds" "target remote $PORT" |
| 1323 | # Enable special debugging for ART processes. |
| 1324 | if [[ $EXE =~ (^|/)(app_process|dalvikvm)(|32|64)$ ]]; then |
| 1325 | echo >> "$OUT_ROOT/gdbclient.cmds" "art-on" |
| 1326 | fi |
| 1327 | echo >>"$OUT_ROOT/gdbclient.cmds" "" |
| 1328 | |
| 1329 | local WHICH_GDB= |
| 1330 | # 64-bit exe found |
| 1331 | if [ "$USE64BIT" != "" ] ; then |
| 1332 | WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB64 |
| 1333 | # 32-bit exe / 32-bit platform |
| 1334 | elif [ "$(get_build_var TARGET_2ND_ARCH)" = "" ]; then |
| 1335 | WHICH_GDB=$ANDROID_TOOLCHAIN/$GDB |
| 1336 | # 32-bit exe / 64-bit platform |
| 1337 | else |
| 1338 | WHICH_GDB=$ANDROID_TOOLCHAIN_2ND_ARCH/$GDB |
| 1339 | fi |
| 1340 | |
| 1341 | ddd --debugger $WHICH_GDB -x "$OUT_ROOT/gdbclient.cmds" "$OUT_EXE_SYMBOLS/$EXE" |
| 1342 | else |
| 1343 | echo "Unable to determine build system output dir." |
| 1344 | fi |
| 1345 | } |
| 1346 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1347 | case `uname -s` in |
| 1348 | Darwin) |
| 1349 | function sgrep() |
| 1350 | { |
Jeff Brown | 46cbd20 | 2014-07-26 15:15:41 -0700 | [diff] [blame] | 1351 | find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cc|cpp|S|java|xml|sh|mk|aidl)' -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1352 | } |
| 1353 | |
| 1354 | ;; |
| 1355 | *) |
| 1356 | function sgrep() |
| 1357 | { |
Jeff Brown | 46cbd20 | 2014-07-26 15:15:41 -0700 | [diff] [blame] | 1358 | find . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.\(c\|h\|cc\|cpp\|S\|java\|xml\|sh\|mk\|aidl\)' -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1359 | } |
| 1360 | ;; |
| 1361 | esac |
| 1362 | |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 1363 | function gettargetarch |
| 1364 | { |
| 1365 | get_build_var TARGET_ARCH |
| 1366 | } |
| 1367 | |
Jon Boekenoogen | cbca56f | 2014-04-07 10:57:38 -0700 | [diff] [blame] | 1368 | function ggrep() |
| 1369 | { |
| 1370 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" -print0 | xargs -0 grep --color -n "$@" |
| 1371 | } |
| 1372 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1373 | function jgrep() |
| 1374 | { |
Anatolii Shuba | 91c72d2 | 2013-07-05 16:09:25 +0300 | [diff] [blame] | 1375 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.java" -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1376 | } |
| 1377 | |
| 1378 | function cgrep() |
| 1379 | { |
Dan Albert | 0196119 | 2014-11-22 10:16:01 -0800 | [diff] [blame] | 1380 | 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' \) -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1381 | } |
| 1382 | |
| 1383 | function resgrep() |
| 1384 | { |
Anatolii Shuba | 91c72d2 | 2013-07-05 16:09:25 +0300 | [diff] [blame] | 1385 | for dir in `find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -name res -type d`; do find $dir -type f -name '*\.xml' -print0 | xargs -0 grep --color -n "$@"; done; |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1386 | } |
| 1387 | |
Jeff Sharkey | 50b61e9 | 2013-03-08 10:20:47 -0800 | [diff] [blame] | 1388 | function mangrep() |
| 1389 | { |
| 1390 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@" |
| 1391 | } |
| 1392 | |
Alex Klyubin | ba5fc8e | 2013-05-06 14:11:48 -0700 | [diff] [blame] | 1393 | function sepgrep() |
| 1394 | { |
| 1395 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -name sepolicy -type d -print0 | xargs -0 grep --color -n -r --exclude-dir=\.git "$@" |
| 1396 | } |
| 1397 | |
Jeff Sharkey | ea0068a | 2015-02-26 14:13:46 -0800 | [diff] [blame] | 1398 | function rcgrep() |
| 1399 | { |
| 1400 | find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" -print0 | xargs -0 grep --color -n "$@" |
| 1401 | } |
| 1402 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1403 | case `uname -s` in |
| 1404 | Darwin) |
| 1405 | function mgrep() |
| 1406 | { |
Ying Wang | 324c2b2 | 2012-08-17 15:03:20 -0700 | [diff] [blame] | 1407 | find -E . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -iregex '.*/(Makefile|Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1408 | } |
| 1409 | |
| 1410 | function treegrep() |
| 1411 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 1412 | find -E . -name .repo -prune -o -name .git -prune -o -type f -iregex '.*\.(c|h|cpp|S|java|xml)' -print0 | xargs -0 grep --color -n -i "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | ;; |
| 1416 | *) |
| 1417 | function mgrep() |
| 1418 | { |
Ying Wang | 324c2b2 | 2012-08-17 15:03:20 -0700 | [diff] [blame] | 1419 | find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -regextype posix-egrep -iregex '(.*\/Makefile|.*\/Makefile\..*|.*\.make|.*\.mak|.*\.mk)' -type f -print0 | xargs -0 grep --color -n "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | function treegrep() |
| 1423 | { |
Joe Onorato | f50e84b | 2011-03-15 14:15:46 -0700 | [diff] [blame] | 1424 | find . -name .repo -prune -o -name .git -prune -o -regextype posix-egrep -iregex '.*\.(c|h|cpp|S|java|xml)' -type f -print0 | xargs -0 grep --color -n -i "$@" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | ;; |
| 1428 | esac |
| 1429 | |
| 1430 | function getprebuilt |
| 1431 | { |
| 1432 | get_abs_build_var ANDROID_PREBUILTS |
| 1433 | } |
| 1434 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1435 | function tracedmdump() |
| 1436 | { |
| 1437 | T=$(gettop) |
| 1438 | if [ ! "$T" ]; then |
| 1439 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1440 | return |
| 1441 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1442 | local prebuiltdir=$(getprebuilt) |
Raghu Gandham | 8da4310 | 2012-07-25 19:57:22 -0700 | [diff] [blame] | 1443 | local arch=$(gettargetarch) |
| 1444 | local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1445 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1446 | local TRACE=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1447 | if [ ! "$TRACE" ] ; then |
| 1448 | echo "usage: tracedmdump tracename" |
| 1449 | return |
| 1450 | fi |
| 1451 | |
Jack Veenstra | 60116fc | 2009-04-09 18:12:34 -0700 | [diff] [blame] | 1452 | if [ ! -r "$KERNEL" ] ; then |
| 1453 | echo "Error: cannot find kernel: '$KERNEL'" |
| 1454 | return |
| 1455 | fi |
| 1456 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1457 | local BASETRACE=$(basename $TRACE) |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1458 | if [ "$BASETRACE" = "$TRACE" ] ; then |
| 1459 | TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE |
| 1460 | fi |
| 1461 | |
| 1462 | echo "post-processing traces..." |
| 1463 | rm -f $TRACE/qtrace.dexlist |
| 1464 | post_trace $TRACE |
| 1465 | if [ $? -ne 0 ]; then |
| 1466 | echo "***" |
| 1467 | echo "*** Error: malformed trace. Did you remember to exit the emulator?" |
| 1468 | echo "***" |
| 1469 | return |
| 1470 | fi |
| 1471 | echo "generating dexlist output..." |
| 1472 | /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 |
| 1473 | echo "generating dmtrace data..." |
| 1474 | q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return |
| 1475 | echo "generating html file..." |
| 1476 | dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return |
| 1477 | echo "done, see $TRACE/dmtrace.html for details" |
| 1478 | echo "or run:" |
| 1479 | echo " traceview $TRACE/dmtrace" |
| 1480 | } |
| 1481 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1482 | # communicate with a running device or emulator, set up necessary state, |
| 1483 | # and run the hat command. |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1484 | function runhat() |
| 1485 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1486 | # process standard adb options |
| 1487 | local adbTarget="" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1488 | if [ "$1" = "-d" -o "$1" = "-e" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1489 | adbTarget=$1 |
| 1490 | shift 1 |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1491 | elif [ "$1" = "-s" ]; then |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1492 | adbTarget="$1 $2" |
| 1493 | shift 2 |
| 1494 | fi |
| 1495 | local adbOptions=${adbTarget} |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1496 | #echo adbOptions = ${adbOptions} |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1497 | |
| 1498 | # runhat options |
| 1499 | local targetPid=$1 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1500 | |
| 1501 | if [ "$targetPid" = "" ]; then |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1502 | echo "Usage: runhat [ -d | -e | -s serial ] target-pid" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1503 | return |
| 1504 | fi |
| 1505 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1506 | # confirm hat is available |
| 1507 | if [ -z $(which hat) ]; then |
| 1508 | echo "hat is not available in this configuration." |
| 1509 | return |
| 1510 | fi |
| 1511 | |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1512 | # issue "am" command to cause the hprof dump |
Nick Kralevich | 9948b1e | 2014-07-18 15:45:38 -0700 | [diff] [blame] | 1513 | local devFile=/data/local/tmp/hprof-$targetPid |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1514 | echo "Poking $targetPid and waiting for data..." |
Dianne Hackborn | 6b9549f | 2012-09-26 15:00:59 -0700 | [diff] [blame] | 1515 | echo "Storing data at $devFile" |
Andy McFadden | b628985 | 2010-07-12 08:00:19 -0700 | [diff] [blame] | 1516 | adb ${adbOptions} shell am dumpheap $targetPid $devFile |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1517 | 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] | 1518 | echo -n "> " |
| 1519 | read |
| 1520 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1521 | local localFile=/tmp/$$-hprof |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1522 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1523 | echo "Retrieving file $devFile..." |
| 1524 | adb ${adbOptions} pull $devFile $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1525 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1526 | adb ${adbOptions} shell rm $devFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1527 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1528 | echo "Running hat on $localFile" |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1529 | echo "View the output by pointing your browser at http://localhost:7000/" |
| 1530 | echo "" |
Dianne Hackborn | 6e4e1bb | 2011-11-10 15:19:51 -0800 | [diff] [blame] | 1531 | hat -JXmx512m $localFile |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1532 | } |
| 1533 | |
| 1534 | function getbugreports() |
| 1535 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1536 | 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] | 1537 | |
| 1538 | if [ ! "$reports" ]; then |
| 1539 | echo "Could not locate any bugreports." |
| 1540 | return |
| 1541 | fi |
| 1542 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1543 | local report |
| 1544 | for report in ${reports[@]} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1545 | do |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1546 | echo "/sdcard/bugreports/${report}" |
| 1547 | adb pull /sdcard/bugreports/${report} ${report} |
| 1548 | gunzip ${report} |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1549 | done |
| 1550 | } |
| 1551 | |
Victoria Lease | 1b296b4 | 2012-08-21 15:44:06 -0700 | [diff] [blame] | 1552 | function getsdcardpath() |
| 1553 | { |
| 1554 | adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\} |
| 1555 | } |
| 1556 | |
| 1557 | function getscreenshotpath() |
| 1558 | { |
| 1559 | echo "$(getsdcardpath)/Pictures/Screenshots" |
| 1560 | } |
| 1561 | |
| 1562 | function getlastscreenshot() |
| 1563 | { |
| 1564 | local screenshot_path=$(getscreenshotpath) |
| 1565 | local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1` |
| 1566 | if [ "$screenshot" = "" ]; then |
| 1567 | echo "No screenshots found." |
| 1568 | return |
| 1569 | fi |
| 1570 | echo "${screenshot}" |
| 1571 | adb ${adbOptions} pull ${screenshot_path}/${screenshot} |
| 1572 | } |
| 1573 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1574 | function startviewserver() |
| 1575 | { |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1576 | local port=4939 |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1577 | if [ $# -gt 0 ]; then |
| 1578 | port=$1 |
| 1579 | fi |
| 1580 | adb shell service call window 1 i32 $port |
| 1581 | } |
| 1582 | |
| 1583 | function stopviewserver() |
| 1584 | { |
| 1585 | adb shell service call window 2 |
| 1586 | } |
| 1587 | |
| 1588 | function isviewserverstarted() |
| 1589 | { |
| 1590 | adb shell service call window 3 |
| 1591 | } |
| 1592 | |
Romain Guy | b84049a | 2010-10-04 16:56:11 -0700 | [diff] [blame] | 1593 | function key_home() |
| 1594 | { |
| 1595 | adb shell input keyevent 3 |
| 1596 | } |
| 1597 | |
| 1598 | function key_back() |
| 1599 | { |
| 1600 | adb shell input keyevent 4 |
| 1601 | } |
| 1602 | |
| 1603 | function key_menu() |
| 1604 | { |
| 1605 | adb shell input keyevent 82 |
| 1606 | } |
| 1607 | |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1608 | function smoketest() |
| 1609 | { |
| 1610 | if [ ! "$ANDROID_PRODUCT_OUT" ]; then |
| 1611 | echo "Couldn't locate output files. Try running 'lunch' first." >&2 |
| 1612 | return |
| 1613 | fi |
| 1614 | T=$(gettop) |
| 1615 | if [ ! "$T" ]; then |
| 1616 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1617 | return |
| 1618 | fi |
| 1619 | |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1620 | (\cd "$T" && mmm tests/SmokeTest) && |
The Android Open Source Project | b6c1cf6 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1621 | adb uninstall com.android.smoketest > /dev/null && |
| 1622 | adb uninstall com.android.smoketest.tests > /dev/null && |
| 1623 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk && |
| 1624 | adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk && |
| 1625 | adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner |
| 1626 | } |
| 1627 | |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 1628 | # simple shortcut to the runtest command |
| 1629 | function runtest() |
| 1630 | { |
| 1631 | T=$(gettop) |
| 1632 | if [ ! "$T" ]; then |
| 1633 | echo "Couldn't locate the top of the tree. Try setting TOP." >&2 |
| 1634 | return |
| 1635 | fi |
Brett Chabot | 3fb149d | 2009-10-21 20:05:26 -0700 | [diff] [blame] | 1636 | ("$T"/development/testrunner/runtest.py $@) |
Brett Chabot | 762748c | 2009-03-27 10:25:11 -0700 | [diff] [blame] | 1637 | } |
| 1638 | |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1639 | function godir () { |
| 1640 | if [[ -z "$1" ]]; then |
| 1641 | echo "Usage: godir <regex>" |
| 1642 | return |
| 1643 | fi |
Brian Carlstrom | b9915a6 | 2010-01-29 16:39:32 -0800 | [diff] [blame] | 1644 | T=$(gettop) |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1645 | if [ ! "$OUT_DIR" = "" ]; then |
| 1646 | mkdir -p $OUT_DIR |
| 1647 | FILELIST=$OUT_DIR/filelist |
| 1648 | else |
| 1649 | FILELIST=$T/filelist |
| 1650 | fi |
| 1651 | if [[ ! -f $FILELIST ]]; then |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1652 | echo -n "Creating index..." |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1653 | (\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] | 1654 | echo " Done" |
| 1655 | echo "" |
| 1656 | fi |
| 1657 | local lines |
Brian Carlstrom | f225742 | 2015-09-30 20:28:54 -0700 | [diff] [blame] | 1658 | lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1659 | if [[ ${#lines[@]} = 0 ]]; then |
| 1660 | echo "Not found" |
| 1661 | return |
| 1662 | fi |
| 1663 | local pathname |
| 1664 | local choice |
| 1665 | if [[ ${#lines[@]} > 1 ]]; then |
| 1666 | while [[ -z "$pathname" ]]; do |
| 1667 | local index=1 |
| 1668 | local line |
| 1669 | for line in ${lines[@]}; do |
| 1670 | printf "%6s %s\n" "[$index]" $line |
Doug Zongker | 2903498 | 2011-04-22 08:16:56 -0700 | [diff] [blame] | 1671 | index=$(($index + 1)) |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1672 | done |
| 1673 | echo |
| 1674 | echo -n "Select one: " |
| 1675 | unset choice |
| 1676 | read choice |
| 1677 | if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then |
| 1678 | echo "Invalid choice" |
| 1679 | continue |
| 1680 | fi |
Kan-Ru Chen | 0745376 | 2010-07-05 15:53:47 +0800 | [diff] [blame] | 1681 | pathname=${lines[$(($choice-1))]} |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1682 | done |
| 1683 | else |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1684 | pathname=${lines[0]} |
| 1685 | fi |
Ying Wang | 9cd1764 | 2012-12-13 10:52:07 -0800 | [diff] [blame] | 1686 | \cd $T/$pathname |
The Android Open Source Project | 88b6079 | 2009-03-03 19:28:42 -0800 | [diff] [blame] | 1687 | } |
| 1688 | |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1689 | function installboot() |
| 1690 | { |
| 1691 | if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ]; |
| 1692 | then |
| 1693 | echo "No recovery.fstab found. Build recovery first." |
| 1694 | return 1 |
| 1695 | fi |
| 1696 | if [ ! -e "$OUT/boot.img" ]; |
| 1697 | then |
| 1698 | echo "No boot.img found. Run make bootimage first." |
| 1699 | return 1 |
| 1700 | fi |
| 1701 | PARTITION=`grep "^\/boot" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 1702 | if [ -z "$PARTITION" ]; |
| 1703 | then |
Ricardo Cerqueira | 9e4c4a7 | 2013-07-27 13:51:56 +0100 | [diff] [blame] | 1704 | # Try for RECOVERY_FSTAB_VERSION = 2 |
| 1705 | PARTITION=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}` |
| 1706 | PARTITION_TYPE=`grep "[[:space:]]\/boot[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 1707 | if [ -z "$PARTITION" ]; |
| 1708 | then |
| 1709 | echo "Unable to determine boot partition." |
| 1710 | return 1 |
| 1711 | fi |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1712 | fi |
| 1713 | adb start-server |
Steve Kondik | 3bc5cfd | 2013-08-30 17:34:37 -0700 | [diff] [blame] | 1714 | adb wait-for-online |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1715 | adb root |
| 1716 | sleep 1 |
Steve Kondik | 21e4f7f | 2013-04-13 13:23:35 -0700 | [diff] [blame] | 1717 | adb wait-for-online shell mount /system 2>&1 > /dev/null |
| 1718 | adb wait-for-online remount |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1719 | if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD"); |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1720 | then |
| 1721 | adb push $OUT/boot.img /cache/ |
| 1722 | for i in $OUT/system/lib/modules/*; |
| 1723 | do |
| 1724 | adb push $i /system/lib/modules/ |
| 1725 | done |
| 1726 | adb shell dd if=/cache/boot.img of=$PARTITION |
| 1727 | adb shell chmod 644 /system/lib/modules/* |
| 1728 | echo "Installation complete." |
| 1729 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1730 | echo "The connected device does not appear to be $BLISS_BUILD, run away!" |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1731 | fi |
| 1732 | } |
| 1733 | |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 1734 | function installrecovery() |
| 1735 | { |
| 1736 | if [ ! -e "$OUT/recovery/root/etc/recovery.fstab" ]; |
| 1737 | then |
| 1738 | echo "No recovery.fstab found. Build recovery first." |
| 1739 | return 1 |
| 1740 | fi |
| 1741 | if [ ! -e "$OUT/recovery.img" ]; |
| 1742 | then |
| 1743 | echo "No recovery.img found. Run make recoveryimage first." |
| 1744 | return 1 |
| 1745 | fi |
| 1746 | PARTITION=`grep "^\/recovery" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
| 1747 | if [ -z "$PARTITION" ]; |
| 1748 | then |
Steve Kondik | 75f1076 | 2013-08-09 21:03:42 -0700 | [diff] [blame] | 1749 | # Try for RECOVERY_FSTAB_VERSION = 2 |
Steve Kondik | d8b510a | 2013-08-10 21:02:09 -0700 | [diff] [blame] | 1750 | PARTITION=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $1'}` |
| 1751 | PARTITION_TYPE=`grep "[[:space:]]\/recovery[[:space:]]" $OUT/recovery/root/etc/recovery.fstab | awk {'print $3'}` |
Steve Kondik | 75f1076 | 2013-08-09 21:03:42 -0700 | [diff] [blame] | 1752 | if [ -z "$PARTITION" ]; |
| 1753 | then |
| 1754 | echo "Unable to determine recovery partition." |
| 1755 | return 1 |
| 1756 | fi |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 1757 | fi |
| 1758 | adb start-server |
Steve Kondik | 3bc5cfd | 2013-08-30 17:34:37 -0700 | [diff] [blame] | 1759 | adb wait-for-online |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 1760 | adb root |
| 1761 | sleep 1 |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1762 | adb wait-for-online shell mount /system 2>&1 > /dev/null |
Steve Kondik | 21e4f7f | 2013-04-13 13:23:35 -0700 | [diff] [blame] | 1763 | adb wait-for-online remount |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1764 | if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD"); |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 1765 | then |
| 1766 | adb push $OUT/recovery.img /cache/ |
| 1767 | adb shell dd if=/cache/recovery.img of=$PARTITION |
| 1768 | echo "Installation complete." |
| 1769 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1770 | echo "The connected device does not appear to be $BLISS_BUILD, run away!" |
Steve Kondik | 83c03d5 | 2012-10-24 16:40:42 -0700 | [diff] [blame] | 1771 | fi |
| 1772 | } |
Steve Kondik | f00e7d9 | 2012-09-23 23:46:55 -0700 | [diff] [blame] | 1773 | |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 1774 | function mka() { |
Khalid Zubair | abcd194 | 2015-10-06 11:00:55 -0700 | [diff] [blame] | 1775 | local T=$(gettop) |
| 1776 | if [ "$T" ]; then |
| 1777 | case `uname -s` in |
| 1778 | Darwin) |
| 1779 | make -C $T -j `sysctl hw.ncpu|cut -d" " -f2` "$@" |
| 1780 | ;; |
| 1781 | *) |
| 1782 | mk_timer schedtool -B -n 1 -e ionice -n 1 make -C $T -j$(cat /proc/cpuinfo | grep "^processor" | wc -l) "$@" |
| 1783 | ;; |
| 1784 | esac |
| 1785 | |
| 1786 | else |
| 1787 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1788 | fi |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 1789 | } |
| 1790 | |
Chirayu Desai | cf2bdb6 | 2012-09-28 11:56:02 +0530 | [diff] [blame] | 1791 | function cmka() { |
| 1792 | if [ ! -z "$1" ]; then |
| 1793 | for i in "$@"; do |
| 1794 | case $i in |
| 1795 | bacon|otapackage|systemimage) |
| 1796 | mka installclean |
| 1797 | mka $i |
| 1798 | ;; |
| 1799 | *) |
| 1800 | mka clean-$i |
| 1801 | mka $i |
| 1802 | ;; |
| 1803 | esac |
| 1804 | done |
| 1805 | else |
| 1806 | mka clean |
| 1807 | mka |
| 1808 | fi |
| 1809 | } |
| 1810 | |
Khalid Zubair | fdc26cd | 2015-10-21 12:43:14 -0700 | [diff] [blame] | 1811 | function mms() { |
| 1812 | local T=$(gettop) |
| 1813 | if [ -z "$T" ] |
| 1814 | then |
| 1815 | echo "Couldn't locate the top of the tree. Try setting TOP." |
| 1816 | return 1 |
| 1817 | fi |
| 1818 | |
| 1819 | case `uname -s` in |
| 1820 | Darwin) |
| 1821 | local NUM_CPUS=$(sysctl hw.ncpu|cut -d" " -f2) |
| 1822 | ONE_SHOT_MAKEFILE="__none__" \ |
| 1823 | make -C $T -j $NUM_CPUS "$@" |
| 1824 | ;; |
| 1825 | *) |
| 1826 | local NUM_CPUS=$(cat /proc/cpuinfo | grep "^processor" | wc -l) |
| 1827 | ONE_SHOT_MAKEFILE="__none__" \ |
| 1828 | mk_timer schedtool -B -n 1 -e ionice -n 1 \ |
| 1829 | make -C $T -j $NUM_CPUS "$@" |
| 1830 | ;; |
| 1831 | esac |
| 1832 | } |
| 1833 | |
| 1834 | |
Matt Mower | 8dacaed | 2013-12-29 12:57:20 -0600 | [diff] [blame] | 1835 | function repolastsync() { |
| 1836 | RLSPATH="$ANDROID_BUILD_TOP/.repo/.repo_fetchtimes.json" |
| 1837 | RLSLOCAL=$(date -d "$(stat -c %z $RLSPATH)" +"%e %b %Y, %T %Z") |
| 1838 | RLSUTC=$(date -d "$(stat -c %z $RLSPATH)" -u +"%e %b %Y, %T %Z") |
| 1839 | echo "Last repo sync: $RLSLOCAL / $RLSUTC" |
| 1840 | } |
| 1841 | |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 1842 | function reposync() { |
| 1843 | case `uname -s` in |
| 1844 | Darwin) |
| 1845 | repo sync -j 4 "$@" |
| 1846 | ;; |
| 1847 | *) |
Alan Orth | ef363cd | 2012-09-07 11:44:27 +0300 | [diff] [blame] | 1848 | schedtool -B -n 1 -e ionice -n 1 `which repo` sync -j 4 "$@" |
Andrew Sutherland | d6bd065 | 2011-11-18 00:45:55 -0600 | [diff] [blame] | 1849 | ;; |
| 1850 | esac |
| 1851 | } |
Tanguy Pruvot | 2192fd2 | 2012-06-06 21:39:23 +0200 | [diff] [blame] | 1852 | |
| 1853 | function repodiff() { |
| 1854 | if [ -z "$*" ]; then |
| 1855 | echo "Usage: repodiff <ref-from> [[ref-to] [--numstat]]" |
| 1856 | return |
| 1857 | fi |
| 1858 | diffopts=$* repo forall -c \ |
| 1859 | 'echo "$REPO_PATH ($REPO_REMOTE)"; git diff ${diffopts} 2>/dev/null ;' |
| 1860 | } |
| 1861 | |
Khalid Zubair | 63eabff | 2016-02-02 12:00:14 -0800 | [diff] [blame] | 1862 | # Return success if adb is up and not in recovery |
| 1863 | function _adb_connected { |
| 1864 | { |
| 1865 | if [[ "$(adb get-state)" == device && |
| 1866 | "$(adb shell test -e /sbin/recovery; echo $?)" == 0 ]] |
| 1867 | then |
| 1868 | return 0 |
| 1869 | fi |
| 1870 | } 2>/dev/null |
| 1871 | |
| 1872 | return 1 |
| 1873 | }; |
| 1874 | |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1875 | # Credit for color strip sed: http://goo.gl/BoIcm |
| 1876 | function dopush() |
| 1877 | { |
| 1878 | local func=$1 |
| 1879 | shift |
| 1880 | |
| 1881 | adb start-server # Prevent unexpected starting server message from adb get-state in the next line |
Khalid Zubair | 63eabff | 2016-02-02 12:00:14 -0800 | [diff] [blame] | 1882 | if ! _adb_connected; then |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1883 | echo "No device is online. Waiting for one..." |
| 1884 | echo "Please connect USB and/or enable USB debugging" |
Khalid Zubair | 63eabff | 2016-02-02 12:00:14 -0800 | [diff] [blame] | 1885 | until _adb_connected; do |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1886 | sleep 1 |
| 1887 | done |
| 1888 | echo "Device Found." |
| 1889 | fi |
| 1890 | |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 1891 | if (adb shell getprop ro.bliss.device | grep -q "$BLISS_BUILD") || [ "$FORCE_PUSH" == "true" ]; |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 1892 | then |
Sam Mortimer | 9e0a3f7 | 2013-08-10 22:57:08 -0700 | [diff] [blame] | 1893 | # retrieve IP and PORT info if we're using a TCP connection |
| 1894 | TCPIPPORT=$(adb devices | egrep '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:[0-9]+[^0-9]+' \ |
| 1895 | | head -1 | awk '{print $1}') |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1896 | adb root &> /dev/null |
| 1897 | sleep 0.3 |
Sam Mortimer | 9e0a3f7 | 2013-08-10 22:57:08 -0700 | [diff] [blame] | 1898 | if [ -n "$TCPIPPORT" ] |
| 1899 | then |
| 1900 | # adb root just killed our connection |
| 1901 | # so reconnect... |
| 1902 | adb connect "$TCPIPPORT" |
| 1903 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1904 | adb wait-for-device &> /dev/null |
| 1905 | sleep 0.3 |
| 1906 | adb remount &> /dev/null |
| 1907 | |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1908 | mkdir -p $OUT |
Marcos Marado | 37e92c2 | 2015-01-13 15:14:28 +0000 | [diff] [blame] | 1909 | ($func $*|tee $OUT/.log;return ${PIPESTATUS[0]}) |
| 1910 | ret=$?; |
| 1911 | if [ $ret -ne 0 ]; then |
| 1912 | rm -f $OUT/.log;return $ret |
| 1913 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1914 | |
| 1915 | # Install: <file> |
LuK1337 | 56041e7 | 2015-12-01 14:53:23 +0100 | [diff] [blame] | 1916 | if [ `uname` = "Linux" ]; then |
| 1917 | LOC="$(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Install: ' | cut -d ':' -f 2)" |
| 1918 | else |
| 1919 | LOC="$(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Install: ' | cut -d ':' -f 2)" |
| 1920 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1921 | |
| 1922 | # Copy: <file> |
LuK1337 | 56041e7 | 2015-12-01 14:53:23 +0100 | [diff] [blame] | 1923 | if [ `uname` = "Linux" ]; then |
| 1924 | LOC="$LOC $(cat $OUT/.log | sed -r 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g' | grep '^Copy: ' | cut -d ':' -f 2)" |
| 1925 | else |
| 1926 | LOC="$LOC $(cat $OUT/.log | sed -E "s/"$'\E'"\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | grep '^Copy: ' | cut -d ':' -f 2)" |
| 1927 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1928 | |
Matt Mower | dfd4c08 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1929 | # If any files are going to /data, push an octal file permissions reader to device |
| 1930 | if [ -n "$(echo $LOC | egrep '(^|\s)/data')" ]; then |
| 1931 | CHKPERM="/data/local/tmp/chkfileperm.sh" |
| 1932 | ( |
| 1933 | cat <<'EOF' |
| 1934 | #!/system/xbin/sh |
| 1935 | FILE=$@ |
| 1936 | if [ -e $FILE ]; then |
| 1937 | ls -l $FILE | awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o ",k);print}' | cut -d ' ' -f1 |
| 1938 | fi |
| 1939 | EOF |
| 1940 | ) > $OUT/.chkfileperm.sh |
| 1941 | echo "Pushing file permissions checker to device" |
| 1942 | adb push $OUT/.chkfileperm.sh $CHKPERM |
| 1943 | adb shell chmod 755 $CHKPERM |
| 1944 | rm -f $OUT/.chkfileperm.sh |
| 1945 | fi |
| 1946 | |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1947 | stop_n_start=false |
Luca Stefani | 406c2af | 2015-11-02 05:33:10 -0800 | [diff] [blame] | 1948 | for FILE in $(echo $LOC | tr " " "\n"); do |
Matt Mower | dfd4c08 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1949 | # Make sure file is in $OUT/system or $OUT/data |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1950 | case $FILE in |
Matt Mower | dfd4c08 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1951 | $OUT/system/*|$OUT/data/*) |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1952 | # Get target file name (i.e. /system/bin/adb) |
| 1953 | TARGET=$(echo $FILE | sed "s#$OUT##") |
| 1954 | ;; |
| 1955 | *) continue ;; |
| 1956 | esac |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1957 | |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1958 | case $TARGET in |
Matt Mower | dfd4c08 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1959 | /data/*) |
| 1960 | # fs_config only sets permissions and se labels for files pushed to /system |
| 1961 | if [ -n "$CHKPERM" ]; then |
| 1962 | OLDPERM=$(adb shell $CHKPERM $TARGET) |
| 1963 | OLDPERM=$(echo $OLDPERM | tr -d '\r' | tr -d '\n') |
| 1964 | OLDOWN=$(adb shell ls -al $TARGET | awk '{print $2}') |
| 1965 | OLDGRP=$(adb shell ls -al $TARGET | awk '{print $3}') |
| 1966 | fi |
| 1967 | echo "Pushing: $TARGET" |
| 1968 | adb push $FILE $TARGET |
| 1969 | if [ -n "$OLDPERM" ]; then |
| 1970 | echo "Setting file permissions: $OLDPERM, $OLDOWN":"$OLDGRP" |
| 1971 | adb shell chown "$OLDOWN":"$OLDGRP" $TARGET |
| 1972 | adb shell chmod "$OLDPERM" $TARGET |
| 1973 | else |
| 1974 | echo "$TARGET did not exist previously, you should set file permissions manually" |
| 1975 | fi |
| 1976 | adb shell restorecon "$TARGET" |
| 1977 | ;; |
Pawit Pornkitprasan | 1822ad0 | 2014-12-22 20:11:47 +0700 | [diff] [blame] | 1978 | /system/priv-app/SystemUI/SystemUI.apk|/system/framework/*) |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1979 | # Only need to stop services once |
| 1980 | if ! $stop_n_start; then |
| 1981 | adb shell stop |
| 1982 | stop_n_start=true |
| 1983 | fi |
| 1984 | echo "Pushing: $TARGET" |
| 1985 | adb push $FILE $TARGET |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1986 | ;; |
| 1987 | *) |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1988 | echo "Pushing: $TARGET" |
| 1989 | adb push $FILE $TARGET |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1990 | ;; |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1991 | esac |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1992 | done |
Matt Mower | dfd4c08 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1993 | if [ -n "$CHKPERM" ]; then |
| 1994 | adb shell rm $CHKPERM |
| 1995 | fi |
Matt Mower | 668ea26 | 2014-05-20 02:52:23 -0500 | [diff] [blame] | 1996 | if $stop_n_start; then |
| 1997 | adb shell start |
| 1998 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 1999 | rm -f $OUT/.log |
| 2000 | return 0 |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 2001 | else |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 2002 | echo "The connected device does not appear to be $BLISS_BUILD, run away!" |
Chirayu Desai | 6dadb57 | 2012-12-26 10:53:58 +0530 | [diff] [blame] | 2003 | fi |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 2004 | } |
| 2005 | |
| 2006 | alias mmp='dopush mm' |
| 2007 | alias mmmp='dopush mmm' |
Martin Brabham | b77db58 | 2016-02-05 15:59:21 -0500 | [diff] [blame] | 2008 | alias mmap='dopush mma' |
Chirayu Desai | ae7a4d0 | 2012-10-16 19:40:18 +0530 | [diff] [blame] | 2009 | alias mkap='dopush mka' |
| 2010 | alias cmkap='dopush cmka' |
| 2011 | |
Chirayu Desai | 4a319b8 | 2013-06-05 20:14:33 +0530 | [diff] [blame] | 2012 | function repopick() { |
| 2013 | T=$(gettop) |
| 2014 | $T/build/tools/repopick.py $@ |
| 2015 | } |
| 2016 | |
Chirayu Desai | b89b324 | 2013-06-30 10:04:25 +0530 | [diff] [blame] | 2017 | function fixup_common_out_dir() { |
| 2018 | common_out_dir=$(get_build_var OUT_DIR)/target/common |
| 2019 | target_device=$(get_build_var TARGET_DEVICE) |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 2020 | if [ ! -z $BLISS_FIXUP_COMMON_OUT ]; then |
Chirayu Desai | b89b324 | 2013-06-30 10:04:25 +0530 | [diff] [blame] | 2021 | if [ -d ${common_out_dir} ] && [ ! -L ${common_out_dir} ]; then |
| 2022 | mv ${common_out_dir} ${common_out_dir}-${target_device} |
| 2023 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 2024 | else |
| 2025 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 2026 | mkdir -p ${common_out_dir}-${target_device} |
| 2027 | ln -s ${common_out_dir}-${target_device} ${common_out_dir} |
| 2028 | fi |
| 2029 | else |
| 2030 | [ -L ${common_out_dir} ] && rm ${common_out_dir} |
| 2031 | mkdir -p ${common_out_dir} |
| 2032 | fi |
| 2033 | } |
| 2034 | |
Michael Bestas | 163381a | 2015-10-23 20:36:47 +0300 | [diff] [blame] | 2035 | # Force JAVA_HOME to point to java 1.7 if it isn't already set. |
Narayan Kamath | 9260bba | 2014-01-17 10:05:25 +0000 | [diff] [blame] | 2036 | # |
| 2037 | # Note that the MacOS path for java 1.7 includes a minor revision number (sigh). |
| 2038 | # For some reason, installing the JDK doesn't make it show up in the |
| 2039 | # JavaVM.framework/Versions/1.7/ folder. |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 2040 | function set_java_home() { |
Narayan Kamath | 9260bba | 2014-01-17 10:05:25 +0000 | [diff] [blame] | 2041 | # Clear the existing JAVA_HOME value if we set it ourselves, so that |
Narayan Kamath | c84889b | 2014-04-01 14:16:26 +0100 | [diff] [blame] | 2042 | # we can reset it later, depending on the version of java the build |
| 2043 | # system needs. |
Narayan Kamath | 9260bba | 2014-01-17 10:05:25 +0000 | [diff] [blame] | 2044 | # |
| 2045 | # If we don't do this, the JAVA_HOME value set by the first call to |
| 2046 | # build/envsetup.sh will persist forever. |
| 2047 | if [ -n "$ANDROID_SET_JAVA_HOME" ]; then |
| 2048 | export JAVA_HOME="" |
| 2049 | fi |
| 2050 | |
Andy McFadden | bd96094 | 2010-06-24 12:52:51 -0700 | [diff] [blame] | 2051 | if [ ! "$JAVA_HOME" ]; then |
Neil Fuller | 46e00ea | 2014-10-16 10:23:03 +0100 | [diff] [blame] | 2052 | case `uname -s` in |
| 2053 | Darwin) |
| 2054 | export JAVA_HOME=$(/usr/libexec/java_home -v 1.7) |
| 2055 | ;; |
| 2056 | *) |
| 2057 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
| 2058 | ;; |
| 2059 | esac |
Narayan Kamath | 9260bba | 2014-01-17 10:05:25 +0000 | [diff] [blame] | 2060 | |
| 2061 | # Keep track of the fact that we set JAVA_HOME ourselves, so that |
| 2062 | # we can change it on the next envsetup.sh, if required. |
| 2063 | export ANDROID_SET_JAVA_HOME=true |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 2064 | fi |
Jeff Hamilton | 4a1c70e | 2010-06-21 18:26:38 -0500 | [diff] [blame] | 2065 | } |
Jeff Hamilton | 04be0d8 | 2010-06-07 15:03:54 -0500 | [diff] [blame] | 2066 | |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 2067 | # Print colored exit condition |
| 2068 | function pez { |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 2069 | "$@" |
| 2070 | local retval=$? |
| 2071 | if [ $retval -ne 0 ] |
| 2072 | then |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2073 | printf "\e[0;31mFAILURE\e[00m\n" |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 2074 | else |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2075 | printf "\e[0;32mSUCCESS\e[00m\n" |
Michael Wright | eb73384 | 2013-03-08 17:34:02 -0800 | [diff] [blame] | 2076 | fi |
| 2077 | return $retval |
Alex Ray | f0d08eb | 2013-03-08 15:15:06 -0800 | [diff] [blame] | 2078 | } |
| 2079 | |
Ying Wang | ed21d4c | 2014-08-24 22:14:19 -0700 | [diff] [blame] | 2080 | function get_make_command() |
| 2081 | { |
| 2082 | echo command make |
| 2083 | } |
| 2084 | |
Anthony King | 40b093f | 2015-04-30 22:19:48 +0100 | [diff] [blame] | 2085 | function mk_timer() |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2086 | { |
| 2087 | local start_time=$(date +"%s") |
Anthony King | 40b093f | 2015-04-30 22:19:48 +0100 | [diff] [blame] | 2088 | $@ |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2089 | local ret=$? |
| 2090 | local end_time=$(date +"%s") |
| 2091 | local tdiff=$(($end_time-$start_time)) |
| 2092 | local hours=$(($tdiff / 3600 )) |
| 2093 | local mins=$((($tdiff % 3600) / 60)) |
| 2094 | local secs=$(($tdiff % 60)) |
Greg Hackmann | d95c7f7 | 2014-06-23 14:05:06 -0700 | [diff] [blame] | 2095 | local ncolors=$(tput colors 2>/dev/null) |
| 2096 | if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then |
| 2097 | color_failed="\e[0;31m" |
| 2098 | color_success="\e[0;32m" |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2099 | color_reset="\e[0m" |
Greg Hackmann | d95c7f7 | 2014-06-23 14:05:06 -0700 | [diff] [blame] | 2100 | else |
| 2101 | color_failed="" |
| 2102 | color_success="" |
| 2103 | color_reset="" |
| 2104 | fi |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2105 | echo |
| 2106 | if [ $ret -eq 0 ] ; then |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2107 | printf "${color_success}#### make completed successfully " |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2108 | else |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2109 | printf "${color_failed}#### make failed to build some targets " |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2110 | fi |
| 2111 | if [ $hours -gt 0 ] ; then |
| 2112 | printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs |
| 2113 | elif [ $mins -gt 0 ] ; then |
| 2114 | printf "(%02g:%02g (mm:ss))" $mins $secs |
| 2115 | elif [ $secs -gt 0 ] ; then |
| 2116 | printf "(%s seconds)" $secs |
| 2117 | fi |
Roman Birg | ead9a5c | 2015-10-16 10:29:06 -0700 | [diff] [blame] | 2118 | printf " ####${color_reset}\n\n" |
Ed Heyl | cc6be0a | 2014-06-18 14:55:58 -0700 | [diff] [blame] | 2119 | return $ret |
| 2120 | } |
| 2121 | |
Anthony King | 40b093f | 2015-04-30 22:19:48 +0100 | [diff] [blame] | 2122 | function make() |
| 2123 | { |
| 2124 | mk_timer $(get_make_command) "$@" |
| 2125 | } |
| 2126 | |
Khalid Zubair | 695992c | 2016-02-08 16:27:55 -0800 | [diff] [blame] | 2127 | function __detect_shell() { |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 2128 | case `ps -o command -p $$` in |
| 2129 | *bash*) |
Khalid Zubair | 695992c | 2016-02-08 16:27:55 -0800 | [diff] [blame] | 2130 | echo bash |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 2131 | ;; |
Emilio López | 7ff9caa | 2013-11-03 13:05:43 -0300 | [diff] [blame] | 2132 | *zsh*) |
Khalid Zubair | 695992c | 2016-02-08 16:27:55 -0800 | [diff] [blame] | 2133 | echo zsh |
Emilio López | 7ff9caa | 2013-11-03 13:05:43 -0300 | [diff] [blame] | 2134 | ;; |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 2135 | *) |
Khalid Zubair | 695992c | 2016-02-08 16:27:55 -0800 | [diff] [blame] | 2136 | echo unknown |
| 2137 | return 1 |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 2138 | ;; |
| 2139 | esac |
Khalid Zubair | 695992c | 2016-02-08 16:27:55 -0800 | [diff] [blame] | 2140 | return |
| 2141 | } |
| 2142 | |
| 2143 | |
| 2144 | if ! __detect_shell > /dev/null; then |
| 2145 | echo "WARNING: Only bash and zsh are supported, use of other shell may lead to erroneous results" |
Raphael Moll | 70a86b0 | 2011-06-20 16:03:14 -0700 | [diff] [blame] | 2146 | fi |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 2147 | |
| 2148 | # Execute the contents of any vendorsetup.sh files we can find. |
Oleksiy Avramchenko | 15760a8 | 2014-10-06 18:51:58 +0200 | [diff] [blame] | 2149 | for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \ |
| 2150 | `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` |
The Android Open Source Project | dcc08f0 | 2008-12-17 18:03:49 -0800 | [diff] [blame] | 2151 | do |
| 2152 | echo "including $f" |
| 2153 | . $f |
| 2154 | done |
| 2155 | unset f |
Kenny Root | 52aa81c | 2011-07-15 11:07:06 -0700 | [diff] [blame] | 2156 | |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 2157 | # Add completions |
| 2158 | check_bash_version && { |
Dark Eyes | dafcfe8 | 2015-12-11 20:51:02 -0500 | [diff] [blame^] | 2159 | dirs="sdk/bash_completion vendor/bliss/bash_completion" |
Kyle Ladd | 031a0b6 | 2013-09-11 20:43:42 -0400 | [diff] [blame] | 2160 | for dir in $dirs; do |
| 2161 | if [ -d ${dir} ]; then |
| 2162 | for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do |
| 2163 | echo "including $f" |
| 2164 | . $f |
| 2165 | done |
| 2166 | fi |
| 2167 | done |
| 2168 | } |
Chirayu Desai | e1466d6 | 2013-03-19 17:50:37 +0530 | [diff] [blame] | 2169 | |
| 2170 | export ANDROID_BUILD_TOP=$(gettop) |