Start moving add_lunch_combo to Make
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
This commit is contained in:
@@ -41,21 +41,68 @@ $(foreach d, device vendor product,$(call _search-android-products-files-in-dir,
|
||||
$(SRC_TARGET_DIR)/product/AndroidProducts.mk
|
||||
endef
|
||||
|
||||
#
|
||||
# For entries returned by get-product-makefiles, decode an entry to a short
|
||||
# product name. These either may be in the form of <name>:path/to/file.mk or
|
||||
# path/to/<name>.mk
|
||||
# $(1): The entry to decode
|
||||
#
|
||||
# Returns two words:
|
||||
# <name> <file>
|
||||
#
|
||||
define _decode-product-name
|
||||
$(strip \
|
||||
$(eval _cpm_words := $(subst :,$(space),$(1))) \
|
||||
$(if $(word 2,$(_cpm_words)), \
|
||||
$(wordlist 1,2,$(_cpm_words)), \
|
||||
$(basename $(notdir $(1))) $(1)))
|
||||
endef
|
||||
|
||||
#
|
||||
# Validates the new common lunch choices -- ensures that they're in an
|
||||
# appropriate form, and are paired with definitions of their products.
|
||||
# $(1): The new list of COMMON_LUNCH_CHOICES
|
||||
# $(2): The new list of PRODUCT_MAKEFILES
|
||||
#
|
||||
define _validate-common-lunch-choices
|
||||
$(strip $(foreach choice,$(1),\
|
||||
$(eval _parts := $(subst -,$(space),$(choice))) \
|
||||
$(if $(call math_lt,$(words $(_parts)),2), \
|
||||
$(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
|
||||
$(if $(call math_gt_or_eq,$(words $(_parts)),4), \
|
||||
$(error $(LOCAL_DIR): $(choice): Invalid lunch choice)) \
|
||||
$(if $(filter-out eng userdebug user,$(word 2,$(_parts))), \
|
||||
$(error $(LOCAL_DIR): $(choice): Invalid variant: $(word 2,$(_parts)))) \
|
||||
$(if $(filter-out $(foreach p,$(2),$(call _decode-product-name,$(p))),$(word 1,$(_parts))), \
|
||||
$(error $(LOCAL_DIR): $(word 1,$(_parts)): Product not defined in this file)) \
|
||||
))
|
||||
endef
|
||||
|
||||
#
|
||||
# Returns the sorted concatenation of PRODUCT_MAKEFILES
|
||||
# variables set in the given AndroidProducts.mk files.
|
||||
# $(1): the list of AndroidProducts.mk files.
|
||||
#
|
||||
# As a side-effect, COMMON_LUNCH_CHOICES will be set to a
|
||||
# union of all of the COMMON_LUNCH_CHOICES definitions within
|
||||
# each AndroidProducts.mk file.
|
||||
#
|
||||
define get-product-makefiles
|
||||
$(sort \
|
||||
$(eval _COMMON_LUNCH_CHOICES :=) \
|
||||
$(foreach f,$(1), \
|
||||
$(eval PRODUCT_MAKEFILES :=) \
|
||||
$(eval COMMON_LUNCH_CHOICES :=) \
|
||||
$(eval LOCAL_DIR := $(patsubst %/,%,$(dir $(f)))) \
|
||||
$(eval include $(f)) \
|
||||
$(call _validate-common-lunch-choices,$(COMMON_LUNCH_CHOICES),$(PRODUCT_MAKEFILES)) \
|
||||
$(eval _COMMON_LUNCH_CHOICES += $(COMMON_LUNCH_CHOICES)) \
|
||||
$(PRODUCT_MAKEFILES) \
|
||||
) \
|
||||
$(eval PRODUCT_MAKEFILES :=) \
|
||||
$(eval LOCAL_DIR :=) \
|
||||
$(eval COMMON_LUNCH_CHOICES := $(sort $(_COMMON_LUNCH_CHOICES) $(LUNCH_MENU_CHOICES))) \
|
||||
$(eval _COMMON_LUNCH_CHOICES :=) \
|
||||
)
|
||||
endef
|
||||
|
||||
|
||||
@@ -195,18 +195,13 @@ all_named_products :=
|
||||
current_product_makefile :=
|
||||
all_product_makefiles :=
|
||||
$(foreach f, $(all_product_configs),\
|
||||
$(eval _cpm_words := $(subst :,$(space),$(f)))\
|
||||
$(eval _cpm_words := $(call _decode-product-name,$(f)))\
|
||||
$(eval _cpm_word1 := $(word 1,$(_cpm_words)))\
|
||||
$(eval _cpm_word2 := $(word 2,$(_cpm_words)))\
|
||||
$(if $(_cpm_word2),\
|
||||
$(eval all_product_makefiles += $(_cpm_word2))\
|
||||
$(eval all_named_products += $(_cpm_word1))\
|
||||
$(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
|
||||
$(eval current_product_makefile += $(_cpm_word2)),),\
|
||||
$(eval all_product_makefiles += $(f))\
|
||||
$(eval all_named_products += $(basename $(notdir $(f))))\
|
||||
$(if $(filter $(TARGET_PRODUCT),$(basename $(notdir $(f)))),\
|
||||
$(eval current_product_makefile += $(f)),)))
|
||||
$(eval all_product_makefiles += $(_cpm_word2))\
|
||||
$(eval all_named_products += $(_cpm_word1))\
|
||||
$(if $(filter $(TARGET_PRODUCT),$(_cpm_word1)),\
|
||||
$(eval current_product_makefile += $(_cpm_word2)),))
|
||||
_cpm_words :=
|
||||
_cpm_word1 :=
|
||||
_cpm_word2 :=
|
||||
|
||||
Reference in New Issue
Block a user