aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Willemsen2018-04-04 17:41:41 -0500
committerPraneeth Bajjuri2019-01-16 10:01:15 -0600
commit938c63a0da4802ab89882edbfad45570df908a27 (patch)
tree80750580803613d60a00b31eea49905d0cac5678
parentd412eca840efb10d8e17d5ef5bfcc2100d6c5ea5 (diff)
downloadplatform-build-d-pie-core-release.tar.gz
platform-build-d-pie-core-release.tar.xz
platform-build-d-pie-core-release.zip
Start moving add_lunch_combo to Maked-pie-core-release
Start deprecating add_lunch_combo, preferring a list of common choices in each AndroidProducts.mk file. This list will be validated so that we don't have typos: https://android-review.git.corp.google.com/c/device/generic/car/+/619533 Or targets that no longer exist. Bug: 77599627 Test: lunch Test: lunch 34 Test: lunch aosp_x86_64-eng Test: lunch aosp_<tab> Change-Id: Ie0ddaa94cbd6cee26584f56f1706a8ec1333f87e [praneeth@ti.com: cherry-pick to d-pie-core-release] Signed-off-by: Praneeth Bajjuri <praneeth@ti.com>
-rw-r--r--core/product.mk47
-rw-r--r--core/product_config.mk15
-rw-r--r--envsetup.sh22
-rw-r--r--target/product/AndroidProducts.mk8
4 files changed, 70 insertions, 22 deletions
diff --git a/core/product.mk b/core/product.mk
index 899b806cc..4459d8ade 100644
--- a/core/product.mk
+++ b/core/product.mk
@@ -42,20 +42,67 @@ $(foreach d, device vendor product,$(call _search-android-products-files-in-dir,
42endef 42endef
43 43
44# 44#
45# For entries returned by get-product-makefiles, decode an entry to a short
46# product name. These either may be in the form of <name>:path/to/file.mk or
47# path/to/<name>.mk
48# $(1): The entry to decode
49#
50# Returns two words:
51# <name> <file>
52#
53define _decode-product-name
54$(strip \
55 $(eval _cpm_words := $(subst :,$(space),$(1))) \
56 $(if $(word 2,$(_cpm_words)), \
57 $(wordlist 1,2,$(_cpm_words)), \
58 $(basename $(notdir $(1))) $(1)))
59endef
60
61#
62# Validates the new common lunch choices -- ensures that they're in an
63# appropriate form, and are paired with definitions of their products.
64# $(1): The new list of COMMON_LUNCH_CHOICES
65# $(2): The new list of PRODUCT_MAKEFILES
66#
67define _validate-common-lunch-choices
68$(strip $(foreach choice,$(1),\
69 $(eval _parts := $(subst -,$(space),$(choice))) \
70 $(if $(call math_lt,$(words $(_parts)),2), \
71 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
72 $(if $(call math_gt_or_eq,$(words $(_parts)),4), \
73 $(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
74 $(if $(filter-out eng userdebug user,$(word 2,$(_parts))), \
75 $(error $(LOCAL_DIR): $(choice): Invalid variant: $(word 2,$(_parts)))) \
76 $(if $(filter-out $(foreach p,$(2),$(call _decode-product-name,$(p))),$(word 1,$(_parts))), \
77 $(error $(LOCAL_DIR): $(word 1,$(_parts)): Product not defined in this file)) \
78 ))
79endef
80
81#
45# Returns the sorted concatenation of PRODUCT_MAKEFILES 82# Returns the sorted concatenation of PRODUCT_MAKEFILES
46# variables set in the given AndroidProducts.mk files. 83# variables set in the given AndroidProducts.mk files.
47# $(1): the list of AndroidProducts.mk files. 84# $(1): the list of AndroidProducts.mk files.
48# 85#
86# As a side-effect, COMMON_LUNCH_CHOICES will be set to a
87# union of all of the COMMON_LUNCH_CHOICES definitions within
88# each AndroidProducts.mk file.
89#
49define get-product-makefiles 90define get-product-makefiles
50$(sort \ 91$(sort \
92 $(eval _COMMON_LUNCH_CHOICES :=) \
51 $(foreach f,$(1), \ 93 $(foreach f,$(1), \
52 $(eval PRODUCT_MAKEFILES :=) \ 94 $(eval PRODUCT_MAKEFILES :=) \
95 $(eval COMMON_LUNCH_CHOICES :=) \
53 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \ 96 $(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
54 $(eval include $(f)) \ 97 $(eval include $(f)) \
98 $(call _validate-common-lunch-choices,$(COMMON_LUNCH_CHOICES),$(PRODUCT_MAKEFILES)) \
99 $(eval _COMMON_LUNCH_CHOICES += $(COMMON_LUNCH_CHOICES)) \
55 $(PRODUCT_MAKEFILES) \ 100 $(PRODUCT_MAKEFILES) \
56 ) \ 101 ) \
57 $(eval PRODUCT_MAKEFILES :=) \ 102 $(eval PRODUCT_MAKEFILES :=) \
58 $(eval LOCAL_DIR :=) \ 103 $(eval LOCAL_DIR :=) \
104 $(eval COMMON_LUNCH_CHOICES := $(sort $(_COMMON_LUNCH_CHOICES) $(LUNCH_MENU_CHOICES))) \
105 $(eval _COMMON_LUNCH_CHOICES :=) \
59 ) 106 )
60endef 107endef
61 108
diff --git a/core/product_config.mk b/core/product_config.mk
index 9406812ab..6449b9fd7 100644
--- a/core/product_config.mk
+++ b/core/product_config.mk
@@ -195,18 +195,13 @@ all_named_products :=
195current_product_makefile := 195current_product_makefile :=
196all_product_makefiles := 196all_product_makefiles :=
197$(foreach f, $(all_product_configs),\ 197$(foreach f, $(all_product_configs),\
198 $(eval _cpm_words := $(subst :,$(space),$(f)))\ 198 $(eval _cpm_words := $(call _decode-product-name,$(f)))\
199 $(eval _cpm_word1 := $(word 1,$(_cpm_words)))\ 199 $(eval _cpm_word1 := $(word 1,$(_cpm_words)))\
200 $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\ 200 $(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
201 $(if $(_cpm_word2),\ 201 $(eval all_product_makefiles += $(_cpm_word2))\
202 $(eval all_product_makefiles += $(_cpm_word2))\ 202 $(eval all_named_products += $(_cpm_word1))\
203 $(eval all_named_products += $(_cpm_word1))\ 203 $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
204 $(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\ 204 $(eval current_product_makefile += $(_cpm_word2)),))
205 $(eval current_product_makefile += $(_cpm_word2)),),\
206 $(eval all_product_makefiles += $(f))\
207 $(eval all_named_products += $(basename $(notdir $(f))))\
208 $(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
209 $(eval current_product_makefile += $(f)),)))
210_cpm_words := 205_cpm_words :=
211_cpm_word1 := 206_cpm_word1 :=
212_cpm_word2 := 207_cpm_word2 :=
diff --git a/envsetup.sh b/envsetup.sh
index cf619505a..dc50dd968 100644
--- a/envsetup.sh
+++ b/envsetup.sh
@@ -544,14 +544,6 @@ function add_lunch_combo()
544 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo) 544 LUNCH_MENU_CHOICES=(${LUNCH_MENU_CHOICES[@]} $new_combo)
545} 545}
546 546
547# add the default one here
548add_lunch_combo aosp_arm-eng
549add_lunch_combo aosp_arm64-eng
550add_lunch_combo aosp_mips-eng
551add_lunch_combo aosp_mips64-eng
552add_lunch_combo aosp_x86-eng
553add_lunch_combo aosp_x86_64-eng
554
555function print_lunch_menu() 547function print_lunch_menu()
556{ 548{
557 local uname=$(uname) 549 local uname=$(uname)
@@ -562,7 +554,7 @@ function print_lunch_menu()
562 554
563 local i=1 555 local i=1
564 local choice 556 local choice
565 for choice in ${LUNCH_MENU_CHOICES[@]} 557 for choice in $(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES)
566 do 558 do
567 echo " $i. $choice" 559 echo " $i. $choice"
568 i=$(($i+1)) 560 i=$(($i+1))
@@ -590,9 +582,10 @@ function lunch()
590 selection=aosp_arm-eng 582 selection=aosp_arm-eng
591 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$") 583 elif (echo -n $answer | grep -q -e "^[0-9][0-9]*$")
592 then 584 then
593 if [ $answer -le ${#LUNCH_MENU_CHOICES[@]} ] 585 local choices=($(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES))
586 if [ $answer -le ${#choices[@]} ]
594 then 587 then
595 selection=${LUNCH_MENU_CHOICES[$(($answer-1))]} 588 selection=${choices[$(($answer-1))]}
596 fi 589 fi
597 else 590 else
598 selection=$answer 591 selection=$answer
@@ -643,6 +636,7 @@ function lunch()
643 destroy_build_var_cache 636 destroy_build_var_cache
644} 637}
645 638
639unset COMMON_LUNCH_CHOICES_CACHE
646# Tab completion for lunch. 640# Tab completion for lunch.
647function _lunch() 641function _lunch()
648{ 642{
@@ -651,7 +645,11 @@ function _lunch()
651 cur="${COMP_WORDS[COMP_CWORD]}" 645 cur="${COMP_WORDS[COMP_CWORD]}"
652 prev="${COMP_WORDS[COMP_CWORD-1]}" 646 prev="${COMP_WORDS[COMP_CWORD-1]}"
653 647
654 COMPREPLY=( $(compgen -W "${LUNCH_MENU_CHOICES[*]}" -- ${cur}) ) 648 if [ -z "$COMMON_LUNCH_CHOICES_CACHE" ]; then
649 COMMON_LUNCH_CHOICES_CACHE=$(TARGET_BUILD_APPS= LUNCH_MENU_CHOICES="${LUNCH_MENU_CHOICES[@]}" get_build_var COMMON_LUNCH_CHOICES)
650 fi
651
652 COMPREPLY=( $(compgen -W "${COMMON_LUNCH_CHOICES_CACHE}" -- ${cur}) )
655 return 0 653 return 0
656} 654}
657complete -F _lunch lunch 655complete -F _lunch lunch
diff --git a/target/product/AndroidProducts.mk b/target/product/AndroidProducts.mk
index 85330b30a..daa97260a 100644
--- a/target/product/AndroidProducts.mk
+++ b/target/product/AndroidProducts.mk
@@ -79,3 +79,11 @@ PRODUCT_MAKEFILES := \
79 $(LOCAL_DIR)/sdk_arm64.mk \ 79 $(LOCAL_DIR)/sdk_arm64.mk \
80 $(LOCAL_DIR)/sdk_x86_64.mk 80 $(LOCAL_DIR)/sdk_x86_64.mk
81endif 81endif
82
83COMMON_LUNCH_CHOICES := \
84 aosp_arm-eng \
85 aosp_arm64-eng \
86 aosp_mips-eng \
87 aosp_mips64-eng \
88 aosp_x86-eng \
89 aosp_x86_64-eng