From 5e2d3399d3b07bf83b596e6633c157e23f97124c Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Fri, 27 Oct 2023 14:15:48 -0600 Subject: [PATCH] Require lunch targets to be product-release-variant Instead of supporting both product-variant and product-release-variant, we now require the release type to be given to use. Bug: 307946156 Test: 'lunch aosp_mokey-userdebug' (now) fails; 'lunch aosp_mokey-trunk_staging-userdebug' (still) works Change-Id: Ica87b3969f950a57232615f33bfe5f4012a743d6 --- envsetup.sh | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/envsetup.sh b/envsetup.sh index f4cba1d9b2..e5d4eb73ce 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -56,7 +56,7 @@ cat <- +- lunch: lunch -- Selects as the product to build, and as the variant to build, and stores those selections in the environment to be read by subsequent invocations of 'm' etc. @@ -486,7 +486,7 @@ function addcompletions() function multitree_lunch_help() { - echo "usage: lunch PRODUCT-VARIANT" 1>&2 + echo "usage: lunch PRODUCT-RELEASE-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 @@ -804,26 +804,16 @@ function lunch() export TARGET_BUILD_APPS= - # Support either - or -- - local product release_and_variant release variant - product=${selection%%-*} # Trim everything after first dash - release_and_variant=${selection#*-} # Trim everything up to first dash - if [ "$release_and_variant" != "$selection" ]; then - local first=${release_and_variant%%-*} # Trim everything after first dash - if [ "$first" != "$release_and_variant" ]; then - # There is a 2nd dash, split into release-variant - release=$first # Everything up to the dash - variant=${release_and_variant#*-} # Trim everything up to dash - else - # There is not a 2nd dash, default to variant as the second param - variant=$first - fi - fi + # This must be -- + local product release variant + # Split string on the '-' character. + IFS="-" read -r product release variant <<< "$selection" - if [ -z "$product" ] + if [[ -z "$product" ]] || [[ -z "$release" ]] || [[ -z "$variant" ]] then echo echo "Invalid lunch combo: $selection" + echo "Valid combos must be of the form --" return 1 fi @@ -841,11 +831,8 @@ function lunch() fi export TARGET_PRODUCT=$(get_build_var TARGET_PRODUCT) export TARGET_BUILD_VARIANT=$(get_build_var TARGET_BUILD_VARIANT) - if [ -n "$release" ]; then - export TARGET_RELEASE=$release - else - unset TARGET_RELEASE - fi + export TARGET_RELEASE=$release + # Note this is the string "release", not the value of the variable. export TARGET_BUILD_TYPE=release if [ $used_lunch_menu -eq 1 ]; then