Merge "Verify PRODUCT_* are not modified by Android.mks, but allow them to be read only."
This commit is contained in:
commit
9af2da0d94
2 changed files with 7 additions and 23 deletions
|
@ -473,10 +473,10 @@ endif # !BUILD_TINY_ANDROID
|
|||
endif # !SDK_ONLY
|
||||
|
||||
# Before we go and include all of the module makefiles, stash away
|
||||
# the PRODUCT_* values so you can't get to them.
|
||||
stash_product_vars:=#true
|
||||
# the PRODUCT_* values so that later we can verify they are not modified.
|
||||
stash_product_vars:=true
|
||||
ifeq ($(stash_product_vars),true)
|
||||
$(call stash-product-vars, __STASHED, DO_NOT_USE_IN_ANDROID_MK_)
|
||||
$(call stash-product-vars, __STASHED)
|
||||
endif
|
||||
|
||||
ifneq ($(ONE_SHOT_MAKEFILE),)
|
||||
|
@ -510,8 +510,7 @@ include $(subdir_makefiles)
|
|||
endif # ONE_SHOT_MAKEFILE
|
||||
|
||||
ifeq ($(stash_product_vars),true)
|
||||
$(call assert-product-vars, __STASHED, DO_NOT_USE_IN_ANDROID_MK_)
|
||||
$(call restore-product-vars, __STASHED)
|
||||
$(call assert-product-vars, __STASHED)
|
||||
endif
|
||||
|
||||
include $(BUILD_SYSTEM)/legacy_prebuilts.mk
|
||||
|
|
|
@ -190,44 +190,29 @@ endef
|
|||
|
||||
|
||||
#
|
||||
# Rename the variables in _product_var_list.
|
||||
# Stash vaues of the variables in _product_var_list.
|
||||
# $(1): Renamed prefix
|
||||
# $(2): New value prefix. The new value will be $(2)$(VARNAME)
|
||||
#
|
||||
define stash-product-vars
|
||||
$(foreach v,$(_product_var_list), \
|
||||
$(eval $(strip $(1))_$(call rot13,$(v)):=$$($$(v))) \
|
||||
$(eval $(v):=$(2)$$(v)) \
|
||||
)
|
||||
endef
|
||||
|
||||
#
|
||||
# Assert that the the variable stashed by stash-product-vars remains untouched.
|
||||
# $(1): The prefix as supplied to stash-product-vars
|
||||
# $(2): The expected value prefix. The value should be $(2)$(VARNAME)
|
||||
#
|
||||
define assert-product-vars
|
||||
$(strip \
|
||||
$(eval changed_variables:=)
|
||||
$(foreach v,$(_product_var_list), \
|
||||
$(if $(call streq,$($(v)),$(2)$(v)),, \
|
||||
$(if $(call streq,$($(v)),$($(strip $(1))_$(call rot13,$(v)))),, \
|
||||
$(eval $(warning $(v) has been modified: $($(v)))) \
|
||||
$(eval $(warning previous value: $($(strip $(1))_$(call rot13,$(v))))) \
|
||||
$(eval changed_variables := $(changed_variables) $(v))) \
|
||||
) \
|
||||
$(if $(changed_variables),\
|
||||
$(eval $(error The following variables have been changed: $(changed_variables))),)
|
||||
)
|
||||
endef
|
||||
# ... $(eval $(warning $(v) $($(v)),$(2)$(v) streq-->$(call streq,$($(v)),$(2)$(v)))) \
|
||||
|
||||
#
|
||||
# Restore the product variables as stashed by stash-product-vars
|
||||
# $(1): The prefix as supplied to stash-product-vars
|
||||
#
|
||||
define restore-product-vars
|
||||
$(foreach v,$(_product_var_list), \
|
||||
$(eval $(v):=$($(strip $(1))_$(call rot13,$(v)))) \
|
||||
$(eval $(strip $(1))_$(v):=) \
|
||||
)
|
||||
endef
|
||||
|
||||
|
|
Loading…
Reference in a new issue