blob: afe41d514c3d84a1b2b8c471c77559f2f89b56f1 [file] [log] [blame]
Joe Onorato344e4042022-12-05 15:15:36 -08001# Copyright (C) 2022 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# gettop is duplicated here and in shell_utils.mk, because it's difficult
16# to find shell_utils.make without it for all the novel ways this file can be
17# sourced. Other common functions should only be in one place or the other.
18function _gettop_once
19{
20 local TOPFILE=build/make/core/envsetup.mk
21 if [ -n "$TOP" -a -f "$TOP/$TOPFILE" ] ; then
22 # The following circumlocution ensures we remove symlinks from TOP.
23 (cd "$TOP"; PWD= /bin/pwd)
24 else
25 if [ -f $TOPFILE ] ; then
26 # The following circumlocution (repeated below as well) ensures
27 # that we record the true directory name and not one that is
28 # faked up with symlink names.
29 PWD= /bin/pwd
30 else
31 local HERE=$PWD
32 local T=
33 while [ \( ! \( -f $TOPFILE \) \) -a \( "$PWD" != "/" \) ]; do
34 \cd ..
35 T=`PWD= /bin/pwd -P`
36 done
37 \cd "$HERE"
38 if [ -f "$T/$TOPFILE" ]; then
39 echo "$T"
40 fi
41 fi
42 fi
43}
44T=$(_gettop_once)
45if [ ! "$T" ]; then
46 echo "Couldn't locate the top of the tree. Always source build/envsetup.sh from the root of the tree." >&2
47 return 1
48fi
49IMPORTING_ENVSETUP=true source $T/build/make/shell_utils.sh
50
Ying Wang08800fd2016-03-03 20:57:21 -080051# Get all the build variables needed by this script in a single call to the build system.
Matt Alexanderd9c56562020-05-21 10:49:17 +000052function build_build_var_cache()
53{
Christopher Ferris55257d22017-03-23 11:08:58 -070054 local T=$(gettop)
Ying Wang08800fd2016-03-03 20:57:21 -080055 # Grep out the variable names from the script.
Alexander Martinze2761e72022-04-07 18:02:53 +020056 cached_vars=(`cat $T/build/envsetup.sh $T/vendor/lineage/build/envsetup.sh $T/vendor/shiftos/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
57 cached_abs_vars=(`cat $T/build/envsetup.sh $T/vendor/lineage/build/envsetup.sh $T/vendor/shiftos/build/envsetup.sh | tr '()' ' ' | awk '{for(i=1;i<=NF;i++) if($i~/_get_abs_build_var_cached/) print $(i+1)}' | sort -u | tr '\n' ' '`)
Ying Wang08800fd2016-03-03 20:57:21 -080058 # Call the build system to dump the "<val>=<value>" pairs as a shell script.
Steven Moreland05402962018-01-05 12:13:11 -080059 build_dicts_script=`\builtin cd $T; build/soong/soong_ui.bash --dumpvars-mode \
Jim Tanga881a252018-06-19 16:34:41 +080060 --vars="${cached_vars[*]}" \
61 --abs-vars="${cached_abs_vars[*]}" \
Dan Willemsenaf88c412017-07-14 11:29:44 -070062 --var-prefix=var_cache_ \
63 --abs-var-prefix=abs_var_cache_`
Ying Wang08800fd2016-03-03 20:57:21 -080064 local ret=$?
Matt Alexanderd9c56562020-05-21 10:49:17 +000065 if [ $ret -ne 0 ]
66 then
Ying Wang08800fd2016-03-03 20:57:21 -080067 unset build_dicts_script
68 return $ret
69 fi
Dan Willemsenaf88c412017-07-14 11:29:44 -070070 # Execute the script to store the "<val>=<value>" pairs as shell variables.
Ying Wang08800fd2016-03-03 20:57:21 -080071 eval "$build_dicts_script"
Ying Wang08800fd2016-03-03 20:57:21 -080072 ret=$?
Ying Wangf0cb3972016-03-04 13:56:23 -080073 unset build_dicts_script
Matt Alexanderd9c56562020-05-21 10:49:17 +000074 if [ $ret -ne 0 ]
75 then
Ying Wang08800fd2016-03-03 20:57:21 -080076 return $ret
77 fi
78 BUILD_VAR_CACHE_READY="true"
79}
80
Ying Wangf0cb3972016-03-04 13:56:23 -080081# Delete the build var cache, so that we can still call into the build system
Ying Wang08800fd2016-03-03 20:57:21 -080082# to get build variables not listed in this script.
Matt Alexanderd9c56562020-05-21 10:49:17 +000083function destroy_build_var_cache()
84{
Ying Wang08800fd2016-03-03 20:57:21 -080085 unset BUILD_VAR_CACHE_READY
Christopher Ferris55257d22017-03-23 11:08:58 -070086 local v
Ying Wang08800fd2016-03-03 20:57:21 -080087 for v in $cached_vars; do
88 unset var_cache_$v
89 done
90 unset cached_vars
91 for v in $cached_abs_vars; do
92 unset abs_var_cache_$v
93 done
94 unset cached_abs_vars
95}
96
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -070097# Get the value of a build variable as an absolute path.
Joe Onorato0e68f702024-05-24 14:19:21 -070098function _get_abs_build_var_cached()
Matt Alexanderd9c56562020-05-21 10:49:17 +000099{
100 if [ "$BUILD_VAR_CACHE_READY" = "true" ]
101 then
Vishwath Mohan7d35f002016-03-11 10:00:40 -0800102 eval "echo \"\${abs_var_cache_$1}\""
Timi0469c3f2021-04-15 16:41:18 +0200103 return
Ying Wang08800fd2016-03-03 20:57:21 -0800104 fi
105
Christopher Ferris55257d22017-03-23 11:08:58 -0700106 local T=$(gettop)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700107 if [ ! "$T" ]; then
108 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
109 return
110 fi
Dan Willemsenaf88c412017-07-14 11:29:44 -0700111 (\cd $T; build/soong/soong_ui.bash --dumpvar-mode --abs $1)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700112}
113
114# Get the exact value of a build variable.
Joe Onorato0e68f702024-05-24 14:19:21 -0700115function _get_build_var_cached()
Matt Alexanderd9c56562020-05-21 10:49:17 +0000116{
117 if [ "$BUILD_VAR_CACHE_READY" = "true" ]
118 then
Vishwath Mohan7d35f002016-03-11 10:00:40 -0800119 eval "echo \"\${var_cache_$1}\""
Roland Levillain23c46cf2020-03-31 16:11:05 +0100120 return 0
Ying Wang08800fd2016-03-03 20:57:21 -0800121 fi
122
Christopher Ferris55257d22017-03-23 11:08:58 -0700123 local T=$(gettop)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700124 if [ ! "$T" ]; then
125 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
Roland Levillain23c46cf2020-03-31 16:11:05 +0100126 return 1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700127 fi
Dan Willemsenaf88c412017-07-14 11:29:44 -0700128 (\cd $T; build/soong/soong_ui.bash --dumpvar-mode $1)
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800129}
130
Joe Onorato32b2aa32024-05-14 13:54:13 -0700131# This logic matches envsetup.mk
132function get_host_prebuilt_prefix
133{
134 local un=$(uname)
135 if [[ $un == "Linux" ]] ; then
136 echo linux-x86
137 elif [[ $un == "Darwin" ]] ; then
138 echo darwin-x86
139 else
140 echo "Error: Invalid host operating system: $un" 1>&2
141 fi
142}
143
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800144# Add directories to PATH that are dependent on the lunch target.
145# For directories that are not lunch-specific, add them in set_global_paths
146function set_lunch_paths()
Matt Alexanderd9c56562020-05-21 10:49:17 +0000147{
Christopher Ferris55257d22017-03-23 11:08:58 -0700148 local T=$(gettop)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700149 if [ ! "$T" ]; then
150 echo "Couldn't locate the top of the tree. Try setting TOP."
151 return
152 fi
153
154 ##################################################################
155 # #
156 # Read me before you modify this code #
157 # #
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800158 # This function sets ANDROID_LUNCH_BUILD_PATHS to what it is #
159 # adding to PATH, and the next time it is run, it removes that #
160 # from PATH. This is required so lunch can be run more than #
161 # once and still have working paths. #
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700162 # #
163 ##################################################################
164
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800165 # Note: on windows/cygwin, ANDROID_LUNCH_BUILD_PATHS will contain spaces
Raphael Mollc639c782011-06-20 17:25:01 -0700166 # due to "C:\Program Files" being in the path.
167
Kevin Dagostino185109b2024-01-11 17:39:02 +0000168 # Handle compat with the old ANDROID_BUILD_PATHS variable.
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800169 # TODO: Remove this after we think everyone has lunched again.
170 if [ -z "$ANDROID_LUNCH_BUILD_PATHS" -a -n "$ANDROID_BUILD_PATHS" ] ; then
171 ANDROID_LUNCH_BUILD_PATHS="$ANDROID_BUILD_PATHS"
172 ANDROID_BUILD_PATHS=
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700173 fi
Matt Alexanderd9c56562020-05-21 10:49:17 +0000174 if [ -n "$ANDROID_PRE_BUILD_PATHS" ] ; then
Doug Zongker29034982011-04-22 08:16:56 -0700175 export PATH=${PATH/$ANDROID_PRE_BUILD_PATHS/}
Ying Wangaa1c9b52012-11-26 20:51:59 -0800176 # strip leading ':', if any
177 export PATH=${PATH/:%/}
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800178 ANDROID_PRE_BUILD_PATHS=
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500179 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700180
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800181 # Out with the old...
182 if [ -n "$ANDROID_LUNCH_BUILD_PATHS" ] ; then
183 export PATH=${PATH/$ANDROID_LUNCH_BUILD_PATHS/}
184 fi
Ben Chengfba67bf2014-02-25 10:27:07 -0800185
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800186 # And in with the new...
Joe Onorato0e68f702024-05-24 14:19:21 -0700187 ANDROID_LUNCH_BUILD_PATHS=$(_get_abs_build_var_cached SOONG_HOST_OUT_EXECUTABLES)
188 ANDROID_LUNCH_BUILD_PATHS+=:$(_get_abs_build_var_cached HOST_OUT_EXECUTABLES)
Yueyao Zhuefc786a2017-04-07 14:11:54 -0700189
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800190 # Append llvm binutils prebuilts path to ANDROID_LUNCH_BUILD_PATHS.
Joe Onorato0e68f702024-05-24 14:19:21 -0700191 local ANDROID_LLVM_BINUTILS=$(_get_abs_build_var_cached ANDROID_CLANG_PREBUILTS)/llvm-binutils-stable
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800192 ANDROID_LUNCH_BUILD_PATHS+=:$ANDROID_LLVM_BINUTILS
David 'Digit' Turner94d16e52014-05-05 16:13:50 +0200193
Stephen Hinesaa8d72c2020-02-04 09:15:18 -0800194 # Set up ASAN_SYMBOLIZER_PATH for SANITIZE_HOST=address builds.
195 export ASAN_SYMBOLIZER_PATH=$ANDROID_LLVM_BINUTILS/llvm-symbolizer
196
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800197 # Append asuite prebuilts path to ANDROID_LUNCH_BUILD_PATHS.
Joe Onorato0e68f702024-05-24 14:19:21 -0700198 local os_arch=$(_get_build_var_cached HOST_PREBUILT_TAG)
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800199 ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/acloud/$os_arch
200 ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/aidegen/$os_arch
201 ANDROID_LUNCH_BUILD_PATHS+=:$T/prebuilts/asuite/atest/$os_arch
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800202
Joe Onorato0e68f702024-05-24 14:19:21 -0700203 export ANDROID_JAVA_HOME=$(_get_abs_build_var_cached ANDROID_JAVA_HOME)
Colin Crosse97e6932017-06-30 16:01:45 -0700204 export JAVA_HOME=$ANDROID_JAVA_HOME
Joe Onorato0e68f702024-05-24 14:19:21 -0700205 export ANDROID_JAVA_TOOLCHAIN=$(_get_abs_build_var_cached ANDROID_JAVA_TOOLCHAIN)
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800206 ANDROID_LUNCH_BUILD_PATHS+=:$ANDROID_JAVA_TOOLCHAIN
207
208 # Fix up PYTHONPATH
209 if [ -n $ANDROID_PYTHONPATH ]; then
210 export PYTHONPATH=${PYTHONPATH//$ANDROID_PYTHONPATH/}
211 fi
Dan Albert0d6d3592023-01-26 00:07:03 +0000212 # //development/python-packages contains both a pseudo-PYTHONPATH which
213 # mimics an already assembled venv, but also contains real Python packages
214 # that are not in that layout until they are installed. We can fake it for
215 # the latter type by adding the package source directories to the PYTHONPATH
216 # directly. For the former group, we only need to add the python-packages
217 # directory itself.
218 #
219 # This could be cleaned up by converting the remaining packages that are in
220 # the first category into a typical python source layout (that is, another
221 # layer of directory nesting) and automatically adding all subdirectories of
222 # python-packages to the PYTHONPATH instead of manually curating this. We
223 # can't convert the packages like adb to the other style because doing so
224 # would prevent exporting type info from those packages.
225 #
226 # http://b/266688086
Dan Albert426ac692023-05-16 22:59:55 +0000227 export ANDROID_PYTHONPATH=$T/development/python-packages/adb:$T/development/python-packages/gdbrunner:$T/development/python-packages:
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800228 if [ -n $VENDOR_PYTHONPATH ]; then
229 ANDROID_PYTHONPATH=$ANDROID_PYTHONPATH$VENDOR_PYTHONPATH
230 fi
231 export PYTHONPATH=$ANDROID_PYTHONPATH$PYTHONPATH
Jeff Hamilton4a1c70e2010-06-21 18:26:38 -0500232
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800233 unset ANDROID_PRODUCT_OUT
Joe Onorato0e68f702024-05-24 14:19:21 -0700234 export ANDROID_PRODUCT_OUT=$(_get_abs_build_var_cached PRODUCT_OUT)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700235 export OUT=$ANDROID_PRODUCT_OUT
236
Jeff Brown8fd5cce2011-03-24 17:03:06 -0700237 unset ANDROID_HOST_OUT
Joe Onorato0e68f702024-05-24 14:19:21 -0700238 export ANDROID_HOST_OUT=$(_get_abs_build_var_cached HOST_OUT)
Jeff Brown8fd5cce2011-03-24 17:03:06 -0700239
Jiyong Parkc02b1c42020-11-03 11:06:39 +0900240 unset ANDROID_SOONG_HOST_OUT
Joe Onorato0e68f702024-05-24 14:19:21 -0700241 export ANDROID_SOONG_HOST_OUT=$(_get_abs_build_var_cached SOONG_HOST_OUT)
Jiyong Parkc02b1c42020-11-03 11:06:39 +0900242
Simran Basidd050ed2017-02-13 13:46:48 -0800243 unset ANDROID_HOST_OUT_TESTCASES
Joe Onorato0e68f702024-05-24 14:19:21 -0700244 export ANDROID_HOST_OUT_TESTCASES=$(_get_abs_build_var_cached HOST_OUT_TESTCASES)
Simran Basidd050ed2017-02-13 13:46:48 -0800245
246 unset ANDROID_TARGET_OUT_TESTCASES
Joe Onorato0e68f702024-05-24 14:19:21 -0700247 export ANDROID_TARGET_OUT_TESTCASES=$(_get_abs_build_var_cached TARGET_OUT_TESTCASES)
Simran Basidd050ed2017-02-13 13:46:48 -0800248
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800249 # Finally, set PATH
Joe Onorato1cb9e152022-12-05 16:56:15 -0800250 export PATH=$ANDROID_LUNCH_BUILD_PATHS:$PATH
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800251}
252
253# Add directories to PATH that are NOT dependent on the lunch target.
254# For directories that are lunch-specific, add them in set_lunch_paths
255function set_global_paths()
256{
257 local T=$(gettop)
258 if [ ! "$T" ]; then
259 echo "Couldn't locate the top of the tree. Try setting TOP."
260 return
261 fi
262
263 ##################################################################
264 # #
265 # Read me before you modify this code #
266 # #
267 # This function sets ANDROID_GLOBAL_BUILD_PATHS to what it is #
268 # adding to PATH, and the next time it is run, it removes that #
269 # from PATH. This is required so envsetup.sh can be sourced #
270 # more than once and still have working paths. #
271 # #
272 ##################################################################
273
274 # Out with the old...
275 if [ -n "$ANDROID_GLOBAL_BUILD_PATHS" ] ; then
276 export PATH=${PATH/$ANDROID_GLOBAL_BUILD_PATHS/}
277 fi
278
279 # And in with the new...
Joe Onorato84e61d02024-02-02 22:53:39 -0800280 ANDROID_GLOBAL_BUILD_PATHS=$T/build/soong/bin
LaMont Jonese8a3be22024-02-12 09:55:41 -0800281 ANDROID_GLOBAL_BUILD_PATHS+=:$T/build/bazel/bin
Joe Onorato1cb9e152022-12-05 16:56:15 -0800282 ANDROID_GLOBAL_BUILD_PATHS+=:$T/development/scripts
283 ANDROID_GLOBAL_BUILD_PATHS+=:$T/prebuilts/devtools/tools
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800284
285 # add kernel specific binaries
286 if [ $(uname -s) = Linux ] ; then
287 ANDROID_GLOBAL_BUILD_PATHS+=:$T/prebuilts/misc/linux-x86/dtc
288 ANDROID_GLOBAL_BUILD_PATHS+=:$T/prebuilts/misc/linux-x86/libufdt
289 fi
290
291 # If prebuilts/android-emulator/<system>/ exists, prepend it to our PATH
292 # to ensure that the corresponding 'emulator' binaries are used.
293 case $(uname -s) in
294 Darwin)
295 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/darwin-x86_64
296 ;;
297 Linux)
298 ANDROID_EMULATOR_PREBUILTS=$T/prebuilts/android-emulator/linux-x86_64
299 ;;
300 *)
301 ANDROID_EMULATOR_PREBUILTS=
302 ;;
303 esac
304 if [ -n "$ANDROID_EMULATOR_PREBUILTS" -a -d "$ANDROID_EMULATOR_PREBUILTS" ]; then
305 ANDROID_GLOBAL_BUILD_PATHS+=:$ANDROID_EMULATOR_PREBUILTS
306 export ANDROID_EMULATOR_PREBUILTS
307 fi
308
309 # Finally, set PATH
Joe Onorato1cb9e152022-12-05 16:56:15 -0800310 export PATH=$ANDROID_GLOBAL_BUILD_PATHS:$PATH
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700311}
312
Matt Alexanderd9c56562020-05-21 10:49:17 +0000313function printconfig()
314{
Christopher Ferris55257d22017-03-23 11:08:58 -0700315 local T=$(gettop)
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800316 if [ ! "$T" ]; then
317 echo "Couldn't locate the top of the tree. Try setting TOP." >&2
318 return
319 fi
Joe Onorato0e68f702024-05-24 14:19:21 -0700320 _get_build_var_cached report_config
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700321}
322
Matt Alexanderd9c56562020-05-21 10:49:17 +0000323function set_stuff_for_environment()
324{
Joe Onorato7c3a77f2022-12-05 13:05:14 -0800325 set_lunch_paths
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800326 set_sequence_number
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700327}
328
Matt Alexanderd9c56562020-05-21 10:49:17 +0000329function set_sequence_number()
330{
Colin Cross88737132017-03-21 17:41:03 -0700331 export BUILD_ENV_SEQUENCE_NUMBER=13
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700332}
333
Makoto Onukida971062018-06-18 10:15:19 -0700334# Takes a command name, and check if it's in ENVSETUP_NO_COMPLETION or not.
335function should_add_completion() {
Jim Tanga881a252018-06-19 16:34:41 +0800336 local cmd="$(basename $1| sed 's/_completion//' |sed 's/\.\(.*\)*sh$//')"
Makoto Onukida971062018-06-18 10:15:19 -0700337 case :"$ENVSETUP_NO_COMPLETION": in
Jim Tanga881a252018-06-19 16:34:41 +0800338 *:"$cmd":*)
339 return 1
340 ;;
Makoto Onukida971062018-06-18 10:15:19 -0700341 esac
342 return 0
343}
344
Matt Alexanderd9c56562020-05-21 10:49:17 +0000345function addcompletions()
346{
Ben Taitelbaum8c2c9cf2020-09-22 16:45:05 -0700347 local f=
Kenny Root52aa81c2011-07-15 11:07:06 -0700348
Jim Tanga881a252018-06-19 16:34:41 +0800349 # Keep us from trying to run in something that's neither bash nor zsh.
350 if [ -z "$BASH_VERSION" -a -z "$ZSH_VERSION" ]; then
Kenny Root52aa81c2011-07-15 11:07:06 -0700351 return
352 fi
353
354 # Keep us from trying to run in bash that's too old.
Jim Tanga881a252018-06-19 16:34:41 +0800355 if [ -n "$BASH_VERSION" -a ${BASH_VERSINFO[0]} -lt 3 ]; then
Kenny Root52aa81c2011-07-15 11:07:06 -0700356 return
357 fi
358
Jim Tanga881a252018-06-19 16:34:41 +0800359 local completion_files=(
MÃ¥rten Kongstadcb5c73f2022-05-04 14:08:12 +0000360 packages/modules/adb/adb.bash
Jim Tanga881a252018-06-19 16:34:41 +0800361 system/core/fastboot/fastboot.bash
Jim Tangb3fda302018-12-22 10:24:55 +0800362 tools/asuite/asuite.sh
Chris Parsonsa2972972022-08-31 15:04:38 -0400363 prebuilts/bazel/common/bazel-complete.bash
Jim Tanga881a252018-06-19 16:34:41 +0800364 )
Makoto Onukida971062018-06-18 10:15:19 -0700365 # Completion can be disabled selectively to allow users to use non-standard completion.
366 # e.g.
367 # ENVSETUP_NO_COMPLETION=adb # -> disable adb completion
368 # ENVSETUP_NO_COMPLETION=adb:bit # -> disable adb and bit completion
Usta Shrestha1433fb32022-05-13 14:49:40 -0400369 local T=$(gettop)
Jim Tanga881a252018-06-19 16:34:41 +0800370 for f in ${completion_files[*]}; do
Usta Shrestha1433fb32022-05-13 14:49:40 -0400371 f="$T/$f"
MÃ¥rten Kongstadcb5c73f2022-05-04 14:08:12 +0000372 if [ ! -f "$f" ]; then
373 echo "Warning: completion file $f not found"
374 elif should_add_completion "$f"; then
Kenny Root52aa81c2011-07-15 11:07:06 -0700375 . $f
Elliott Hughesce18dd42018-04-03 13:49:48 -0700376 fi
377 done
Joe Onorato002a6c72016-10-20 16:39:49 -0700378
Anton Hanssonece9c482019-02-04 18:15:39 +0000379 if [ -z "$ZSH_VERSION" ]; then
380 # Doesn't work in zsh.
381 complete -o nospace -F _croot croot
Chris Parsonsa2972972022-08-31 15:04:38 -0400382 # TODO(b/244559459): Support b autocompletion for zsh
383 complete -F _bazel__complete -o nospace b
Anton Hanssonece9c482019-02-04 18:15:39 +0000384 fi
Jim Tanga881a252018-06-19 16:34:41 +0800385 complete -F _lunch lunch
Joe Onorato590ae9f2024-05-24 15:38:58 -0700386 complete -F _lunch_completion lunch2
Steven Moreland62054a42018-12-06 10:11:40 -0800387
Cole Faust24c36db2021-01-23 02:39:37 +0000388 complete -F _complete_android_module_names pathmod
dimitry73b84812018-12-11 18:06:00 +0100389 complete -F _complete_android_module_names gomod
Cole Faust24c36db2021-01-23 02:39:37 +0000390 complete -F _complete_android_module_names outmod
391 complete -F _complete_android_module_names installmod
dimitry73b84812018-12-11 18:06:00 +0100392 complete -F _complete_android_module_names m
Kenny Root52aa81c2011-07-15 11:07:06 -0700393}
394
Matt Alexanderd9c56562020-05-21 10:49:17 +0000395function add_lunch_combo()
396{
Dan Willemsen5436c7e2019-02-11 21:31:47 -0800397 if [ -n "$ZSH_VERSION" ]; then
398 echo -n "${funcfiletrace[1]}: "
399 else
400 echo -n "${BASH_SOURCE[1]}:${BASH_LINENO[0]}: "
401 fi
402 echo "add_lunch_combo is obsolete. Use COMMON_LUNCH_CHOICES in your AndroidProducts.mk instead."
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800403}
404
Matt Alexanderd9c56562020-05-21 10:49:17 +0000405function print_lunch_menu()
406{
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700407 local uname=$(uname)
Roland Levillain23c46cf2020-03-31 16:11:05 +0100408 local choices
Joe Onorato0e68f702024-05-24 14:19:21 -0700409 choices=$(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= _get_build_var_cached COMMON_LUNCH_CHOICES 2>/dev/null)
Roland Levillain23c46cf2020-03-31 16:11:05 +0100410 local ret=$?
411
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700412 echo
413 echo "You're building on" $uname
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700414 echo
Roland Levillain23c46cf2020-03-31 16:11:05 +0100415
Matt Alexanderd9c56562020-05-21 10:49:17 +0000416 if [ $ret -ne 0 ]
417 then
Roland Levillain23c46cf2020-03-31 16:11:05 +0100418 echo "Warning: Cannot display lunch menu."
419 echo
420 echo "Note: You can invoke lunch with an explicit target:"
421 echo
422 echo " usage: lunch [target]" >&2
423 echo
424 return
425 fi
426
Will Burr40401202022-02-07 12:12:01 +0000427 echo "Lunch menu .. Here are the common combinations:"
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800428
429 local i=1
430 local choice
Dan Willemsen91763e92019-10-03 15:13:12 -0700431 for choice in $(echo $choices)
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800432 do
433 echo " $i. $choice"
434 i=$(($i+1))
435 done
436
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700437 echo
438}
439
Matt Alexanderd9c56562020-05-21 10:49:17 +0000440function lunch()
441{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800442 local answer
443
Steven Moreland92793dc2020-02-25 18:30:18 -0800444 if [[ $# -gt 1 ]]; then
445 echo "usage: lunch [target]" >&2
446 return 1
447 fi
448
Will Burr40401202022-02-07 12:12:01 +0000449 local used_lunch_menu=0
450
Steven Moreland92793dc2020-02-25 18:30:18 -0800451 if [ "$1" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800452 answer=$1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700453 else
454 print_lunch_menu
Greg Kaiserbae4c572024-01-04 15:57:54 -0700455 echo "Which would you like? [aosp_cf_x86_64_phone-trunk_staging-eng]"
Greg Kaiser9a5a5262023-11-02 16:54:27 +0000456 echo -n "Pick from common choices above (e.g. 13) or specify your own (e.g. aosp_barbet-trunk_staging-eng): "
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800457 read answer
Will Burr40401202022-02-07 12:12:01 +0000458 used_lunch_menu=1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700459 fi
460
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800461 local selection=
462
Matt Alexanderd9c56562020-05-21 10:49:17 +0000463 if [ -z "$answer" ]
464 then
Greg Kaiserbae4c572024-01-04 15:57:54 -0700465 selection=aosp_cf_x86_64_phone-trunk_staging-eng
Matt Alexanderd9c56562020-05-21 10:49:17 +0000466 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
467 then
Joe Onorato0e68f702024-05-24 14:19:21 -0700468 local choices=($(TARGET_BUILD_APPS= TARGET_PRODUCT= TARGET_RELEASE= TARGET_BUILD_VARIANT= _get_build_var_cached COMMON_LUNCH_CHOICES 2>/dev/null))
Matt Alexanderd9c56562020-05-21 10:49:17 +0000469 if [ $answer -le ${#choices[@]} ]
470 then
Jim Tang0e3397b2018-10-03 18:25:50 +0800471 # array in zsh starts from 1 instead of 0.
Matt Alexanderd9c56562020-05-21 10:49:17 +0000472 if [ -n "$ZSH_VERSION" ]
473 then
Jim Tang0e3397b2018-10-03 18:25:50 +0800474 selection=${choices[$(($answer))]}
475 else
476 selection=${choices[$(($answer-1))]}
477 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800478 fi
Colin Cross88737132017-03-21 17:41:03 -0700479 else
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800480 selection=$answer
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700481 fi
482
Joe Onoratoda12daf2010-06-09 18:18:31 -0700483 export TARGET_BUILD_APPS=
484
Greg Kaiser5e2d3392023-10-27 14:15:48 -0600485 # This must be <product>-<release>-<variant>
486 local product release variant
487 # Split string on the '-' character.
488 IFS="-" read -r product release variant <<< "$selection"
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800489
Greg Kaiser5e2d3392023-10-27 14:15:48 -0600490 if [[ -z "$product" ]] || [[ -z "$release" ]] || [[ -z "$variant" ]]
Matt Alexanderd9c56562020-05-21 10:49:17 +0000491 then
Ying Wang08800fd2016-03-03 20:57:21 -0800492 echo
Colin Cross88737132017-03-21 17:41:03 -0700493 echo "Invalid lunch combo: $selection"
Greg Kaiser5e2d3392023-10-27 14:15:48 -0600494 echo "Valid combos must be of the form <product>-<release>-<variant>"
Jeff Browne33ba4c2011-07-11 22:11:46 -0700495 return 1
496 fi
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800497
Alexander Martinzec93d192024-12-05 13:01:00 +0100498 # Populate LINEAGE_BUILD
499 check_product $product $release
500
Joe Onorato590ae9f2024-05-24 15:38:58 -0700501 _lunch_meat $product $release $variant
502}
503
504function _lunch_meat()
505{
506 local product=$1
507 local release=$2
508 local variant=$3
509
Colin Cross88737132017-03-21 17:41:03 -0700510 TARGET_PRODUCT=$product \
Jeff Hamiltona02c7472023-05-08 03:13:29 +0000511 TARGET_RELEASE=$release \
Joe Onorato590ae9f2024-05-24 15:38:58 -0700512 TARGET_BUILD_VARIANT=$variant \
Colin Cross88737132017-03-21 17:41:03 -0700513 build_build_var_cache
Matt Alexanderd9c56562020-05-21 10:49:17 +0000514 if [ $? -ne 0 ]
515 then
Anton Hansson32fa7ee2021-06-14 17:09:58 +0100516 if [[ "$product" =~ .*_(eng|user|userdebug) ]]
517 then
518 echo "Did you mean -${product/*_/}? (dash instead of underscore)"
519 fi
Colin Cross88737132017-03-21 17:41:03 -0700520 return 1
521 fi
Joe Onorato0e68f702024-05-24 14:19:21 -0700522 export TARGET_PRODUCT=$(_get_build_var_cached TARGET_PRODUCT)
523 export TARGET_BUILD_VARIANT=$(_get_build_var_cached TARGET_BUILD_VARIANT)
Greg Kaiser5e2d3392023-10-27 14:15:48 -0600524 export TARGET_RELEASE=$release
525 # Note this is the string "release", not the value of the variable.
Jeff Browne33ba4c2011-07-11 22:11:46 -0700526 export TARGET_BUILD_TYPE=release
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700527
Michael Bestas7e6522b2021-05-06 16:44:13 +0300528 local no_kernel=$(_get_build_var_cached TARGET_NO_KERNEL)
529 if [[ "$no_kernel" == "true" ]]; then
530 unset INLINE_KERNEL_BUILDING
531 else
532 export INLINE_KERNEL_BUILDING=true
533 fi
534
Mark White2c807512023-10-25 17:27:07 +0000535 [[ -n "${ANDROID_QUIET_BUILD:-}" ]] || echo
536
Luca Stefani05ce70d2017-08-17 21:21:23 +0200537 fixup_common_out_dir
538
Mark White2c807512023-10-25 17:27:07 +0000539 set_stuff_for_environment
540 [[ -n "${ANDROID_QUIET_BUILD:-}" ]] || printconfig
541
Chirayu Desai635935f2024-03-08 02:10:56 +0530542 if [[ -z "${ANDROID_QUIET_BUILD}" && -z "${LINEAGE_BUILD}" ]]; then
Joe Onorato590ae9f2024-05-24 15:38:58 -0700543 local spam_for_lunch=$(gettop)/build/make/tools/envsetup/spam_for_lunch
544 if [[ -x $spam_for_lunch ]]; then
545 $spam_for_lunch
546 fi
Will Burr40401202022-02-07 12:12:01 +0000547 fi
548
Ying Wang08800fd2016-03-03 20:57:21 -0800549 destroy_build_var_cache
Kousik Kumar41dacd12021-05-11 18:38:38 -0400550
551 if [[ -n "${CHECK_MU_CONFIG:-}" ]]; then
552 check_mu_config
553 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700554}
555
Dan Willemsenaf2e1f82018-04-04 15:41:41 -0700556unset COMMON_LUNCH_CHOICES_CACHE
Jeff Davidson513d7a42010-08-02 10:00:44 -0700557# Tab completion for lunch.
Matt Alexanderd9c56562020-05-21 10:49:17 +0000558function _lunch()
559{
Jeff Davidson513d7a42010-08-02 10:00:44 -0700560 local cur prev opts
561 COMPREPLY=()
562 cur="${COMP_WORDS[COMP_CWORD]}"
563 prev="${COMP_WORDS[COMP_CWORD-1]}"
564
Dan Willemsenaf2e1f82018-04-04 15:41:41 -0700565 if [ -z "$COMMON_LUNCH_CHOICES_CACHE" ]; then
Joe Onorato0e68f702024-05-24 14:19:21 -0700566 COMMON_LUNCH_CHOICES_CACHE=$(TARGET_BUILD_APPS= _get_build_var_cached COMMON_LUNCH_CHOICES)
Dan Willemsenaf2e1f82018-04-04 15:41:41 -0700567 fi
568
569 COMPREPLY=( $(compgen -W "${COMMON_LUNCH_CHOICES_CACHE}" -- ${cur}) )
Jeff Davidson513d7a42010-08-02 10:00:44 -0700570 return 0
571}
Jeff Davidson513d7a42010-08-02 10:00:44 -0700572
Joe Onorato590ae9f2024-05-24 15:38:58 -0700573function _lunch_usage()
574{
575 (
576 echo "The lunch command selects the configuration to use for subsequent"
577 echo "Android builds."
578 echo
579 echo "Usage: lunch TARGET_PRODUCT [TARGET_RELEASE [TARGET_BUILD_VARIANT]]"
580 echo
581 echo " Choose the product, release and variant to use. If not"
582 echo " supplied, TARGET_RELEASE will be 'trunk_staging' and"
583 echo " TARGET_BUILD_VARIANT will be 'eng'"
584 echo
585 echo
586 echo "Usage: lunch TARGET_PRODUCT-TARGET_RELEASE-TARGET_BUILD_VARIANT"
587 echo
588 echo " Chose the product, release and variant to use. This"
589 echo " legacy format is maintained for compatibility."
590 echo
591 echo
592 echo "Note that the previous interactive menu and list of hard-coded"
593 echo "list of curated targets has been removed. If you would like the"
594 echo "list of products, release configs for a particular product, or"
595 echo "variants, run list_products, list_release_configs, list_variants"
596 echo "respectively."
597 echo
598 ) 1>&2
599}
600
601function lunch2()
602{
603 if [[ $# -eq 1 && $1 = "--help" ]]; then
604 _lunch_usage
605 return 0
606 fi
607 if [[ $# -eq 0 ]]; then
608 echo "No target specified. See lunch --help" 1>&2
609 return 1
610 fi
611 if [[ $# -gt 3 ]]; then
612 echo "Too many parameters given. See lunch --help" 1>&2
613 return 1
614 fi
615
616 local product release variant
617
618 # Handle the legacy format
619 local legacy=$(echo $1 | grep "-")
620 if [[ $# -eq 1 && -n $legacy ]]; then
621 IFS="-" read -r product release variant <<< "$1"
622 if [[ -z "$product" ]] || [[ -z "$release" ]] || [[ -z "$variant" ]]; then
623 echo "Invalid lunch combo: $1" 1>&2
624 echo "Valid combos must be of the form <product>-<release>-<variant> when using" 1>&2
625 echo "the legacy format. Run 'lunch --help' for usage." 1>&2
626 return 1
627 fi
628 fi
629
630 # Handle the new format.
631 if [[ -z $legacy ]]; then
632 product=$1
633 release=$2
634 if [[ -z $release ]]; then
635 release=trunk_staging
636 fi
637 variant=$3
638 if [[ -z $variant ]]; then
639 variant=eng
640 fi
641 fi
642
643 # Validate the selection and set all the environment stuff
644 _lunch_meat $product $release $variant
645}
646
647unset ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE
648unset ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT
649unset ANDROID_LUNCH_COMPLETION_RELEASE_CACHE
650# Tab completion for lunch.
651function _lunch_completion()
652{
653 # Available products
654 if [[ $COMP_CWORD -eq 1 ]] ; then
655 if [[ -z $ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE ]]; then
656 ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE=$(list_products)
657 fi
658 COMPREPLY=( $(compgen -W "${ANDROID_LUNCH_COMPLETION_PRODUCT_CACHE}" -- "${COMP_WORDS[COMP_CWORD]}") )
659 fi
660
661 # Available release configs
662 if [[ $COMP_CWORD -eq 2 ]] ; then
663 if [[ -z $ANDROID_LUNCH_COMPLETION_RELEASE_CACHE || $ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT != ${COMP_WORDS[1]} ]] ; then
664 ANDROID_LUNCH_COMPLETION_RELEASE_CACHE=$(list_releases ${COMP_WORDS[1]})
665 ANDROID_LUNCH_COMPLETION_CHOSEN_PRODUCT=${COMP_WORDS[1]}
666 fi
667 COMPREPLY=( $(compgen -W "${ANDROID_LUNCH_COMPLETION_RELEASE_CACHE}" -- "${COMP_WORDS[COMP_CWORD]}") )
668 fi
669
670 # Available variants
671 if [[ $COMP_CWORD -eq 3 ]] ; then
672 COMPREPLY=(user userdebug eng)
673 fi
674
675 return 0
676}
677
678
Joe Onoratoda12daf2010-06-09 18:18:31 -0700679# Configures the build to build unbundled apps.
Doug Zongker0d8179e2014-04-16 11:34:34 -0700680# Run tapas with one or more app names (from LOCAL_PACKAGE_NAME)
Matt Alexanderd9c56562020-05-21 10:49:17 +0000681function tapas()
682{
Jeff Gaston9fb05d82017-08-21 18:27:00 -0700683 local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)"
Elliott Hughesf71c05a2020-03-06 16:46:59 -0800684 local arch="$(echo $* | xargs -n 1 echo | \grep -E '^(arm|x86|arm64|x86_64)$' | xargs)"
Greg Kaiser83ed1592023-10-26 18:37:40 +0000685 # TODO(b/307975293): Expand tapas to take release arguments (and update hmm() usage).
686 local release="trunk_staging"
Doug Zongker0d8179e2014-04-16 11:34:34 -0700687 local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700688 local density="$(echo $* | xargs -n 1 echo | \grep -E '^(ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi)$' | xargs)"
Colin Cross7f49a672022-01-27 18:15:53 -0800689 local keys="$(echo $* | xargs -n 1 echo | \grep -E '^(devkeys)$' | xargs)"
690 local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|arm|x86|arm64|x86_64|ldpi|mdpi|tvdpi|hdpi|xhdpi|xxhdpi|xxxhdpi|alldpi|devkeys)$' | xargs)"
691
Joe Onoratoda12daf2010-06-09 18:18:31 -0700692
Jeff Gaston9fb05d82017-08-21 18:27:00 -0700693 if [ "$showHelp" != "" ]; then
694 $(gettop)/build/make/tapasHelp.sh
695 return
696 fi
697
Ying Wang67f02922012-08-22 10:25:20 -0700698 if [ $(echo $arch | wc -w) -gt 1 ]; then
699 echo "tapas: Error: Multiple build archs supplied: $arch"
700 return
701 fi
Greg Kaiser83ed1592023-10-26 18:37:40 +0000702 if [ $(echo $release | wc -w) -gt 1 ]; then
703 echo "tapas: Error: Multiple build releases supplied: $release"
704 return
705 fi
Joe Onoratoda12daf2010-06-09 18:18:31 -0700706 if [ $(echo $variant | wc -w) -gt 1 ]; then
707 echo "tapas: Error: Multiple build variants supplied: $variant"
708 return
709 fi
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700710 if [ $(echo $density | wc -w) -gt 1 ]; then
711 echo "tapas: Error: Multiple densities supplied: $density"
712 return
713 fi
Colin Cross7f49a672022-01-27 18:15:53 -0800714 if [ $(echo $keys | wc -w) -gt 1 ]; then
715 echo "tapas: Error: Multiple keys supplied: $keys"
716 return
717 fi
Ying Wang67f02922012-08-22 10:25:20 -0700718
Ying Wang0a76df52015-06-08 11:57:26 -0700719 local product=aosp_arm
Ying Wang67f02922012-08-22 10:25:20 -0700720 case $arch in
Matt Alexanderd9c56562020-05-21 10:49:17 +0000721 x86) product=aosp_x86;;
722 arm64) product=aosp_arm64;;
723 x86_64) product=aosp_x86_64;;
Ying Wang67f02922012-08-22 10:25:20 -0700724 esac
Colin Cross7f49a672022-01-27 18:15:53 -0800725 if [ -n "$keys" ]; then
726 product=${product/aosp_/aosp_${keys}_}
727 fi;
728
Joe Onoratoda12daf2010-06-09 18:18:31 -0700729 if [ -z "$variant" ]; then
730 variant=eng
731 fi
Ying Wangc048c9b2010-06-24 15:08:33 -0700732 if [ -z "$apps" ]; then
733 apps=all
734 fi
Justin Morey29d225c2014-11-04 13:35:51 -0600735 if [ -z "$density" ]; then
736 density=alldpi
737 fi
Joe Onoratoda12daf2010-06-09 18:18:31 -0700738
Ying Wang67f02922012-08-22 10:25:20 -0700739 export TARGET_PRODUCT=$product
Greg Kaiser83ed1592023-10-26 18:37:40 +0000740 export TARGET_RELEASE=$release
Joe Onoratoda12daf2010-06-09 18:18:31 -0700741 export TARGET_BUILD_VARIANT=$variant
Jeff Hamilton5069bd62014-09-04 21:28:00 -0700742 export TARGET_BUILD_DENSITY=$density
Joe Onoratoda12daf2010-06-09 18:18:31 -0700743 export TARGET_BUILD_TYPE=release
744 export TARGET_BUILD_APPS=$apps
745
Ying Wang08800fd2016-03-03 20:57:21 -0800746 build_build_var_cache
Joe Onoratoda12daf2010-06-09 18:18:31 -0700747 set_stuff_for_environment
748 printconfig
Ying Wang08800fd2016-03-03 20:57:21 -0800749 destroy_build_var_cache
Joe Onoratoda12daf2010-06-09 18:18:31 -0700750}
751
Martin Stjernholmf692c752021-04-12 00:01:10 +0100752# Configures the build to build unbundled Android modules (APEXes).
753# Run banchan with one or more module names (from apex{} modules).
754function banchan()
755{
756 local showHelp="$(echo $* | xargs -n 1 echo | \grep -E '^(help)$' | xargs)"
Ulya Trafimovich08c381b2023-06-12 15:33:09 +0100757 local product="$(echo $* | xargs -n 1 echo | \grep -E '^(.*_)?(arm|x86|arm64|riscv64|x86_64|arm64only|x86_64only)$' | xargs)"
Greg Kaiserd35095e2023-10-27 16:04:30 -0600758 # TODO: Expand banchan to take release arguments (and update hmm() usage).
759 local release="trunk_staging"
Martin Stjernholmf692c752021-04-12 00:01:10 +0100760 local variant="$(echo $* | xargs -n 1 echo | \grep -E '^(user|userdebug|eng)$' | xargs)"
Ulya Trafimovich08c381b2023-06-12 15:33:09 +0100761 local apps="$(echo $* | xargs -n 1 echo | \grep -E -v '^(user|userdebug|eng|(.*_)?(arm|x86|arm64|riscv64|x86_64))$' | xargs)"
Martin Stjernholmf692c752021-04-12 00:01:10 +0100762
763 if [ "$showHelp" != "" ]; then
764 $(gettop)/build/make/banchanHelp.sh
765 return
766 fi
767
Martin Stjernholm2b8d9232021-04-16 20:45:03 +0100768 if [ -z "$product" ]; then
Anton Hansson0328e322022-05-24 15:47:40 +0000769 product=arm64
Martin Stjernholm2b8d9232021-04-16 20:45:03 +0100770 elif [ $(echo $product | wc -w) -gt 1 ]; then
771 echo "banchan: Error: Multiple build archs or products supplied: $products"
Martin Stjernholmf692c752021-04-12 00:01:10 +0100772 return
773 fi
Greg Kaiserd35095e2023-10-27 16:04:30 -0600774 if [ $(echo $release | wc -w) -gt 1 ]; then
775 echo "banchan: Error: Multiple build releases supplied: $release"
776 return
777 fi
Martin Stjernholmf692c752021-04-12 00:01:10 +0100778 if [ $(echo $variant | wc -w) -gt 1 ]; then
779 echo "banchan: Error: Multiple build variants supplied: $variant"
780 return
781 fi
782 if [ -z "$apps" ]; then
783 echo "banchan: Error: No modules supplied"
784 return
785 fi
786
Martin Stjernholm2b8d9232021-04-16 20:45:03 +0100787 case $product in
788 arm) product=module_arm;;
Martin Stjernholmf692c752021-04-12 00:01:10 +0100789 x86) product=module_x86;;
790 arm64) product=module_arm64;;
Ulya Trafimovich08c381b2023-06-12 15:33:09 +0100791 riscv64) product=module_riscv64;;
Martin Stjernholmf692c752021-04-12 00:01:10 +0100792 x86_64) product=module_x86_64;;
Anton Hansson90ac61c2022-09-06 14:36:00 +0000793 arm64only) product=module_arm64only;;
794 x86_64only) product=module_x86_64only;;
Martin Stjernholmf692c752021-04-12 00:01:10 +0100795 esac
796 if [ -z "$variant" ]; then
797 variant=eng
798 fi
799
800 export TARGET_PRODUCT=$product
Greg Kaiserd35095e2023-10-27 16:04:30 -0600801 export TARGET_RELEASE=$release
Martin Stjernholmf692c752021-04-12 00:01:10 +0100802 export TARGET_BUILD_VARIANT=$variant
803 export TARGET_BUILD_DENSITY=alldpi
804 export TARGET_BUILD_TYPE=release
805
806 # This setup currently uses TARGET_BUILD_APPS just like tapas, but the use
807 # case is different and it may diverge in the future.
808 export TARGET_BUILD_APPS=$apps
809
810 build_build_var_cache
811 set_stuff_for_environment
812 printconfig
813 destroy_build_var_cache
814}
815
Matt Alexanderd9c56562020-05-21 10:49:17 +0000816function croot()
817{
Christopher Ferris55257d22017-03-23 11:08:58 -0700818 local T=$(gettop)
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700819 if [ "$T" ]; then
Marie Janssen32ec50a2016-04-21 16:53:39 -0700820 if [ "$1" ]; then
821 \cd $(gettop)/$1
822 else
823 \cd $(gettop)
824 fi
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700825 else
826 echo "Couldn't locate the top of the tree. Try setting TOP."
827 fi
828}
829
Matt Alexanderd9c56562020-05-21 10:49:17 +0000830function _croot()
831{
Anton Hanssonece9c482019-02-04 18:15:39 +0000832 local T=$(gettop)
833 if [ "$T" ]; then
834 local cur="${COMP_WORDS[COMP_CWORD]}"
835 k=0
836 for c in $(compgen -d ${T}/${cur}); do
837 COMPREPLY[k++]=${c#${T}/}/
838 done
839 fi
840}
841
Matt Alexanderd9c56562020-05-21 10:49:17 +0000842function cproj()
843{
Colin Cross6cdc5d22017-10-20 11:37:33 -0700844 local TOPFILE=build/make/core/envsetup.mk
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700845 local HERE=$PWD
Christopher Ferris55257d22017-03-23 11:08:58 -0700846 local T=
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700847 while [ \( ! \( -f $TOPFILE \) \) -a \( $PWD != "/" \) ]; do
848 T=$PWD
849 if [ -f "$T/Android.mk" ]; then
Ying Wang9cd17642012-12-13 10:52:07 -0800850 \cd $T
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700851 return
852 fi
Ying Wang9cd17642012-12-13 10:52:07 -0800853 \cd ..
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700854 done
Ying Wang9cd17642012-12-13 10:52:07 -0800855 \cd $HERE
Joe Onorato2a5d4d82009-07-30 10:23:21 -0700856 echo "can't find Android.mk"
857}
858
Elliott Hughes86e99172024-03-21 16:55:08 +0000859# Ensure that we're always using the adb in the tree. This works around the fact
860# that bash caches $PATH lookups, so if you use adb before lunching/building the
861# one in your tree, you'll continue to get /usr/bin/adb or whatever even after
862# you have the one from your current tree on your path. Historically this would
863# cause confusion because glinux had adb in /usr/bin/ by default, though that
864# doesn't appear to be the case on my rodete hosts; it is however still the case
865# that my Mac has /usr/local/bin/adb installed by default and on the default
866# path.
Shaju Mathew21439002023-07-10 00:53:22 +0000867function adb() {
Elliott Hughes57c47b72024-03-22 15:46:59 +0000868 # We need `command which` because zsh has a built-in `which` that's more
869 # like `type`.
870 local ADB=$(command which adb)
Elliott Hughes7e7ff752024-03-20 17:23:40 -0700871 if [ -z "$ADB" ]; then
872 echo "Command adb not found; try lunch (and building) first?"
873 return 1
874 fi
Zhuoyao Zhang60dd9dd2024-04-19 00:07:59 +0000875 run_tool_with_logging "ADB" $ADB "${@}"
Shaju Mathew21439002023-07-10 00:53:22 +0000876}
877
Zhuoyao Zhangf02aadf2024-06-10 18:28:25 +0000878function fastboot() {
879 local FASTBOOT=$(command which fastboot)
880 if [ -z "$FASTBOOT" ]; then
881 echo "Command fastboot not found; try lunch (and building) first?"
882 return 1
883 fi
884 # Support tool event logging for fastboot command.
885 run_tool_with_logging "FASTBOOT" $FASTBOOT "${@}"
886}
887
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800888# communicate with a running device or emulator, set up necessary state,
889# and run the hat command.
Matt Alexanderd9c56562020-05-21 10:49:17 +0000890function runhat()
891{
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800892 # process standard adb options
893 local adbTarget=""
Matt Alexanderd9c56562020-05-21 10:49:17 +0000894 if [ "$1" = "-d" -o "$1" = "-e" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800895 adbTarget=$1
896 shift 1
Matt Alexanderd9c56562020-05-21 10:49:17 +0000897 elif [ "$1" = "-s" ]; then
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800898 adbTarget="$1 $2"
899 shift 2
900 fi
901 local adbOptions=${adbTarget}
Matt Alexanderd9c56562020-05-21 10:49:17 +0000902 #echo adbOptions = ${adbOptions}
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800903
904 # runhat options
905 local targetPid=$1
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700906
Matt Alexanderd9c56562020-05-21 10:49:17 +0000907 if [ "$targetPid" = "" ]; then
Andy McFaddenb6289852010-07-12 08:00:19 -0700908 echo "Usage: runhat [ -d | -e | -s serial ] target-pid"
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700909 return
910 fi
911
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -0800912 # confirm hat is available
913 if [ -z $(which hat) ]; then
914 echo "hat is not available in this configuration."
915 return
916 fi
917
Andy McFaddenb6289852010-07-12 08:00:19 -0700918 # issue "am" command to cause the hprof dump
Nick Kralevich9948b1e2014-07-18 15:45:38 -0700919 local devFile=/data/local/tmp/hprof-$targetPid
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700920 echo "Poking $targetPid and waiting for data..."
Dianne Hackborn6b9549f2012-09-26 15:00:59 -0700921 echo "Storing data at $devFile"
Andy McFaddenb6289852010-07-12 08:00:19 -0700922 adb ${adbOptions} shell am dumpheap $targetPid $devFile
The Android Open Source Project88b60792009-03-03 19:28:42 -0800923 echo "Press enter when logcat shows \"hprof: heap dump completed\""
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700924 echo -n "> "
925 read
926
The Android Open Source Project88b60792009-03-03 19:28:42 -0800927 local localFile=/tmp/$$-hprof
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700928
The Android Open Source Project88b60792009-03-03 19:28:42 -0800929 echo "Retrieving file $devFile..."
930 adb ${adbOptions} pull $devFile $localFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700931
The Android Open Source Project88b60792009-03-03 19:28:42 -0800932 adb ${adbOptions} shell rm $devFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700933
The Android Open Source Project88b60792009-03-03 19:28:42 -0800934 echo "Running hat on $localFile"
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700935 echo "View the output by pointing your browser at http://localhost:7000/"
936 echo ""
Dianne Hackborn6e4e1bb2011-11-10 15:19:51 -0800937 hat -JXmx512m $localFile
The Android Open Source Projectb6c1cf62008-10-21 07:00:00 -0700938}
939
The Android Open Source Project88b60792009-03-03 19:28:42 -0800940function godir () {
941 if [[ -z "$1" ]]; then
942 echo "Usage: godir <regex>"
943 return
944 fi
Christopher Ferris55257d22017-03-23 11:08:58 -0700945 local T=$(gettop)
946 local FILELIST
Matt Alexanderd9c56562020-05-21 10:49:17 +0000947 if [ ! "$OUT_DIR" = "" ]; then
Brian Carlstromf2257422015-09-30 20:28:54 -0700948 mkdir -p $OUT_DIR
949 FILELIST=$OUT_DIR/filelist
950 else
951 FILELIST=$T/filelist
952 fi
953 if [[ ! -f $FILELIST ]]; then
The Android Open Source Project88b60792009-03-03 19:28:42 -0800954 echo -n "Creating index..."
Brian Carlstromf2257422015-09-30 20:28:54 -0700955 (\cd $T; find . -wholename ./out -prune -o -wholename ./.repo -prune -o -type f > $FILELIST)
The Android Open Source Project88b60792009-03-03 19:28:42 -0800956 echo " Done"
957 echo ""
958 fi
959 local lines
Brian Carlstromf2257422015-09-30 20:28:54 -0700960 lines=($(\grep "$1" $FILELIST | sed -e 's/\/[^/]*$//' | sort | uniq))
Matt Alexanderd9c56562020-05-21 10:49:17 +0000961 if [[ ${#lines[@]} = 0 ]]; then
The Android Open Source Project88b60792009-03-03 19:28:42 -0800962 echo "Not found"
963 return
964 fi
965 local pathname
966 local choice
967 if [[ ${#lines[@]} > 1 ]]; then
968 while [[ -z "$pathname" ]]; do
969 local index=1
970 local line
971 for line in ${lines[@]}; do
972 printf "%6s %s\n" "[$index]" $line
Doug Zongker29034982011-04-22 08:16:56 -0700973 index=$(($index + 1))
The Android Open Source Project88b60792009-03-03 19:28:42 -0800974 done
975 echo
976 echo -n "Select one: "
977 unset choice
978 read choice
979 if [[ $choice -gt ${#lines[@]} || $choice -lt 1 ]]; then
980 echo "Invalid choice"
981 continue
982 fi
Guillaume Chelfice000fd2019-10-03 12:02:46 +0200983 pathname=${lines[@]:$(($choice-1)):1}
The Android Open Source Project88b60792009-03-03 19:28:42 -0800984 done
985 else
Guillaume Chelfice000fd2019-10-03 12:02:46 +0200986 pathname=${lines[@]:0:1}
The Android Open Source Project88b60792009-03-03 19:28:42 -0800987 fi
Ying Wang9cd17642012-12-13 10:52:07 -0800988 \cd $T/$pathname
The Android Open Source Project88b60792009-03-03 19:28:42 -0800989}
990
Rett Berg78d1c932019-01-24 14:34:23 -0800991# Go to a specific module in the android tree, as cached in module-info.json. If any build change
992# is made, and it should be reflected in the output, you should run 'refreshmod' first.
Joe Onorato6b543832024-05-23 12:26:50 -0700993# Note: This function is in envsetup because changing the directory needs to happen in the current
994# shell. All other functions that use module-info.json should be in build/soong/bin.
Rett Berg78d1c932019-01-24 14:34:23 -0800995function gomod() {
996 if [[ $# -ne 1 ]]; then
997 echo "usage: gomod <module>" >&2
998 return 1
999 fi
1000
1001 local path="$(pathmod $@)"
1002 if [ -z "$path" ]; then
1003 return 1
1004 fi
1005 cd $path
1006}
1007
dimitry73b84812018-12-11 18:06:00 +01001008function _complete_android_module_names() {
Steven Moreland62054a42018-12-06 10:11:40 -08001009 local word=${COMP_WORDS[COMP_CWORD]}
Cole Faust5d825b72022-10-26 18:16:44 -07001010 COMPREPLY=( $(allmod | grep -E "^$word") )
Steven Moreland62054a42018-12-06 10:11:40 -08001011}
1012
Matt Alexanderd9c56562020-05-21 10:49:17 +00001013function get_make_command()
1014{
Dan Willemsend41ec5a2017-07-12 16:14:50 -07001015 # If we're in the top of an Android tree, use soong_ui.bash instead of make
1016 if [ -f build/soong/soong_ui.bash ]; then
Dan Willemsene9842242017-07-28 13:00:13 -07001017 # Always use the real make if -C is passed in
1018 for arg in "$@"; do
1019 if [[ $arg == -C* ]]; then
1020 echo command make
1021 return
1022 fi
1023 done
Dan Willemsend41ec5a2017-07-12 16:14:50 -07001024 echo build/soong/soong_ui.bash --make-mode
1025 else
1026 echo command make
1027 fi
Ying Wanged21d4c2014-08-24 22:14:19 -07001028}
1029
Matt Alexanderd9c56562020-05-21 10:49:17 +00001030function make()
1031{
Dan Willemsene9842242017-07-28 13:00:13 -07001032 _wrap_build $(get_make_command "$@") "$@"
Dan Willemsend41ec5a2017-07-12 16:14:50 -07001033}
1034
Jim Tanga881a252018-06-19 16:34:41 +08001035# Zsh needs bashcompinit called to support bash-style completion.
Patrik Fimmldf248e62018-10-15 18:15:12 +02001036function enable_zsh_completion() {
1037 # Don't override user's options if bash-style completion is already enabled.
1038 if ! declare -f complete >/dev/null; then
1039 autoload -U compinit && compinit
1040 autoload -U bashcompinit && bashcompinit
1041 fi
Jim Tanga881a252018-06-19 16:34:41 +08001042}
1043
1044function validate_current_shell() {
1045 local current_sh="$(ps -o command -p $$)"
1046 case "$current_sh" in
Raphael Moll70a86b02011-06-20 16:03:14 -07001047 *bash*)
Jim Tanga881a252018-06-19 16:34:41 +08001048 function check_type() { type -t "$1"; }
Raphael Moll70a86b02011-06-20 16:03:14 -07001049 ;;
Jim Tanga881a252018-06-19 16:34:41 +08001050 *zsh*)
1051 function check_type() { type "$1"; }
Matt Alexanderd9c56562020-05-21 10:49:17 +00001052 enable_zsh_completion ;;
Raphael Moll70a86b02011-06-20 16:03:14 -07001053 *)
Jim Tanga881a252018-06-19 16:34:41 +08001054 echo -e "WARNING: Only bash and zsh are supported.\nUse of other shell would lead to erroneous results."
Raphael Moll70a86b02011-06-20 16:03:14 -07001055 ;;
1056 esac
Jim Tanga881a252018-06-19 16:34:41 +08001057}
The Android Open Source Projectdcc08f02008-12-17 18:03:49 -08001058
1059# Execute the contents of any vendorsetup.sh files we can find.
Dan Willemsend855a722019-02-12 15:52:36 -08001060# Unless we find an allowed-vendorsetup_sh-files file, in which case we'll only
1061# load those.
1062#
1063# This allows loading only approved vendorsetup.sh files
Jim Tanga881a252018-06-19 16:34:41 +08001064function source_vendorsetup() {
Jim Tangc4dba1d2019-07-25 16:54:27 +08001065 unset VENDOR_PYTHONPATH
Patrice Arrudaaa4b8242020-10-12 21:29:14 +00001066 local T="$(gettop)"
Dan Willemsend855a722019-02-12 15:52:36 -08001067 allowed=
Patrice Arrudaaa4b8242020-10-12 21:29:14 +00001068 for f in $(cd "$T" && find -L device vendor product -maxdepth 4 -name 'allowed-vendorsetup_sh-files' 2>/dev/null | sort); do
Dan Willemsend855a722019-02-12 15:52:36 -08001069 if [ -n "$allowed" ]; then
1070 echo "More than one 'allowed_vendorsetup_sh-files' file found, not including any vendorsetup.sh files:"
1071 echo " $allowed"
1072 echo " $f"
1073 return
1074 fi
Patrice Arrudaaa4b8242020-10-12 21:29:14 +00001075 allowed="$T/$f"
Dan Willemsend855a722019-02-12 15:52:36 -08001076 done
1077
1078 allowed_files=
1079 [ -n "$allowed" ] && allowed_files=$(cat "$allowed")
Jim Tanga881a252018-06-19 16:34:41 +08001080 for dir in device vendor product; do
Patrice Arrudaaa4b8242020-10-12 21:29:14 +00001081 for f in $(cd "$T" && test -d $dir && \
Jim Tanga881a252018-06-19 16:34:41 +08001082 find -L $dir -maxdepth 4 -name 'vendorsetup.sh' 2>/dev/null | sort); do
Dan Willemsend855a722019-02-12 15:52:36 -08001083
1084 if [[ -z "$allowed" || "$allowed_files" =~ $f ]]; then
Patrice Arrudaaa4b8242020-10-12 21:29:14 +00001085 echo "including $f"; . "$T/$f"
Dan Willemsend855a722019-02-12 15:52:36 -08001086 else
1087 echo "ignoring $f, not in $allowed"
1088 fi
Jim Tanga881a252018-06-19 16:34:41 +08001089 done
1090 done
Kousik Kumarec5416c2023-09-14 17:11:45 +00001091
1092 if [[ "${PWD}" == /google/cog/* ]]; then
1093 f="build/make/cogsetup.sh"
1094 echo "including $f"; . "$T/$f"
1095 fi
Jim Tanga881a252018-06-19 16:34:41 +08001096}
Kenny Root52aa81c2011-07-15 11:07:06 -07001097
Dan Albertbab814f2020-08-26 15:34:53 -07001098function showcommands() {
1099 local T=$(gettop)
1100 if [[ -z "$TARGET_PRODUCT" ]]; then
1101 >&2 echo "TARGET_PRODUCT not set. Run lunch."
1102 return
1103 fi
1104 case $(uname -s) in
1105 Darwin)
1106 PREBUILT_NAME=darwin-x86
1107 ;;
1108 Linux)
1109 PREBUILT_NAME=linux-x86
1110 ;;
1111 *)
1112 >&2 echo Unknown host $(uname -s)
1113 return
1114 ;;
1115 esac
Joe Onorato0e68f702024-05-24 14:19:21 -07001116 OUT_DIR="$(_get_abs_build_var_cached OUT_DIR)"
Dan Albertbab814f2020-08-26 15:34:53 -07001117 if [[ "$1" == "--regenerate" ]]; then
1118 shift 1
1119 NINJA_ARGS="-t commands $@" m
1120 else
1121 (cd $T && prebuilts/build-tools/$PREBUILT_NAME/bin/ninja \
1122 -f $OUT_DIR/combined-${TARGET_PRODUCT}.ninja \
1123 -t commands "$@")
1124 fi
1125}
1126
Joe Onorato1b9ab292024-05-17 12:16:43 -07001127# These functions used to be here but are now standalone scripts
1128# in build/soong/bin. Unset these for the time being so the real
1129# script is picked up.
Joe Onorato23124752024-05-14 15:06:48 -07001130# TODO: Remove this some time after a suitable delay (maybe 2025?)
Joe Onorato6b543832024-05-23 12:26:50 -07001131unset allmod
Joe Onorato23124752024-05-14 15:06:48 -07001132unset aninja
Joe Onorato1b9ab292024-05-17 12:16:43 -07001133unset cgrep
Joe Onorato3acb3082024-05-24 14:14:46 -07001134unset core
1135unset coredump_enable
1136unset coredump_setup
Joe Onorato6b543832024-05-23 12:26:50 -07001137unset dirmods
Joe Onorato0e68f702024-05-24 14:19:21 -07001138unset get_build_var
1139unset get_abs_build_var
Joe Onorato3acb3082024-05-24 14:14:46 -07001140unset getlastscreenshot
1141unset getprebuilt
1142unset getscreenshotpath
1143unset getsdcardpath
1144unset gettargetarch
Joe Onorato1b9ab292024-05-17 12:16:43 -07001145unset ggrep
1146unset gogrep
Joe Onorato3acb3082024-05-24 14:14:46 -07001147unset hmm
Joe Onorato6b543832024-05-23 12:26:50 -07001148unset installmod
Joe Onorato3acb3082024-05-24 14:14:46 -07001149unset is64bit
1150unset isviewserverstarted
Joe Onorato1b9ab292024-05-17 12:16:43 -07001151unset jgrep
1152unset jsongrep
Joe Onorato3acb3082024-05-24 14:14:46 -07001153unset key_back
1154unset key_home
1155unset key_menu
Joe Onorato1b9ab292024-05-17 12:16:43 -07001156unset ktgrep
Joe Onorato6b543832024-05-23 12:26:50 -07001157unset m
Joe Onorato1b9ab292024-05-17 12:16:43 -07001158unset mangrep
1159unset mgrep
Joe Onorato6b543832024-05-23 12:26:50 -07001160unset mm
1161unset mma
1162unset mmm
1163unset mmma
1164unset outmod
1165unset overrideflags
Joe Onorato1b9ab292024-05-17 12:16:43 -07001166unset owngrep
Joe Onorato6b543832024-05-23 12:26:50 -07001167unset pathmod
Joe Onoratoff277c52024-05-23 12:52:07 -07001168unset pez
Joe Onorato1b9ab292024-05-17 12:16:43 -07001169unset pygrep
Joe Onorato6b543832024-05-23 12:26:50 -07001170unset qpid
Joe Onorato1b9ab292024-05-17 12:16:43 -07001171unset rcgrep
Joe Onorato6b543832024-05-23 12:26:50 -07001172unset refreshmod
Joe Onorato1b9ab292024-05-17 12:16:43 -07001173unset resgrep
1174unset rsgrep
Zhuoyao Zhang1698d492024-05-21 23:55:27 +00001175unset run_tool_with_logging
Joe Onorato1b9ab292024-05-17 12:16:43 -07001176unset sepgrep
1177unset sgrep
Joe Onorato3acb3082024-05-24 14:14:46 -07001178unset startviewserver
1179unset stopviewserver
1180unset systemstack
Joe Onorato6b543832024-05-23 12:26:50 -07001181unset syswrite
Joe Onorato1b9ab292024-05-17 12:16:43 -07001182unset tomlgrep
1183unset treegrep
Cole Faust45844ab2022-08-30 13:59:07 -07001184
Colin Cross71319722023-10-24 10:58:46 -07001185
Jim Tanga881a252018-06-19 16:34:41 +08001186validate_current_shell
Joe Onorato7c3a77f2022-12-05 13:05:14 -08001187set_global_paths
Jim Tanga881a252018-06-19 16:34:41 +08001188source_vendorsetup
Kenny Root52aa81c2011-07-15 11:07:06 -07001189addcompletions
Joe Onorato7c3a77f2022-12-05 13:05:14 -08001190
Chirayu Desaif17e3102013-03-19 17:50:37 +05301191export ANDROID_BUILD_TOP=$(gettop)
Michael Bestas3a8fb882016-08-26 00:37:02 +03001192
1193. $ANDROID_BUILD_TOP/vendor/lineage/build/envsetup.sh
Alexander Martinze2761e72022-04-07 18:02:53 +02001194. $ANDROID_BUILD_TOP/vendor/shiftos/build/envsetup.sh