Implement multitree lunch

Test: (cd build/make/orchestrator/core ; ./test_lunch.py)
Change-Id: I4ba36a79abd13c42b986e3ba0d6d599c1cc73cb0
This commit is contained in:
Joe Onorato
2022-04-08 11:06:16 -07:00
parent d3a9957616
commit 824608c33d
23 changed files with 593 additions and 0 deletions

View File

@@ -425,6 +425,61 @@ function addcompletions()
complete -F _complete_android_module_names m
}
function multitree_lunch_help()
{
echo "usage: lunch PRODUCT-VARIANT" 1>&2
echo " Set up android build environment based on a product short name and variant" 1>&2
echo 1>&2
echo "lunch COMBO_FILE VARIANT" 1>&2
echo " Set up android build environment based on a specific lunch combo file" 1>&2
echo " and variant." 1>&2
echo 1>&2
echo "lunch --print [CONFIG]" 1>&2
echo " Print the contents of a configuration. If CONFIG is supplied, that config" 1>&2
echo " will be flattened and printed. If CONFIG is not supplied, the currently" 1>&2
echo " selected config will be printed. Returns 0 on success or nonzero on error." 1>&2
echo 1>&2
echo "lunch --list" 1>&2
echo " List all possible combo files available in the current tree" 1>&2
echo 1>&2
echo "lunch --help" 1>&2
echo "lunch -h" 1>&2
echo " Prints this message." 1>&2
}
function multitree_lunch()
{
local code
local results
if $(echo "$1" | grep -q '^-') ; then
# Calls starting with a -- argument are passed directly and the function
# returns with the lunch.py exit code.
build/make/orchestrator/core/lunch.py "$@"
code=$?
if [[ $code -eq 2 ]] ; then
echo 1>&2
multitree_lunch_help
return $code
elif [[ $code -ne 0 ]] ; then
return $code
fi
else
# All other calls go through the --lunch variant of lunch.py
results=($(build/make/orchestrator/core/lunch.py --lunch "$@"))
code=$?
if [[ $code -eq 2 ]] ; then
echo 1>&2
multitree_lunch_help
return $code
elif [[ $code -ne 0 ]] ; then
return $code
fi
export TARGET_BUILD_COMBO=${results[0]}
export TARGET_BUILD_VARIANT=${results[1]}
fi
}
function choosetype()
{
echo "Build type choices are:"