blob: e1dd6ea2f091222b11706a775a033052540fedb7 [file] [log] [blame]
Scott Anderson1a5fc952012-03-07 17:15:06 -08001function hmm() {
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07002cat <<EOF
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08003Invoke ". build/envsetup.sh" from your shell to add the following functions to your environment:
Ying Wang67f02922012-08-22 10:25:20 -07004- lunch: lunch <product_name>-<build_variant>
Ying Wangb541ab62014-05-29 17:57:40 -07005- tapas: tapas [<App1> <App2> ...] [arm|x86|mips|armv5|arm64|x86_64|mips64] [eng|userdebug|user]
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07006- croot: Changes directory to the top of the tree.
7- m: Makes from the top of the tree.
Ying Wangb607f7b2013-02-08 18:01:04 -08008- mm: Builds all of the modules in the current directory, but not their dependencies.
9- mmm: Builds all of the modules in the supplied directories, but not their dependencies.
Primiano Tucci6a8069d2014-02-26 11:09:19 +000010 To limit the modules being built use the syntax: mmm dir/:target1,target2.
Ying Wangb607f7b2013-02-08 18:01:04 -080011- mma: Builds all of the modules in the current directory, and their dependencies.
12- mmma: Builds all of the modules in the supplied directories, and their dependencies.
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070013- cgrep: Greps on all local C/C++ files.
Jon Boekenoogencbca56f2014-04-07 10:57:38 -070014- ggrep: Greps on all local Gradle files.
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070015- jgrep: Greps on all local Java files.
16- resgrep: Greps on all local res/*.xml files.
Trevor Drake9c889762015-01-30 04:42:21 +000017- mangrep: Greps on all local AndroidManifest.xml files.
18- sepgrep: Greps on all local sepolicy files.
Jeff Brown46cbd202014-07-26 15:15:41 -070019- sgrep: Greps on all local source files.
The Android Open Source Project88b60792009-03-03 19:28:42 -080020- godir: Go to the directory containing a file.
Andrew Sutherlandd6bd0652011-11-18 00:45:55 -060021- cmremote: Add git remote for CM Gerrit Review
22- cmgerrit: A Git wrapper that fetches/pushes patch from/to CM Gerrit Review
23- cmrebase: Rebase a Gerrit change and push it again
24- mka: Builds using SCHED_BATCH on all processors
25- reposync: Parallel repo sync using ionice and SCHED_BATCH
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070026
Dan Albert4ae5d4b2014-10-31 16:23:08 -070027Environemnt options:
28- SANITIZE_HOST: Set to 'true' to use ASAN for all host modules. Note that
29 ASAN_OPTIONS=detect_leaks=0 will be set by default until the
30 build is leak-check clean.
31
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070032Look at the source to view more functions. The complete list is:
33EOF
34 T=$(gettop)
35 local A
36 A=""
Jeff Brown46cbd202014-07-26 15:15:41 -070037 for i in `cat $T/build/envsetup.sh | sed -n "/^[ \t]*function /s/function \([a-z_]*\).*/\1/p" | sort | uniq`; do
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070038 A="$A $i"
39 done
40 echo $A
41}
42
43# Get the value of a build variable as an absolute path.
44function get_abs_build_var()
45{
46 T=$(gettop)
47 if [ ! "$T" ]; then
48 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
49 return
50 fi
Ying Wang9cd17642012-12-13 10:52:07 -080051 (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
Ed Heylc6d11f82014-06-27 13:32:39 -070052 command make --no-print-directory -f build/core/config.mk dumpvar-abs-$1)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070053}
54
55# Get the exact value of a build variable.
56function get_build_var()
57{
58 T=$(gettop)
59 if [ ! "$T" ]; then
60 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
61 return
62 fi
Andrew Boie6905e212013-12-19 13:21:46 -080063 (\cd $T; CALLED_FROM_SETUP=true BUILD_SYSTEM=build/core \
Ed Heylc6d11f82014-06-27 13:32:39 -070064 command make --no-print-directory -f build/core/config.mk dumpvar-$1)
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -080065}
66
67# check to see if the supplied product is one we can build
68function check_product()
69{
70 T=$(gettop)
71 if [ ! "$T" ]; then
72 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
73 return
74 fi
Ricardo Cerqueira119d3bb2011-11-25 15:30:36 +000075
76 if (echo -n $1 | grep -q -e "^cm_") ; then
77 CM_BUILD=$(echo -n $1 | sed -e 's/^cm_//g')
78 else
79 CM_BUILD=
80 fi
81 export CM_BUILD
82
Jeff Browne33ba4c2011-07-11 22:11:46 -070083 TARGET_PRODUCT=$1 \
84 TARGET_BUILD_VARIANT= \
85 TARGET_BUILD_TYPE= \
Joe Onoratoda12daf2010-06-09 18:18:31 -070086 TARGET_BUILD_APPS= \
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -080087 get_build_var TARGET_DEVICE > /dev/null
88 # hide successful answers, but allow the errors to show
89}
90
91VARIANT_CHOICES=(user userdebug eng)
92
93# check to see if the supplied variant is valid
94function check_variant()
95{
96 for v in ${VARIANT_CHOICES[@]}
97 do
98 if [ "$v" = "$1" ]
99 then
100 return 0
101 fi
102 done
103 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700104}
105
106function setpaths()
107{
108 T=$(gettop)
109 if [ ! "$T" ]; then
110 echo "Couldn't locate the top of the tree. Try setting TOP."
111 return
112 fi
113
114 ##################################################################
115 # #
116 # Read me before you modify this code #
117 # #
118 # This function sets ANDROID_BUILD_PATHS to what it is adding #
119 # to PATH, and the next time it is run, it removes that from #
120 # PATH. This is required so lunch can be run more than once #
121 # and still have working paths. #
122 # #
123 ##################################################################
124
Raphael Mollc639c782011-06-20 17:25:01 -0700125 # Note: on windows/cygwin, ANDROID_BUILD_PATHS will contain spaces
126 # due to "C:\Program Files" being in the path.
127
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700128 # out with the old
Raphael Mollc639c782011-06-20 17:25:01 -0700129 if [ -n "$ANDROID_BUILD_PATHS" ] ; then
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700130 export PATH=${PATH/$ANDROID_BUILD_PATHS/}
131 fi
Raphael Mollc639c782011-06-20 17:25:01 -0700132 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
Doug Zongker29034982011-04-22 08:16:56 -0700133 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
Ying Wangaa1c9b52012-11-26 20:51:59 -0800134 # strip leading ':', if any
135 export PATH=${PATH/:%/}
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500136 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700137
138 # and in with the new
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700139 prebuiltdir=$(getprebuilt)
Jing Yuf5172c72012-03-29 20:45:50 -0700140 gccprebuiltdir=$(get_abs_build_var ANDROID_GCC_PREBUILTS)
Raphael732936d2011-06-22 14:35:32 -0700141
Ben Cheng8bc4c432012-11-16 13:29:13 -0800142 # defined in core/config.mk
143 targetgccversion=$(get_build_var TARGET_GCC_VERSION)
Colin Cross03b424a2014-05-22 11:57:43 -0700144 targetgccversion2=$(get_build_var 2ND_TARGET_GCC_VERSION)
Ben Cheng15266702012-12-10 16:04:39 -0800145 export TARGET_GCC_VERSION=$targetgccversion
Ben Cheng8bc4c432012-11-16 13:29:13 -0800146
Raphael Mollc639c782011-06-20 17:25:01 -0700147 # The gcc toolchain does not exists for windows/cygwin. In this case, do not reference it.
Ben Chengfba67bf2014-02-25 10:27:07 -0800148 export ANDROID_TOOLCHAIN=
149 export ANDROID_TOOLCHAIN_2ND_ARCH=
David 'Digit' Turner2056c252012-04-17 14:50:47 +0200150 local ARCH=$(get_build_var TARGET_ARCH)
151 case $ARCH in
Pavel Chupinc1a56642013-08-23 16:49:21 +0400152 x86) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
Mark D Horn7d0ede72012-03-14 14:20:30 -0700153 ;;
Pavel Chupinfd82a492012-11-26 09:50:07 +0400154 x86_64) toolchaindir=x86/x86_64-linux-android-$targetgccversion/bin
155 ;;
Ben Cheng8bc4c432012-11-16 13:29:13 -0800156 arm) toolchaindir=arm/arm-linux-androideabi-$targetgccversion/bin
David 'Digit' Turner2056c252012-04-17 14:50:47 +0200157 ;;
Ben Chengfba67bf2014-02-25 10:27:07 -0800158 arm64) toolchaindir=aarch64/aarch64-linux-android-$targetgccversion/bin;
Colin Cross03b424a2014-05-22 11:57:43 -0700159 toolchaindir2=arm/arm-linux-androideabi-$targetgccversion2/bin
Ben Chengdb4fc202013-10-04 16:02:59 -0700160 ;;
Duane Sand3c4fcd82014-07-22 14:34:00 -0700161 mips|mips64) toolchaindir=mips/mips64el-linux-android-$targetgccversion/bin
Serban Constantinescu9b68fb22014-01-14 10:33:53 +0000162 ;;
David 'Digit' Turner2056c252012-04-17 14:50:47 +0200163 *)
164 echo "Can't find toolchain for unknown architecture: $ARCH"
165 toolchaindir=xxxxxxxxx
Mark D Horn7d0ede72012-03-14 14:20:30 -0700166 ;;
167 esac
Jing Yuf5172c72012-03-29 20:45:50 -0700168 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
Ben Chengfba67bf2014-02-25 10:27:07 -0800169 export ANDROID_TOOLCHAIN=$gccprebuiltdir/$toolchaindir
Raphael Mollc639c782011-06-20 17:25:01 -0700170 fi
Raphael732936d2011-06-22 14:35:32 -0700171
Ben Chengfba67bf2014-02-25 10:27:07 -0800172 if [ -d "$gccprebuiltdir/$toolchaindir2" ]; then
173 export ANDROID_TOOLCHAIN_2ND_ARCH=$gccprebuiltdir/$toolchaindir2
174 fi
175
176 unset ANDROID_KERNEL_TOOLCHAIN_PATH
Ying Wang08f5e9a2012-04-17 18:10:11 -0700177 case $ARCH in
Bruce Beare42ced6d2012-07-17 21:40:01 -0700178 arm)
Ben Chengfba67bf2014-02-25 10:27:07 -0800179 # Legacy toolchain configuration used for ARM kernel compilation
Ben Cheng8bc4c432012-11-16 13:29:13 -0800180 toolchaindir=arm/arm-eabi-$targetgccversion/bin
Bruce Beare42ced6d2012-07-17 21:40:01 -0700181 if [ -d "$gccprebuiltdir/$toolchaindir" ]; then
Torne (Richard Coles)f24c3562014-04-25 16:24:22 +0100182 export ARM_EABI_TOOLCHAIN="$gccprebuiltdir/$toolchaindir"
183 ANDROID_KERNEL_TOOLCHAIN_PATH="$ARM_EABI_TOOLCHAIN":
Bruce Beare42ced6d2012-07-17 21:40:01 -0700184 fi
Ying Wang08f5e9a2012-04-17 18:10:11 -0700185 ;;
186 *)
Bruce Beare42ced6d2012-07-17 21:40:01 -0700187 # No need to set ARM_EABI_TOOLCHAIN for other ARCHs
Ying Wang08f5e9a2012-04-17 18:10:11 -0700188 ;;
189 esac
Ying Wang08f5e9a2012-04-17 18:10:11 -0700190
Jeff Vander Stoep5aa68322015-06-12 09:56:39 -0700191 export ANDROID_DEV_SCRIPTS=$T/development/scripts:$T/prebuilts/devtools/tools:$T/external/selinux/prebuilts/bin
Ying Wang2a859d52014-06-30 10:25:33 -0700192 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' Turner94d16e52014-05-05 16:13:50 +0200193
194 # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH
195 # to ensure that the corresponding 'emulator' binaries are used.
196 case $(uname -s) in
197 Darwin)
198 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
199 ;;
200 Linux)
201 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
202 ;;
203 *)
204 ANDROID_EMULATOR_PREBUILTS=
205 ;;
206 esac
207 if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
Christopher Ferris7110f242014-05-20 13:56:00 -0700208 ANDROID_BUILD_PATHS=$ANDROID_BUILD_PATHS$ANDROID_EMULATOR_PREBUILTS:
David 'Digit' Turner94d16e52014-05-05 16:13:50 +0200209 export ANDROID_EMULATOR_PREBUILTS
210 fi
211
Ying Wangaa1c9b52012-11-26 20:51:59 -0800212 export PATH=$ANDROID_BUILD_PATHS$PATH
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800213
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500214 unset ANDROID_JAVA_TOOLCHAIN
Ji-Hwan Lee752ad062011-07-04 14:09:47 +0900215 unset ANDROID_PRE_BUILD_PATHS
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500216 if [ -n "$JAVA_HOME" ]; then
217 export ANDROID_JAVA_TOOLCHAIN=$JAVA_HOME/bin
Ji-Hwan Lee752ad062011-07-04 14:09:47 +0900218 export ANDROID_PRE_BUILD_PATHS=$ANDROID_JAVA_TOOLCHAIN:
219 export PATH=$ANDROID_PRE_BUILD_PATHS$PATH
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500220 fi
221
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800222 unset ANDROID_PRODUCT_OUT
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700223 export ANDROID_PRODUCT_OUT=$(get_abs_build_var PRODUCT_OUT)
224 export OUT=$ANDROID_PRODUCT_OUT
225
Jeff Brown8fd5cce2011-03-24 17:03:06 -0700226 unset ANDROID_HOST_OUT
227 export ANDROID_HOST_OUT=$(get_abs_build_var HOST_OUT)
228
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800229 # needed for building linux on MacOS
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700230 # TODO: fix the path
231 #export HOST_EXTRACFLAGS="-I "$T/system/kernel_headers/host_include
232}
233
234function printconfig()
235{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800236 T=$(gettop)
237 if [ ! "$T" ]; then
238 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
239 return
240 fi
241 get_build_var report_config
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700242}
243
244function set_stuff_for_environment()
245{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800246 settitle
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500247 set_java_home
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800248 setpaths
249 set_sequence_number
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700250
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800251 export ANDROID_BUILD_TOP=$(gettop)
Ben Chengaac3f812013-08-13 14:38:15 -0700252 # With this environment variable new GCC can apply colors to warnings/errors
253 export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
Dan Albert4ae5d4b2014-10-31 16:23:08 -0700254 export ASAN_OPTIONS=detect_leaks=0
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700255}
256
257function set_sequence_number()
258{
Joe Onoratoaee4daa2010-06-23 14:03:13 -0700259 export BUILD_ENV_SEQUENCE_NUMBER=10
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700260}
261
262function settitle()
263{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800264 if [ "$STAY_OFF_MY_LAWN" = "" ]; then
Raghu Gandham8da43102012-07-25 19:57:22 -0700265 local arch=$(gettargetarch)
Joe Onoratoda12daf2010-06-09 18:18:31 -0700266 local product=$TARGET_PRODUCT
267 local variant=$TARGET_BUILD_VARIANT
268 local apps=$TARGET_BUILD_APPS
269 if [ -z "$apps" ]; then
Raghu Gandham8da43102012-07-25 19:57:22 -0700270 export PROMPT_COMMAND="echo -ne \"\033]0;[${arch}-${product}-${variant}] ${USER}@${HOSTNAME}: ${PWD}\007\""
Joe Onoratoda12daf2010-06-09 18:18:31 -0700271 else
Raghu Gandham8da43102012-07-25 19:57:22 -0700272 export PROMPT_COMMAND="echo -ne \"\033]0;[$arch $apps $variant] ${USER}@${HOSTNAME}: ${PWD}\007\""
Joe Onoratoda12daf2010-06-09 18:18:31 -0700273 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800274 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700275}
276
Kenny Root52aa81c2011-07-15 11:07:06 -0700277function addcompletions()
278{
279 local T dir f
280
281 # Keep us from trying to run in something that isn't bash.
282 if [ -z "${BASH_VERSION}" ]; then
283 return
284 fi
285
286 # Keep us from trying to run in bash that's too old.
287 if [ ${BASH_VERSINFO[0]} -lt 3 ]; then
288 return
289 fi
290
291 dir="sdk/bash_completion"
292 if [ -d ${dir} ]; then
Kenny Root7546d612011-07-18 13:11:34 -0700293 for f in `/bin/ls ${dir}/[a-z]*.bash 2> /dev/null`; do
Kenny Root52aa81c2011-07-15 11:07:06 -0700294 echo "including $f"
295 . $f
296 done
297 fi
298}
299
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700300function choosetype()
301{
302 echo "Build type choices are:"
303 echo " 1. release"
304 echo " 2. debug"
305 echo
306
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800307 local DEFAULT_NUM DEFAULT_VALUE
Jeff Browne33ba4c2011-07-11 22:11:46 -0700308 DEFAULT_NUM=1
309 DEFAULT_VALUE=release
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700310
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800311 export TARGET_BUILD_TYPE=
312 local ANSWER
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700313 while [ -z $TARGET_BUILD_TYPE ]
314 do
315 echo -n "Which would you like? ["$DEFAULT_NUM"] "
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800316 if [ -z "$1" ] ; then
317 read ANSWER
318 else
319 echo $1
320 ANSWER=$1
321 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700322 case $ANSWER in
323 "")
324 export TARGET_BUILD_TYPE=$DEFAULT_VALUE
325 ;;
326 1)
327 export TARGET_BUILD_TYPE=release
328 ;;
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800329 release)
330 export TARGET_BUILD_TYPE=release
331 ;;
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700332 2)
333 export TARGET_BUILD_TYPE=debug
334 ;;
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800335 debug)
336 export TARGET_BUILD_TYPE=debug
337 ;;
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700338 *)
339 echo
340 echo "I didn't understand your response. Please try again."
341 echo
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700342 ;;
343 esac
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800344 if [ -n "$1" ] ; then
345 break
346 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700347 done
348
349 set_stuff_for_environment
350}
351
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800352#
353# This function isn't really right: It chooses a TARGET_PRODUCT
354# based on the list of boards. Usually, that gets you something
355# that kinda works with a generic product, but really, you should
356# pick a product by name.
357#
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700358function chooseproduct()
359{
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700360 if [ "x$TARGET_PRODUCT" != x ] ; then
361 default_value=$TARGET_PRODUCT
362 else
Jeff Browne33ba4c2011-07-11 22:11:46 -0700363 default_value=full
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700364 fi
365
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800366 export TARGET_PRODUCT=
367 local ANSWER
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700368 while [ -z "$TARGET_PRODUCT" ]
369 do
Joe Onorato8849aed2009-04-29 15:56:47 -0700370 echo -n "Which product would you like? [$default_value] "
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800371 if [ -z "$1" ] ; then
372 read ANSWER
373 else
374 echo $1
375 ANSWER=$1
376 fi
377
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700378 if [ -z "$ANSWER" ] ; then
379 export TARGET_PRODUCT=$default_value
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800380 else
381 if check_product $ANSWER
382 then
383 export TARGET_PRODUCT=$ANSWER
384 else
385 echo "** Not a valid product: $ANSWER"
386 fi
387 fi
388 if [ -n "$1" ] ; then
389 break
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700390 fi
391 done
392
393 set_stuff_for_environment
394}
395
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800396function choosevariant()
397{
398 echo "Variant choices are:"
399 local index=1
400 local v
401 for v in ${VARIANT_CHOICES[@]}
402 do
403 # The product name is the name of the directory containing
404 # the makefile we found, above.
405 echo " $index. $v"
406 index=$(($index+1))
407 done
408
409 local default_value=eng
410 local ANSWER
411
412 export TARGET_BUILD_VARIANT=
413 while [ -z "$TARGET_BUILD_VARIANT" ]
414 do
415 echo -n "Which would you like? [$default_value] "
416 if [ -z "$1" ] ; then
417 read ANSWER
418 else
419 echo $1
420 ANSWER=$1
421 fi
422
423 if [ -z "$ANSWER" ] ; then
424 export TARGET_BUILD_VARIANT=$default_value
425 elif (echo -n $ANSWER | grep -q -e "^[0-9][0-9]*$") ; then
426 if [ "$ANSWER" -le "${#VARIANT_CHOICES[@]}" ] ; then
Kan-Ru Chen07453762010-07-05 15:53:47 +0800427 export TARGET_BUILD_VARIANT=${VARIANT_CHOICES[$(($ANSWER-1))]}
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800428 fi
429 else
430 if check_variant $ANSWER
431 then
432 export TARGET_BUILD_VARIANT=$ANSWER
433 else
434 echo "** Not a valid variant: $ANSWER"
435 fi
436 fi
437 if [ -n "$1" ] ; then
438 break
439 fi
440 done
441}
442
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700443function choosecombo()
444{
Jeff Browne33ba4c2011-07-11 22:11:46 -0700445 choosetype $1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700446
447 echo
448 echo
Jeff Browne33ba4c2011-07-11 22:11:46 -0700449 chooseproduct $2
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700450
451 echo
452 echo
Jeff Browne33ba4c2011-07-11 22:11:46 -0700453 choosevariant $3
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800454
455 echo
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700456 set_stuff_for_environment
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800457 printconfig
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700458}
459
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800460# Clear this variable. It will be built up again when the vendorsetup.sh
461# files are included at the end of this file.
462unset LUNCH_MENU_CHOICES
463function add_lunch_combo()
464{
465 local new_combo=$1
466 local c
467 for c in ${LUNCH_MENU_CHOICES[@]} ; do
468 if [ "$new_combo" = "$c" ] ; then
469 return
470 fi
471 done
472 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
473}
474
475# add the default one here
Jean-Baptiste Queru324c1232013-03-22 15:53:54 -0700476add_lunch_combo aosp_arm-eng
Colin Cross4f0eb7d2014-01-21 19:35:38 -0800477add_lunch_combo aosp_arm64-eng
Serban Constantinescu9b68fb22014-01-14 10:33:53 +0000478add_lunch_combo aosp_mips-eng
Chris Dearman1efd9e42014-02-03 15:01:24 -0800479add_lunch_combo aosp_mips64-eng
Serban Constantinescu9b68fb22014-01-14 10:33:53 +0000480add_lunch_combo aosp_x86-eng
481add_lunch_combo aosp_x86_64-eng
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800482
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700483function print_lunch_menu()
484{
485 local uname=$(uname)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700486 echo
487 echo "You're building on" $uname
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700488 echo
489 echo "Lunch menu... pick a combo:"
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800490
491 local i=1
492 local choice
493 for choice in ${LUNCH_MENU_CHOICES[@]}
494 do
495 echo " $i. $choice"
496 i=$(($i+1))
497 done
498
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700499 echo
500}
501
502function lunch()
503{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800504 local answer
505
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700506 if [ "$1" ] ; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800507 answer=$1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700508 else
509 print_lunch_menu
Jean-Baptiste Queru324c1232013-03-22 15:53:54 -0700510 echo -n "Which would you like? [aosp_arm-eng] "
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800511 read answer
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700512 fi
513
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800514 local selection=
515
516 if [ -z "$answer" ]
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700517 then
Jean-Baptiste Queru324c1232013-03-22 15:53:54 -0700518 selection=aosp_arm-eng
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800519 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
520 then
521 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ]
522 then
Kan-Ru Chen07453762010-07-05 15:53:47 +0800523 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]}
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800524 fi
525 elif (echo -n $answer | grep -q -e "^[^\-][^\-]*-[^\-][^\-]*$")
526 then
527 selection=$answer
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700528 fi
529
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800530 if [ -z "$selection" ]
531 then
532 echo
533 echo "Invalid lunch combo: $answer"
534 return 1
535 fi
536
Joe Onoratoda12daf2010-06-09 18:18:31 -0700537 export TARGET_BUILD_APPS=
538
Jeff Browne33ba4c2011-07-11 22:11:46 -0700539 local product=$(echo -n $selection | sed -e "s/-.*$//")
540 check_product $product
541 if [ $? -ne 0 ]
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800542 then
Koushik Dutta780fb5f2011-11-26 18:51:42 -0800543 # if we can't find a product, try to grab it off the CM github
544 T=$(gettop)
545 pushd $T > /dev/null
546 build/tools/roomservice.py $product
547 popd > /dev/null
548 check_product $product
549 fi
550 if [ $? -ne 0 ]
551 then
Jeff Browne33ba4c2011-07-11 22:11:46 -0700552 echo
553 echo "** Don't have a product spec for: '$product'"
554 echo "** Do you have the right repo manifest?"
555 product=
556 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800557
Jeff Browne33ba4c2011-07-11 22:11:46 -0700558 local variant=$(echo -n $selection | sed -e "s/^[^\-]*-//")
559 check_variant $variant
560 if [ $? -ne 0 ]
561 then
562 echo
563 echo "** Invalid variant: '$variant'"
564 echo "** Must be one of ${VARIANT_CHOICES[@]}"
565 variant=
566 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800567
Jeff Browne33ba4c2011-07-11 22:11:46 -0700568 if [ -z "$product" -o -z "$variant" ]
569 then
570 echo
571 return 1
572 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800573
Jeff Browne33ba4c2011-07-11 22:11:46 -0700574 export TARGET_PRODUCT=$product
575 export TARGET_BUILD_VARIANT=$variant
576 export TARGET_BUILD_TYPE=release
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700577
578 echo
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800579
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700580 set_stuff_for_environment
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800581 printconfig
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700582}
583
Jeff Davidson513d7a42010-08-02 10:00:44 -0700584# Tab completion for lunch.
585function _lunch()
586{
587 local cur prev opts
588 COMPREPLY=()
589 cur="${COMP_WORDS[COMP_CWORD]}"
590 prev="${COMP_WORDS[COMP_CWORD-1]}"
591
592 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) )
593 return 0
594}
595complete -F _lunch lunch
596
Joe Onoratoda12daf2010-06-09 18:18:31 -0700597# Configures the build to build unbundled apps.
Doug Zongker0d8179e2014-04-16 11:34:34 -0700598# Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
Joe Onoratoda12daf2010-06-09 18:18:31 -0700599function tapas()
600{
Ying Wangb541ab62014-05-29 17:57:40 -0700601 local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|mips|armv5|arm64|x86_64|mips64)$' | xargs)"
Doug Zongker0d8179e2014-04-16 11:34:34 -0700602 local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700603 local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
604 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 Onoratoda12daf2010-06-09 18:18:31 -0700605
Ying Wang67f02922012-08-22 10:25:20 -0700606 if [ $(echo $arch | wc -w) -gt 1 ]; then
607 echo "tapas: Error: Multiple build archs supplied: $arch"
608 return
609 fi
Joe Onoratoda12daf2010-06-09 18:18:31 -0700610 if [ $(echo $variant | wc -w) -gt 1 ]; then
611 echo "tapas: Error: Multiple build variants supplied: $variant"
612 return
613 fi
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700614 if [ $(echo $density | wc -w) -gt 1 ]; then
615 echo "tapas: Error: Multiple densities supplied: $density"
616 return
617 fi
Ying Wang67f02922012-08-22 10:25:20 -0700618
619 local product=full
620 case $arch in
Ying Wangb541ab62014-05-29 17:57:40 -0700621 x86) product=full_x86;;
622 mips) product=full_mips;;
623 armv5) product=generic_armv5;;
624 arm64) product=aosp_arm64;;
625 x86_64) product=aosp_x86_64;;
626 mips64) product=aosp_mips64;;
Ying Wang67f02922012-08-22 10:25:20 -0700627 esac
Joe Onoratoda12daf2010-06-09 18:18:31 -0700628 if [ -z "$variant" ]; then
629 variant=eng
630 fi
Ying Wangc048c9b2010-06-24 15:08:33 -0700631 if [ -z "$apps" ]; then
632 apps=all
633 fi
Justin Morey29d225c2014-11-04 13:35:51 -0600634 if [ -z "$density" ]; then
635 density=alldpi
636 fi
Joe Onoratoda12daf2010-06-09 18:18:31 -0700637
Ying Wang67f02922012-08-22 10:25:20 -0700638 export TARGET_PRODUCT=$product
Joe Onoratoda12daf2010-06-09 18:18:31 -0700639 export TARGET_BUILD_VARIANT=$variant
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700640 export TARGET_BUILD_DENSITY=$density
Joe Onoratoda12daf2010-06-09 18:18:31 -0700641 export TARGET_BUILD_TYPE=release
642 export TARGET_BUILD_APPS=$apps
643
644 set_stuff_for_environment
645 printconfig
646}
647
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700648function gettop
649{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800650 local TOPFILE=build/core/envsetup.mk
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700651 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
Brian Carlstroma5c4f172014-09-12 00:33:25 -0700652 # The following circumlocution ensures we remove symlinks from TOP.
653 (cd $TOP; PWD= /bin/pwd)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700654 else
655 if [ -f $TOPFILE ] ; then
Dan Bornsteind0b274d2009-11-24 15:48:50 -0800656 # The following circumlocution (repeated below as well) ensures
657 # that we record the true directory name and not one that is
658 # faked up with symlink names.
659 PWD= /bin/pwd
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700660 else
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800661 local HERE=$PWD
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700662 T=
663 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
Ying Wang9cd17642012-12-13 10:52:07 -0800664 \cd ..
synergyb112a402013-07-05 19:47:47 -0700665 T=`PWD= /bin/pwd -P`
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700666 done
Ying Wang9cd17642012-12-13 10:52:07 -0800667 \cd $HERE
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700668 if [ -f "$T/$TOPFILE" ]; then
669 echo $T
670 fi
671 fi
672 fi
673}
674
Andrew Hsieh906cb782013-09-10 17:37:14 +0800675# Return driver for "make", if any (eg. static analyzer)
676function getdriver()
677{
678 local T="$1"
679 test "$WITH_STATIC_ANALYZER" = "0" && unset WITH_STATIC_ANALYZER
680 if [ -n "$WITH_STATIC_ANALYZER" ]; then
681 echo "\
Andrew Hsiehc4f7fba2014-03-03 16:53:17 +0800682$T/prebuilts/misc/linux-x86/analyzer/tools/scan-build/scan-build \
683--use-analyzer $T/prebuilts/misc/linux-x86/analyzer/bin/analyzer \
Andrew Hsieh906cb782013-09-10 17:37:14 +0800684--status-bugs \
685--top=$T"
686 fi
687}
688
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700689function m()
690{
Andrew Hsieh906cb782013-09-10 17:37:14 +0800691 local T=$(gettop)
692 local DRV=$(getdriver $T)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700693 if [ "$T" ]; then
Andrew Hsieh906cb782013-09-10 17:37:14 +0800694 $DRV make -C $T -f build/core/main.mk $@
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700695 else
696 echo "Couldn't locate the top of the tree. Try setting TOP."
Ying Wang0c1374c2015-04-01 10:13:02 -0700697 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700698 fi
699}
700
701function findmakefile()
702{
703 TOPFILE=build/core/envsetup.mk
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800704 local HERE=$PWD
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700705 T=
706 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
Ying Wang11b15b12012-10-11 15:05:07 -0700707 T=`PWD= /bin/pwd`
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700708 if [ -f "$T/Android.mk" ]; then
709 echo $T/Android.mk
Ying Wang9cd17642012-12-13 10:52:07 -0800710 \cd $HERE
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700711 return
712 fi
Ying Wang9cd17642012-12-13 10:52:07 -0800713 \cd ..
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700714 done
Ying Wang9cd17642012-12-13 10:52:07 -0800715 \cd $HERE
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700716}
717
718function mm()
719{
Andrew Hsieh906cb782013-09-10 17:37:14 +0800720 local T=$(gettop)
721 local DRV=$(getdriver $T)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700722 # If we're sitting in the root of the build tree, just do a
723 # normal make.
724 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
Andrew Hsieh906cb782013-09-10 17:37:14 +0800725 $DRV make $@
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700726 else
727 # Find the closest Android.mk file.
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800728 local M=$(findmakefile)
Ying Wanga7deb082013-08-16 13:24:47 -0700729 local MODULES=
730 local GET_INSTALL_PATH=
731 local ARGS=
Robert Greenwalt3c794d72009-07-15 15:07:44 -0700732 # Remove the path to top as the makefilepath needs to be relative
733 local M=`echo $M|sed 's:'$T'/::'`
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700734 if [ ! "$T" ]; then
735 echo "Couldn't locate the top of the tree. Try setting TOP."
Ying Wang0c1374c2015-04-01 10:13:02 -0700736 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700737 elif [ ! "$M" ]; then
738 echo "Couldn't locate a makefile from the current directory."
Ying Wang0c1374c2015-04-01 10:13:02 -0700739 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700740 else
Ying Wanga7deb082013-08-16 13:24:47 -0700741 for ARG in $@; do
742 case $ARG in
743 GET-INSTALL-PATH) GET_INSTALL_PATH=$ARG;;
744 esac
745 done
746 if [ -n "$GET_INSTALL_PATH" ]; then
747 MODULES=
748 ARGS=GET-INSTALL-PATH
749 else
750 MODULES=all_modules
751 ARGS=$@
752 fi
Andrew Hsieh246daf72013-09-10 18:07:23 -0700753 ONE_SHOT_MAKEFILE=$M $DRV make -C $T -f build/core/main.mk $MODULES $ARGS
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700754 fi
755 fi
756}
757
758function mmm()
759{
Andrew Hsieh906cb782013-09-10 17:37:14 +0800760 local T=$(gettop)
761 local DRV=$(getdriver $T)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700762 if [ "$T" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800763 local MAKEFILE=
Alon Albert68895a92011-11-30 12:40:19 -0800764 local MODULES=
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800765 local ARGS=
766 local DIR TO_CHOP
Ying Wanga7deb082013-08-16 13:24:47 -0700767 local GET_INSTALL_PATH=
The Android Open Source Project88b60792009-03-03 19:28:42 -0800768 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
769 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
770 for DIR in $DIRS ; do
Alon Albert68895a92011-11-30 12:40:19 -0800771 MODULES=`echo $DIR | sed -n -e 's/.*:\(.*$\)/\1/p' | sed 's/,/ /'`
772 if [ "$MODULES" = "" ]; then
773 MODULES=all_modules
774 fi
775 DIR=`echo $DIR | sed -e 's/:.*//' -e 's:/$::'`
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700776 if [ -f $DIR/Android.mk ]; then
Ying Wanga7deb082013-08-16 13:24:47 -0700777 local TO_CHOP=`(\cd -P -- $T && pwd -P) | wc -c | tr -d ' '`
778 local TO_CHOP=`expr $TO_CHOP + 1`
779 local START=`PWD= /bin/pwd`
780 local MFILE=`echo $START | cut -c${TO_CHOP}-`
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700781 if [ "$MFILE" = "" ] ; then
782 MFILE=$DIR/Android.mk
783 else
784 MFILE=$MFILE/$DIR/Android.mk
785 fi
786 MAKEFILE="$MAKEFILE $MFILE"
787 else
Ying Wanga7deb082013-08-16 13:24:47 -0700788 case $DIR in
Adrian Roosafa958f2015-03-05 19:52:55 +0100789 showcommands | snod | dist | incrementaljavac | *=*) ARGS="$ARGS $DIR";;
Ying Wanga7deb082013-08-16 13:24:47 -0700790 GET-INSTALL-PATH) GET_INSTALL_PATH=$DIR;;
791 *) echo "No Android.mk in $DIR."; return 1;;
792 esac
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700793 fi
794 done
Ying Wanga7deb082013-08-16 13:24:47 -0700795 if [ -n "$GET_INSTALL_PATH" ]; then
796 ARGS=$GET_INSTALL_PATH
797 MODULES=
798 fi
Andrew Hsieh906cb782013-09-10 17:37:14 +0800799 ONE_SHOT_MAKEFILE="$MAKEFILE" $DRV make -C $T -f build/core/main.mk $DASH_ARGS $MODULES $ARGS
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700800 else
801 echo "Couldn't locate the top of the tree. Try setting TOP."
Ying Wang0c1374c2015-04-01 10:13:02 -0700802 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700803 fi
804}
805
Ying Wangb607f7b2013-02-08 18:01:04 -0800806function mma()
807{
Andrew Hsieh906cb782013-09-10 17:37:14 +0800808 local T=$(gettop)
809 local DRV=$(getdriver $T)
Ying Wangb607f7b2013-02-08 18:01:04 -0800810 if [ -f build/core/envsetup.mk -a -f Makefile ]; then
Andrew Hsieh906cb782013-09-10 17:37:14 +0800811 $DRV make $@
Ying Wangb607f7b2013-02-08 18:01:04 -0800812 else
Ying Wangb607f7b2013-02-08 18:01:04 -0800813 if [ ! "$T" ]; then
814 echo "Couldn't locate the top of the tree. Try setting TOP."
Ying Wang0c1374c2015-04-01 10:13:02 -0700815 return 1
Ying Wangb607f7b2013-02-08 18:01:04 -0800816 fi
817 local MY_PWD=`PWD= /bin/pwd|sed 's:'$T'/::'`
Andrew Hsieh906cb782013-09-10 17:37:14 +0800818 $DRV make -C $T -f build/core/main.mk $@ all_modules BUILD_MODULES_IN_PATHS="$MY_PWD"
Ying Wangb607f7b2013-02-08 18:01:04 -0800819 fi
820}
821
822function mmma()
823{
Andrew Hsieh906cb782013-09-10 17:37:14 +0800824 local T=$(gettop)
825 local DRV=$(getdriver $T)
Ying Wangb607f7b2013-02-08 18:01:04 -0800826 if [ "$T" ]; then
827 local DASH_ARGS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^-.*$/')
828 local DIRS=$(echo "$@" | awk -v RS=" " -v ORS=" " '/^[^-].*$/')
829 local MY_PWD=`PWD= /bin/pwd`
830 if [ "$MY_PWD" = "$T" ]; then
831 MY_PWD=
832 else
833 MY_PWD=`echo $MY_PWD|sed 's:'$T'/::'`
834 fi
835 local DIR=
836 local MODULE_PATHS=
837 local ARGS=
838 for DIR in $DIRS ; do
839 if [ -d $DIR ]; then
840 if [ "$MY_PWD" = "" ]; then
841 MODULE_PATHS="$MODULE_PATHS $DIR"
842 else
843 MODULE_PATHS="$MODULE_PATHS $MY_PWD/$DIR"
844 fi
845 else
846 case $DIR in
Adrian Roosafa958f2015-03-05 19:52:55 +0100847 showcommands | snod | dist | incrementaljavac | *=*) ARGS="$ARGS $DIR";;
Ying Wangb607f7b2013-02-08 18:01:04 -0800848 *) echo "Couldn't find directory $DIR"; return 1;;
849 esac
850 fi
851 done
Andrew Hsieh906cb782013-09-10 17:37:14 +0800852 $DRV make -C $T -f build/core/main.mk $DASH_ARGS $ARGS all_modules BUILD_MODULES_IN_PATHS="$MODULE_PATHS"
Ying Wangb607f7b2013-02-08 18:01:04 -0800853 else
854 echo "Couldn't locate the top of the tree. Try setting TOP."
Ying Wang0c1374c2015-04-01 10:13:02 -0700855 return 1
Ying Wangb607f7b2013-02-08 18:01:04 -0800856 fi
857}
858
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700859function croot()
860{
861 T=$(gettop)
862 if [ "$T" ]; then
Ying Wang9cd17642012-12-13 10:52:07 -0800863 \cd $(gettop)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700864 else
865 echo "Couldn't locate the top of the tree. Try setting TOP."
866 fi
867}
868
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700869function cproj()
870{
871 TOPFILE=build/core/envsetup.mk
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700872 local HERE=$PWD
873 T=
874 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
875 T=$PWD
876 if [ -f "$T/Android.mk" ]; then
Ying Wang9cd17642012-12-13 10:52:07 -0800877 \cd $T
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700878 return
879 fi
Ying Wang9cd17642012-12-13 10:52:07 -0800880 \cd ..
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700881 done
Ying Wang9cd17642012-12-13 10:52:07 -0800882 \cd $HERE
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700883 echo "can't find Android.mk"
884}
885
Daniel Sandler47e0a882013-07-30 13:23:52 -0400886# simplified version of ps; output in the form
887# <pid> <procname>
888function qpid() {
889 local prepend=''
890 local append=''
891 if [ "$1" = "--exact" ]; then
892 prepend=' '
893 append='$'
894 shift
895 elif [ "$1" = "--help" -o "$1" = "-h" ]; then
896 echo "usage: qpid [[--exact] <process name|pid>"
897 return 255
898 fi
899
900 local EXE="$1"
901 if [ "$EXE" ] ; then
Mathias Agopian44583272013-08-27 14:15:50 -0700902 qpid | \grep "$prepend$EXE$append"
Daniel Sandler47e0a882013-07-30 13:23:52 -0400903 else
904 adb shell ps \
905 | tr -d '\r' \
906 | sed -e 1d -e 's/^[^ ]* *\([0-9]*\).* \([^ ]*\)$/\1 \2/'
907 fi
908}
909
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700910function pid()
911{
Daniel Sandler47e0a882013-07-30 13:23:52 -0400912 local prepend=''
913 local append=''
914 if [ "$1" = "--exact" ]; then
915 prepend=' '
916 append='$'
917 shift
918 fi
919 local EXE="$1"
920 if [ "$EXE" ] ; then
921 local PID=`adb shell ps \
922 | tr -d '\r' \
Mathias Agopian44583272013-08-27 14:15:50 -0700923 | \grep "$prepend$EXE$append" \
Daniel Sandler47e0a882013-07-30 13:23:52 -0400924 | sed -e 's/^[^ ]* *\([0-9]*\).*$/\1/'`
925 echo "$PID"
926 else
927 echo "usage: pid [--exact] <process name>"
928 return 255
929 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700930}
931
Iliyan Malcheve675cfb2014-11-03 17:04:47 -0800932# coredump_setup - enable core dumps globally for any process
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700933# that has the core-file-size limit set correctly
934#
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800935# NOTE: You must call also coredump_enable for a specific process
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700936# if its core-file-size limit is not set already.
937# NOTE: Core dumps are written to ramdisk; they will not survive a reboot!
938
Iliyan Malcheve675cfb2014-11-03 17:04:47 -0800939function coredump_setup()
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700940{
941 echo "Getting root...";
942 adb root;
943 adb wait-for-device;
944
945 echo "Remounting root parition read-write...";
946 adb shell mount -w -o remount -t rootfs rootfs;
947 sleep 1;
948 adb wait-for-device;
949 adb shell mkdir -p /cores;
Nick Kralevicha94282c2014-11-04 11:17:20 -0800950 adb shell mount -t tmpfs tmpfs /cores;
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700951 adb shell chmod 0777 /cores;
952
953 echo "Granting SELinux permission to dump in /cores...";
954 adb shell restorecon -R /cores;
955
956 echo "Set core pattern.";
957 adb shell 'echo /cores/core.%p > /proc/sys/kernel/core_pattern';
958
959 echo "Done."
960}
961
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800962# coredump_enable - enable core dumps for the specified process
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700963# $1 = PID of process (e.g., $(pid mediaserver))
964#
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800965# NOTE: coredump_setup must have been called as well for a core
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700966# dump to actually be generated.
967
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800968function coredump_enable()
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700969{
970 local PID=$1;
971 if [ -z "$PID" ]; then
972 printf "Expecting a PID!\n";
973 return;
974 fi;
975 echo "Setting core limit for $PID to infinite...";
976 adb shell prlimit $PID 4 -1 -1
977}
978
979# core - send SIGV and pull the core for process
980# $1 = PID of process (e.g., $(pid mediaserver))
981#
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800982# NOTE: coredump_setup must be called once per boot for core dumps to be
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700983# enabled globally.
984
985function core()
986{
987 local PID=$1;
988
989 if [ -z "$PID" ]; then
990 printf "Expecting a PID!\n";
991 return;
992 fi;
993
994 local CORENAME=core.$PID;
995 local COREPATH=/cores/$CORENAME;
996 local SIG=SEGV;
997
Iliyan Malchevaf5de972014-11-04 20:57:37 -0800998 coredump_enable $1;
Iliyan Malchev248f4d52014-10-28 18:00:42 -0700999
1000 local done=0;
1001 while [ $(adb shell "[ -d /proc/$PID ] && echo -n yes") ]; do
1002 printf "\tSending SIG%s to %d...\n" $SIG $PID;
1003 adb shell kill -$SIG $PID;
1004 sleep 1;
1005 done;
1006
1007 adb shell "while [ ! -f $COREPATH ] ; do echo waiting for $COREPATH to be generated; sleep 1; done"
1008 echo "Done: core is under $COREPATH on device.";
1009}
1010
Christopher Tate744ee802009-11-12 15:33:08 -08001011# systemstack - dump the current stack trace of all threads in the system process
1012# to the usual ANR traces file
1013function systemstack()
1014{
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001015 stacks system_server
1016}
1017
1018function stacks()
1019{
1020 if [[ $1 =~ ^[0-9]+$ ]] ; then
1021 local PID="$1"
1022 elif [ "$1" ] ; then
Jeff Brownb12c2e52013-08-19 15:14:16 -07001023 local PIDLIST="$(pid $1)"
1024 if [[ $PIDLIST =~ ^[0-9]+$ ]] ; then
1025 local PID="$PIDLIST"
1026 elif [ "$PIDLIST" ] ; then
1027 echo "more than one process: $1"
1028 else
1029 echo "no such process: $1"
1030 fi
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001031 else
1032 echo "usage: stacks [pid|process name]"
1033 fi
1034
1035 if [ "$PID" ] ; then
Jeff Brownb12c2e52013-08-19 15:14:16 -07001036 # Determine whether the process is native
1037 if adb shell ls -l /proc/$PID/exe | grep -q /system/bin/app_process ; then
1038 # Dump stacks of Dalvik process
1039 local TRACES=/data/anr/traces.txt
1040 local ORIG=/data/anr/traces.orig
1041 local TMP=/data/anr/traces.tmp
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001042
Jeff Brownb12c2e52013-08-19 15:14:16 -07001043 # Keep original traces to avoid clobbering
1044 adb shell mv $TRACES $ORIG
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001045
Jeff Brownb12c2e52013-08-19 15:14:16 -07001046 # Make sure we have a usable file
1047 adb shell touch $TRACES
1048 adb shell chmod 666 $TRACES
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001049
Jeff Brownb12c2e52013-08-19 15:14:16 -07001050 # Dump stacks and wait for dump to finish
1051 adb shell kill -3 $PID
1052 adb shell notify $TRACES >/dev/null
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001053
Jeff Brownb12c2e52013-08-19 15:14:16 -07001054 # Restore original stacks, and show current output
1055 adb shell mv $TRACES $TMP
1056 adb shell mv $ORIG $TRACES
1057 adb shell cat $TMP
1058 else
1059 # Dump stacks of native process
Michael Wrightaeed7212014-06-19 19:58:12 -07001060 local USE64BIT="$(is64bit $PID)"
1061 adb shell debuggerd$USE64BIT -b $PID
Jeff Brownb12c2e52013-08-19 15:14:16 -07001062 fi
Jeff Sharkeyf5824372013-02-19 17:00:46 -08001063 fi
Christopher Tate744ee802009-11-12 15:33:08 -08001064}
1065
Michael Wrightaeed7212014-06-19 19:58:12 -07001066# Read the ELF header from /proc/$PID/exe to determine if the process is
1067# 64-bit.
Ben Chengfba67bf2014-02-25 10:27:07 -08001068function is64bit()
1069{
1070 local PID="$1"
1071 if [ "$PID" ] ; then
Michael Wrightaeed7212014-06-19 19:58:12 -07001072 if [[ "$(adb shell cat /proc/$PID/exe | xxd -l 1 -s 4 -ps)" -eq "02" ]] ; then
Ben Chengfba67bf2014-02-25 10:27:07 -08001073 echo "64"
1074 else
1075 echo ""
1076 fi
1077 else
1078 echo ""
1079 fi
1080}
1081
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001082case `uname -s` in
1083 Darwin)
1084 function sgrep()
1085 {
Jeff Brown46cbd202014-07-26 15:15:41 -07001086 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 Projectb6c1cf62008-10-21 07:00:00 -07001087 }
1088
1089 ;;
1090 *)
1091 function sgrep()
1092 {
Jeff Brown46cbd202014-07-26 15:15:41 -07001093 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 Projectb6c1cf62008-10-21 07:00:00 -07001094 }
1095 ;;
1096esac
1097
Raghu Gandham8da43102012-07-25 19:57:22 -07001098function gettargetarch
1099{
1100 get_build_var TARGET_ARCH
1101}
1102
Jon Boekenoogencbca56f2014-04-07 10:57:38 -07001103function ggrep()
1104{
1105 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.gradle" -print0 | xargs -0 grep --color -n "$@"
1106}
1107
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001108function jgrep()
1109{
Anatolii Shuba91c72d22013-07-05 16:09:25 +03001110 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 Projectb6c1cf62008-10-21 07:00:00 -07001111}
1112
1113function cgrep()
1114{
Dan Albert01961192014-11-22 10:16:01 -08001115 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 Projectb6c1cf62008-10-21 07:00:00 -07001116}
1117
1118function resgrep()
1119{
Anatolii Shuba91c72d22013-07-05 16:09:25 +03001120 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 Projectb6c1cf62008-10-21 07:00:00 -07001121}
1122
Jeff Sharkey50b61e92013-03-08 10:20:47 -08001123function mangrep()
1124{
1125 find . -name .repo -prune -o -name .git -prune -o -path ./out -prune -o -type f -name 'AndroidManifest.xml' -print0 | xargs -0 grep --color -n "$@"
1126}
1127
Alex Klyubinba5fc8e2013-05-06 14:11:48 -07001128function sepgrep()
1129{
1130 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 "$@"
1131}
1132
Jeff Sharkeyea0068a2015-02-26 14:13:46 -08001133function rcgrep()
1134{
1135 find . -name .repo -prune -o -name .git -prune -o -name out -prune -o -type f -name "*\.rc*" -print0 | xargs -0 grep --color -n "$@"
1136}
1137
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001138case `uname -s` in
1139 Darwin)
1140 function mgrep()
1141 {
Ying Wang324c2b22012-08-17 15:03:20 -07001142 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 Projectb6c1cf62008-10-21 07:00:00 -07001143 }
1144
1145 function treegrep()
1146 {
Joe Onoratof50e84b2011-03-15 14:15:46 -07001147 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 Projectb6c1cf62008-10-21 07:00:00 -07001148 }
1149
1150 ;;
1151 *)
1152 function mgrep()
1153 {
Ying Wang324c2b22012-08-17 15:03:20 -07001154 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 Projectb6c1cf62008-10-21 07:00:00 -07001155 }
1156
1157 function treegrep()
1158 {
Joe Onoratof50e84b2011-03-15 14:15:46 -07001159 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 Projectb6c1cf62008-10-21 07:00:00 -07001160 }
1161
1162 ;;
1163esac
1164
1165function getprebuilt
1166{
1167 get_abs_build_var ANDROID_PREBUILTS
1168}
1169
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001170function tracedmdump()
1171{
1172 T=$(gettop)
1173 if [ ! "$T" ]; then
1174 echo "Couldn't locate the top of the tree. Try setting TOP."
1175 return
1176 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001177 local prebuiltdir=$(getprebuilt)
Raghu Gandham8da43102012-07-25 19:57:22 -07001178 local arch=$(gettargetarch)
1179 local KERNEL=$T/prebuilts/qemu-kernel/$arch/vmlinux-qemu
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001180
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001181 local TRACE=$1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001182 if [ ! "$TRACE" ] ; then
1183 echo "usage: tracedmdump tracename"
1184 return
1185 fi
1186
Jack Veenstra60116fc2009-04-09 18:12:34 -07001187 if [ ! -r "$KERNEL" ] ; then
1188 echo "Error: cannot find kernel: '$KERNEL'"
1189 return
1190 fi
1191
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001192 local BASETRACE=$(basename $TRACE)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001193 if [ "$BASETRACE" = "$TRACE" ] ; then
1194 TRACE=$ANDROID_PRODUCT_OUT/traces/$TRACE
1195 fi
1196
1197 echo "post-processing traces..."
1198 rm -f $TRACE/qtrace.dexlist
1199 post_trace $TRACE
1200 if [ $? -ne 0 ]; then
1201 echo "***"
1202 echo "*** Error: malformed trace. Did you remember to exit the emulator?"
1203 echo "***"
1204 return
1205 fi
1206 echo "generating dexlist output..."
1207 /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
1208 echo "generating dmtrace data..."
1209 q2dm -r $ANDROID_PRODUCT_OUT/symbols $TRACE $KERNEL $TRACE/dmtrace || return
1210 echo "generating html file..."
1211 dmtracedump -h $TRACE/dmtrace >| $TRACE/dmtrace.html || return
1212 echo "done, see $TRACE/dmtrace.html for details"
1213 echo "or run:"
1214 echo " traceview $TRACE/dmtrace"
1215}
1216
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001217# communicate with a running device or emulator, set up necessary state,
1218# and run the hat command.
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001219function runhat()
1220{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001221 # process standard adb options
1222 local adbTarget=""
Andy McFaddenb6289852010-07-12 08:00:19 -07001223 if [ "$1" = "-d" -o "$1" = "-e" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001224 adbTarget=$1
1225 shift 1
Andy McFaddenb6289852010-07-12 08:00:19 -07001226 elif [ "$1" = "-s" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001227 adbTarget="$1 $2"
1228 shift 2
1229 fi
1230 local adbOptions=${adbTarget}
Dianne Hackborn6b9549f2012-09-26 15:00:59 -07001231 #echo adbOptions = ${adbOptions}
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001232
1233 # runhat options
1234 local targetPid=$1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001235
1236 if [ "$targetPid" = "" ]; then
Andy McFaddenb6289852010-07-12 08:00:19 -07001237 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001238 return
1239 fi
1240
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001241 # confirm hat is available
1242 if [ -z $(which hat) ]; then
1243 echo "hat is not available in this configuration."
1244 return
1245 fi
1246
Andy McFaddenb6289852010-07-12 08:00:19 -07001247 # issue "am" command to cause the hprof dump
Nick Kralevich9948b1e2014-07-18 15:45:38 -07001248 local devFile=/data/local/tmp/hprof-$targetPid
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001249 echo "Poking $targetPid and waiting for data..."
Dianne Hackborn6b9549f2012-09-26 15:00:59 -07001250 echo "Storing data at $devFile"
Andy McFaddenb6289852010-07-12 08:00:19 -07001251 adb ${adbOptions} shell am dumpheap $targetPid $devFile
The Android Open Source Project88b60792009-03-03 19:28:42 -08001252 echo "Press enter when logcat shows \"hprof: heap dump completed\""
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001253 echo -n "> "
1254 read
1255
The Android Open Source Project88b60792009-03-03 19:28:42 -08001256 local localFile=/tmp/$$-hprof
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001257
The Android Open Source Project88b60792009-03-03 19:28:42 -08001258 echo "Retrieving file $devFile..."
1259 adb ${adbOptions} pull $devFile $localFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001260
The Android Open Source Project88b60792009-03-03 19:28:42 -08001261 adb ${adbOptions} shell rm $devFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001262
The Android Open Source Project88b60792009-03-03 19:28:42 -08001263 echo "Running hat on $localFile"
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001264 echo "View the output by pointing your browser at http://localhost:7000/"
1265 echo ""
Dianne Hackborn6e4e1bb2011-11-10 15:19:51 -08001266 hat -JXmx512m $localFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001267}
1268
1269function getbugreports()
1270{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001271 local reports=(`adb shell ls /sdcard/bugreports | tr -d '\r'`)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001272
1273 if [ ! "$reports" ]; then
1274 echo "Could not locate any bugreports."
1275 return
1276 fi
1277
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001278 local report
1279 for report in ${reports[@]}
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001280 do
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001281 echo "/sdcard/bugreports/${report}"
1282 adb pull /sdcard/bugreports/${report} ${report}
1283 gunzip ${report}
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001284 done
1285}
1286
Victoria Lease1b296b42012-08-21 15:44:06 -07001287function getsdcardpath()
1288{
1289 adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\}
1290}
1291
1292function getscreenshotpath()
1293{
1294 echo "$(getsdcardpath)/Pictures/Screenshots"
1295}
1296
1297function getlastscreenshot()
1298{
1299 local screenshot_path=$(getscreenshotpath)
1300 local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1`
1301 if [ "$screenshot" = "" ]; then
1302 echo "No screenshots found."
1303 return
1304 fi
1305 echo "${screenshot}"
1306 adb ${adbOptions} pull ${screenshot_path}/${screenshot}
1307}
1308
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001309function startviewserver()
1310{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001311 local port=4939
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001312 if [ $# -gt 0 ]; then
1313 port=$1
1314 fi
1315 adb shell service call window 1 i32 $port
1316}
1317
1318function stopviewserver()
1319{
1320 adb shell service call window 2
1321}
1322
1323function isviewserverstarted()
1324{
1325 adb shell service call window 3
1326}
1327
Romain Guyb84049a2010-10-04 16:56:11 -07001328function key_home()
1329{
1330 adb shell input keyevent 3
1331}
1332
1333function key_back()
1334{
1335 adb shell input keyevent 4
1336}
1337
1338function key_menu()
1339{
1340 adb shell input keyevent 82
1341}
1342
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001343function smoketest()
1344{
1345 if [ ! "$ANDROID_PRODUCT_OUT" ]; then
1346 echo "Couldn't locate output files. Try running 'lunch' first." >&2
1347 return
1348 fi
1349 T=$(gettop)
1350 if [ ! "$T" ]; then
1351 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1352 return
1353 fi
1354
Ying Wang9cd17642012-12-13 10:52:07 -08001355 (\cd "$T" && mmm tests/SmokeTest) &&
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -07001356 adb uninstall com.android.smoketest > /dev/null &&
1357 adb uninstall com.android.smoketest.tests > /dev/null &&
1358 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTestApp.apk &&
1359 adb install $ANDROID_PRODUCT_OUT/data/app/SmokeTest.apk &&
1360 adb shell am instrument -w com.android.smoketest.tests/android.test.InstrumentationTestRunner
1361}
1362
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001363# simple shortcut to the runtest command
1364function runtest()
1365{
1366 T=$(gettop)
1367 if [ ! "$T" ]; then
1368 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
1369 return
1370 fi
Brett Chabot3fb149d2009-10-21 20:05:26 -07001371 ("$T"/development/testrunner/runtest.py $@)
Brett Chabot762748c2009-03-27 10:25:11 -07001372}
1373
The Android Open Source Project88b60792009-03-03 19:28:42 -08001374function godir () {
1375 if [[ -z "$1" ]]; then
1376 echo "Usage: godir <regex>"
1377 return
1378 fi
Brian Carlstromb9915a62010-01-29 16:39:32 -08001379 T=$(gettop)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001380 if [[ ! -f $T/filelist ]]; then
1381 echo -n "Creating index..."
Ying Wang9cd17642012-12-13 10:52:07 -08001382 (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > filelist)
The Android Open Source Project88b60792009-03-03 19:28:42 -08001383 echo " Done"
1384 echo ""
1385 fi
1386 local lines
Jeff Hamilton293f9392011-11-18 17:15:25 -06001387 lines=($(\grep "$1" $T/filelist | sed -e 's/\/[^/]*$//' | sort | uniq))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001388 if [[ ${#lines[@]} = 0 ]]; then
1389 echo "Not found"
1390 return
1391 fi
1392 local pathname
1393 local choice
1394 if [[ ${#lines[@]} > 1 ]]; then
1395 while [[ -z "$pathname" ]]; do
1396 local index=1
1397 local line
1398 for line in ${lines[@]}; do
1399 printf "%6s %s\n" "[$index]" $line
Doug Zongker29034982011-04-22 08:16:56 -07001400 index=$(($index + 1))
The Android Open Source Project88b60792009-03-03 19:28:42 -08001401 done
1402 echo
1403 echo -n "Select one: "
1404 unset choice
1405 read choice
1406 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
1407 echo "Invalid choice"
1408 continue
1409 fi
Kan-Ru Chen07453762010-07-05 15:53:47 +08001410 pathname=${lines[$(($choice-1))]}
The Android Open Source Project88b60792009-03-03 19:28:42 -08001411 done
1412 else
The Android Open Source Project88b60792009-03-03 19:28:42 -08001413 pathname=${lines[0]}
1414 fi
Ying Wang9cd17642012-12-13 10:52:07 -08001415 \cd $T/$pathname
The Android Open Source Project88b60792009-03-03 19:28:42 -08001416}
1417
Andrew Sutherlandd6bd0652011-11-18 00:45:55 -06001418function cmremote()
1419{
1420 git remote rm cmremote 2> /dev/null
1421 if [ ! -d .git ]
1422 then
1423 echo .git directory not found. Please run this from the root directory of the Android repository you wish to set up.
1424 fi
1425 GERRIT_REMOTE=$(cat .git/config | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g)
1426 if [ -z "$GERRIT_REMOTE" ]
1427 then
1428 echo Unable to set up the git remote, are you in the root of the repo?
1429 return 0
1430 fi
1431 CMUSER=`git config --get review.review.cyanogenmod.com.username`
1432 if [ -z "$CMUSER" ]
1433 then
1434 git remote add cmremote ssh://review.cyanogenmod.com:29418/$GERRIT_REMOTE
1435 else
1436 git remote add cmremote ssh://$CMUSER@review.cyanogenmod.com:29418/$GERRIT_REMOTE
1437 fi
1438 echo You can now push to "cmremote".
1439}
1440
1441function cmgerrit() {
1442 if [ $# -eq 0 ]; then
1443 $FUNCNAME help
1444 return 1
1445 fi
1446 local user=`git config --get review.review.cyanogenmod.com.username`
1447 local review=`git config --get remote.github.review`
1448 local project=`git config --get remote.github.projectname`
1449 local command=$1
1450 shift
1451 case $command in
1452 help)
1453 if [ $# -eq 0 ]; then
1454 cat <<EOF
1455Usage:
1456 $FUNCNAME COMMAND [OPTIONS] [CHANGE-ID[/PATCH-SET]][{@|^|~|:}ARG] [-- ARGS]
1457
1458Commands:
1459 fetch Just fetch the change as FETCH_HEAD
1460 help Show this help, or for a specific command
1461 pull Pull a change into current branch
1462 push Push HEAD or a local branch to Gerrit for a specific branch
1463
1464Any other Git commands that support refname would work as:
1465 git fetch URL CHANGE && git COMMAND OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
1466
1467See '$FUNCNAME help COMMAND' for more information on a specific command.
1468
1469Example:
1470 $FUNCNAME checkout -b topic 1234/5
1471works as:
1472 git fetch http://DOMAIN/p/PROJECT refs/changes/34/1234/5 \\
1473 && git checkout -b topic FETCH_HEAD
1474will checkout a new branch 'topic' base on patch-set 5 of change 1234.
1475Patch-set 1 will be fetched if omitted.
1476EOF
1477 return
1478 fi
1479 case $1 in
1480 __cmg_*) echo "For internal use only." ;;
1481 changes|for)
1482 if [ "$FUNCNAME" = "cmgerrit" ]; then
1483 echo "'$FUNCNAME $1' is deprecated."
1484 fi
1485 ;;
1486 help) $FUNCNAME help ;;
1487 fetch|pull) cat <<EOF
1488usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET]
1489
1490works as:
1491 git $1 OPTIONS http://DOMAIN/p/PROJECT \\
1492 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1}
1493
1494Example:
1495 $FUNCNAME $1 1234
1496will $1 patch-set 1 of change 1234
1497EOF
1498 ;;
1499 push) cat <<EOF
1500usage: $FUNCNAME push [OPTIONS] [LOCAL_BRANCH:]REMOTE_BRANCH
1501
1502works as:
1503 git push OPTIONS ssh://USER@DOMAIN:29418/PROJECT \\
1504 {LOCAL_BRANCH|HEAD}:refs/for/REMOTE_BRANCH
1505
1506Example:
1507 $FUNCNAME push fix6789:gingerbread
1508will push local branch 'fix6789' to Gerrit for branch 'gingerbread'.
1509HEAD will be pushed from local if omitted.
1510EOF
1511 ;;
1512 *)
1513 $FUNCNAME __cmg_err_not_supported $1 && return
1514 cat <<EOF
1515usage: $FUNCNAME $1 [OPTIONS] CHANGE-ID[/PATCH-SET][{@|^|~|:}ARG] [-- ARGS]
1516
1517works as:
1518 git fetch http://DOMAIN/p/PROJECT \\
1519 refs/changes/HASH/CHANGE-ID/{PATCH-SET|1} \\
1520 && git $1 OPTIONS FETCH_HEAD{@|^|~|:}ARG -- ARGS
1521EOF
1522 ;;
1523 esac
1524 ;;
1525 __cmg_get_ref)
1526 $FUNCNAME __cmg_err_no_arg $command $# && return 1
1527 local change_id patchset_id hash
1528 case $1 in
1529 */*)
1530 change_id=${1%%/*}
1531 patchset_id=${1#*/}
1532 ;;
1533 *)
1534 change_id=$1
1535 patchset_id=1
1536 ;;
1537 esac
1538 hash=$(($change_id % 100))
1539 case $hash in
1540 [0-9]) hash="0$hash" ;;
1541 esac
1542 echo "refs/changes/$hash/$change_id/$patchset_id"
1543 ;;
1544 fetch|pull)
1545 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
1546 $FUNCNAME __cmg_err_not_repo && return 1
1547 local change=$1
1548 shift
1549 git $command $@ http://$review/p/$project \
1550 $($FUNCNAME __cmg_get_ref $change) || return 1
1551 ;;
1552 push)
1553 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
1554 $FUNCNAME __cmg_err_not_repo && return 1
1555 if [ -z "$user" ]; then
1556 echo >&2 "Gerrit username not found."
1557 return 1
1558 fi
1559 local local_branch remote_branch
1560 case $1 in
1561 *:*)
1562 local_branch=${1%:*}
1563 remote_branch=${1##*:}
1564 ;;
1565 *)
1566 local_branch=HEAD
1567 remote_branch=$1
1568 ;;
1569 esac
1570 shift
1571 git push $@ ssh://$user@$review:29418/$project \
1572 $local_branch:refs/for/$remote_branch || return 1
1573 ;;
1574 changes|for)
1575 if [ "$FUNCNAME" = "cmgerrit" ]; then
1576 echo >&2 "'$FUNCNAME $command' is deprecated."
1577 fi
1578 ;;
1579 __cmg_err_no_arg)
1580 if [ $# -lt 2 ]; then
1581 echo >&2 "'$FUNCNAME $command' missing argument."
1582 elif [ $2 -eq 0 ]; then
1583 if [ -n "$3" ]; then
1584 $FUNCNAME help $1
1585 else
1586 echo >&2 "'$FUNCNAME $1' missing argument."
1587 fi
1588 else
1589 return 1
1590 fi
1591 ;;
1592 __cmg_err_not_repo)
1593 if [ -z "$review" -o -z "$project" ]; then
1594 echo >&2 "Not currently in any reviewable repository."
1595 else
1596 return 1
1597 fi
1598 ;;
1599 __cmg_err_not_supported)
1600 $FUNCNAME __cmg_err_no_arg $command $# && return
1601 case $1 in
1602 #TODO: filter more git commands that don't use refname
1603 init|add|rm|mv|status|clone|remote|bisect|config|stash)
1604 echo >&2 "'$FUNCNAME $1' is not supported."
1605 ;;
1606 *) return 1 ;;
1607 esac
1608 ;;
1609 #TODO: other special cases?
1610 *)
1611 $FUNCNAME __cmg_err_not_supported $command && return 1
1612 $FUNCNAME __cmg_err_no_arg $command $# help && return 1
1613 $FUNCNAME __cmg_err_not_repo && return 1
1614 local args="$@"
1615 local change pre_args refs_arg post_args
1616 case "$args" in
1617 *--\ *)
1618 pre_args=${args%%-- *}
1619 post_args="-- ${args#*-- }"
1620 ;;
1621 *) pre_args="$args" ;;
1622 esac
1623 args=($pre_args)
1624 pre_args=
1625 if [ ${#args[@]} -gt 0 ]; then
1626 change=${args[${#args[@]}-1]}
1627 fi
1628 if [ ${#args[@]} -gt 1 ]; then
1629 pre_args=${args[0]}
1630 for ((i=1; i<${#args[@]}-1; i++)); do
1631 pre_args="$pre_args ${args[$i]}"
1632 done
1633 fi
1634 while ((1)); do
1635 case $change in
1636 ""|--)
1637 $FUNCNAME help $command
1638 return 1
1639 ;;
1640 *@*)
1641 if [ -z "$refs_arg" ]; then
1642 refs_arg="@${change#*@}"
1643 change=${change%%@*}
1644 fi
1645 ;;
1646 *~*)
1647 if [ -z "$refs_arg" ]; then
1648 refs_arg="~${change#*~}"
1649 change=${change%%~*}
1650 fi
1651 ;;
1652 *^*)
1653 if [ -z "$refs_arg" ]; then
1654 refs_arg="^${change#*^}"
1655 change=${change%%^*}
1656 fi
1657 ;;
1658 *:*)
1659 if [ -z "$refs_arg" ]; then
1660 refs_arg=":${change#*:}"
1661 change=${change%%:*}
1662 fi
1663 ;;
1664 *) break ;;
1665 esac
1666 done
1667 $FUNCNAME fetch $change \
1668 && git $command $pre_args FETCH_HEAD$refs_arg $post_args \
1669 || return 1
1670 ;;
1671 esac
1672}
1673
1674function cmrebase() {
1675 local repo=$1
1676 local refs=$2
1677 local pwd="$(pwd)"
1678 local dir="$(gettop)/$repo"
1679
1680 if [ -z $repo ] || [ -z $refs ]; then
1681 echo "CyanogenMod Gerrit Rebase Usage: "
1682 echo " cmrebase <path to project> <patch IDs on Gerrit>"
1683 echo " The patch IDs appear on the Gerrit commands that are offered."
1684 echo " They consist on a series of numbers and slashes, after the text"
1685 echo " refs/changes. For example, the ID in the following command is 26/8126/2"
1686 echo ""
1687 echo " git[...]ges_apps_Camera refs/changes/26/8126/2 && git cherry-pick FETCH_HEAD"
1688 echo ""
1689 return
1690 fi
1691
1692 if [ ! -d $dir ]; then
1693 echo "Directory $dir doesn't exist in tree."
1694 return
1695 fi
1696 cd $dir
1697 repo=$(cat .git/config | grep git://github.com | awk '{ print $NF }' | sed s#git://github.com/##g)
1698 echo "Starting branch..."
1699 repo start tmprebase .
1700 echo "Bringing it up to date..."
1701 repo sync .
1702 echo "Fetching change..."
1703 git fetch "http://review.cyanogenmod.com/p/$repo" "refs/changes/$refs" && git cherry-pick FETCH_HEAD
1704 if [ "$?" != "0" ]; then
1705 echo "Error cherry-picking. Not uploading!"
1706 return
1707 fi
1708 echo "Uploading..."
1709 repo upload .
1710 echo "Cleaning up..."
1711 repo abandon tmprebase .
1712 cd $pwd
1713}
1714
1715function mka() {
1716 case `uname -s` in
1717 Darwin)
1718 make -j `sysctl hw.ncpu|cut -d" " -f2` "$@"
1719 ;;
1720 *)
1721 schedtool -B -n 1 -e ionice -n 1 make -j `cat /proc/cpuinfo | grep "^processor" | wc -l` "$@"
1722 ;;
1723 esac
1724}
1725
1726function reposync() {
1727 case `uname -s` in
1728 Darwin)
1729 repo sync -j 4 "$@"
1730 ;;
1731 *)
1732 schedtool -B -n 1 -e ionice -n 1 repo sync -j 4 "$@"
1733 ;;
1734 esac
1735}
1736# Force JAVA_HOME to point to java 1.7 or java 1.6 if it isn't already set.
Narayan Kamath9260bba2014-01-17 10:05:25 +00001737#
1738# Note that the MacOS path for java 1.7 includes a minor revision number (sigh).
1739# For some reason, installing the JDK doesn't make it show up in the
1740# JavaVM.framework/Versions/1.7/ folder.
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -05001741function set_java_home() {
Narayan Kamath9260bba2014-01-17 10:05:25 +00001742 # Clear the existing JAVA_HOME value if we set it ourselves, so that
Narayan Kamathc84889b2014-04-01 14:16:26 +01001743 # we can reset it later, depending on the version of java the build
1744 # system needs.
Narayan Kamath9260bba2014-01-17 10:05:25 +00001745 #
1746 # If we don't do this, the JAVA_HOME value set by the first call to
1747 # build/envsetup.sh will persist forever.
1748 if [ -n "$ANDROID_SET_JAVA_HOME" ]; then
1749 export JAVA_HOME=""
1750 fi
1751
Andy McFaddenbd960942010-06-24 12:52:51 -07001752 if [ ! "$JAVA_HOME" ]; then
Neil Fuller46e00ea2014-10-16 10:23:03 +01001753 case `uname -s` in
1754 Darwin)
1755 export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
1756 ;;
1757 *)
1758 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
1759 ;;
1760 esac
Narayan Kamath9260bba2014-01-17 10:05:25 +00001761
1762 # Keep track of the fact that we set JAVA_HOME ourselves, so that
1763 # we can change it on the next envsetup.sh, if required.
1764 export ANDROID_SET_JAVA_HOME=true
Jeff Hamilton04be0d82010-06-07 15:03:54 -05001765 fi
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -05001766}
Jeff Hamilton04be0d82010-06-07 15:03:54 -05001767
Alex Rayf0d08eb2013-03-08 15:15:06 -08001768# Print colored exit condition
1769function pez {
Michael Wrighteb733842013-03-08 17:34:02 -08001770 "$@"
1771 local retval=$?
1772 if [ $retval -ne 0 ]
1773 then
1774 echo -e "\e[0;31mFAILURE\e[00m"
1775 else
1776 echo -e "\e[0;32mSUCCESS\e[00m"
1777 fi
1778 return $retval
Alex Rayf0d08eb2013-03-08 15:15:06 -08001779}
1780
Ying Wanged21d4c2014-08-24 22:14:19 -07001781function get_make_command()
1782{
1783 echo command make
1784}
1785
Ed Heylcc6be0a2014-06-18 14:55:58 -07001786function make()
1787{
1788 local start_time=$(date +"%s")
Ying Wanged21d4c2014-08-24 22:14:19 -07001789 $(get_make_command) "$@"
Ed Heylcc6be0a2014-06-18 14:55:58 -07001790 local ret=$?
1791 local end_time=$(date +"%s")
1792 local tdiff=$(($end_time-$start_time))
1793 local hours=$(($tdiff / 3600 ))
1794 local mins=$((($tdiff % 3600) / 60))
1795 local secs=$(($tdiff % 60))
Greg Hackmannd95c7f72014-06-23 14:05:06 -07001796 local ncolors=$(tput colors 2>/dev/null)
1797 if [ -n "$ncolors" ] && [ $ncolors -ge 8 ]; then
1798 color_failed="\e[0;31m"
1799 color_success="\e[0;32m"
1800 color_reset="\e[00m"
1801 else
1802 color_failed=""
1803 color_success=""
1804 color_reset=""
1805 fi
Ed Heylcc6be0a2014-06-18 14:55:58 -07001806 echo
1807 if [ $ret -eq 0 ] ; then
Greg Hackmannd95c7f72014-06-23 14:05:06 -07001808 echo -n -e "${color_success}#### make completed successfully "
Ed Heylcc6be0a2014-06-18 14:55:58 -07001809 else
Greg Hackmannd95c7f72014-06-23 14:05:06 -07001810 echo -n -e "${color_failed}#### make failed to build some targets "
Ed Heylcc6be0a2014-06-18 14:55:58 -07001811 fi
1812 if [ $hours -gt 0 ] ; then
1813 printf "(%02g:%02g:%02g (hh:mm:ss))" $hours $mins $secs
1814 elif [ $mins -gt 0 ] ; then
1815 printf "(%02g:%02g (mm:ss))" $mins $secs
1816 elif [ $secs -gt 0 ] ; then
1817 printf "(%s seconds)" $secs
1818 fi
Greg Hackmannd95c7f72014-06-23 14:05:06 -07001819 echo -e " ####${color_reset}"
Ed Heylcc6be0a2014-06-18 14:55:58 -07001820 echo
1821 return $ret
1822}
1823
Raphael Moll70a86b02011-06-20 16:03:14 -07001824if [ "x$SHELL" != "x/bin/bash" ]; then
1825 case `ps -o command -p $$` in
1826 *bash*)
1827 ;;
1828 *)
1829 echo "WARNING: Only bash is supported, use of other shell would lead to erroneous results"
1830 ;;
1831 esac
1832fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001833
1834# Execute the contents of any vendorsetup.sh files we can find.
Oleksiy Avramchenko15760a82014-10-06 18:51:58 +02001835for f in `test -d device && find -L device -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort` \
1836 `test -d vendor && find -L vendor -maxdepth 4 -name 'vendorsetup.sh' 2> /dev/null | sort`
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001837do
1838 echo "including $f"
1839 . $f
1840done
1841unset f
Kenny Root52aa81c2011-07-15 11:07:06 -07001842
1843addcompletions