Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9d220844 authored by Dan Willemsen's avatar Dan Willemsen Committed by android-build-merger
Browse files

Merge "Replace product variable stashing with .KATI_READONLY"

am: 157ad04c

Change-Id: I0672cfab4bb7a87cecead3b168080aac208cf5eb
parents 2882b0af 157ad04c
Loading
Loading
Loading
Loading
+11 −13
Original line number Original line Diff line number Diff line
@@ -522,12 +522,10 @@ endif


INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))


BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
ifdef BOARD_KERNEL_BASE
ifdef BOARD_KERNEL_BASE
  INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
  INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
endif


BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
ifdef BOARD_KERNEL_PAGESIZE
ifdef BOARD_KERNEL_PAGESIZE
  INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
  INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
endif
@@ -539,9 +537,9 @@ VERITY_KEYID := veritykeyid=id:`openssl x509 -in $(PRODUCTS.$(INTERNAL_PRODUCT).
endif
endif
endif
endif


BOARD_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE) buildvariant=$(TARGET_BUILD_VARIANT) $(VERITY_KEYID))
ifdef BOARD_KERNEL_CMDLINE
ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
endif


INTERNAL_MKBOOTIMG_VERSION_ARGS := \
INTERNAL_MKBOOTIMG_VERSION_ARGS := \
@@ -632,6 +630,7 @@ endif # TARGET_BOOTIMAGE_USE_EXT2
endif # BOARD_USES_RECOVERY_AS_BOOT
endif # BOARD_USES_RECOVERY_AS_BOOT


else	# TARGET_NO_KERNEL
else	# TARGET_NO_KERNEL
INTERNAL_KERNEL_CMDLINE := $(strip $(BOARD_KERNEL_CMDLINE))
# HACK: The top-level targets depend on the bootimage.  Not all targets
# HACK: The top-level targets depend on the bootimage.  Not all targets
# can produce a bootimage, though, and emulator targets need the ramdisk
# can produce a bootimage, though, and emulator targets need the ramdisk
# instead.  Fake it out by calling the ramdisk the bootimage.
# instead.  Fake it out by calling the ramdisk the bootimage.
@@ -977,13 +976,12 @@ INTERNAL_RECOVERYIMAGE_ARGS := \
	--ramdisk $(recovery_ramdisk)
	--ramdisk $(recovery_ramdisk)


# Assumes this has already been stripped
# Assumes this has already been stripped
ifdef BOARD_KERNEL_CMDLINE
ifdef INTERNAL_KERNEL_CMDLINE
  INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(BOARD_KERNEL_CMDLINE)"
  INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
endif
ifdef BOARD_KERNEL_BASE
ifdef BOARD_KERNEL_BASE
  INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
  INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
endif
BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))
ifdef BOARD_KERNEL_PAGESIZE
ifdef BOARD_KERNEL_PAGESIZE
  INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
  INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
endif
@@ -1346,7 +1344,7 @@ define build-boottarball-target
    $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
    $(hide) echo "Target boot fs tarball: $(INSTALLED_BOOTTARBALL_TARGET)"
    $(hide) mkdir -p $(PRODUCT_OUT)/boot
    $(hide) mkdir -p $(PRODUCT_OUT)/boot
    $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
    $(hide) cp -f $(INTERNAL_BOOTIMAGE_FILES) $(PRODUCT_OUT)/boot/.
    $(hide) echo $(BOARD_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
    $(hide) echo $(INTERNAL_KERNEL_CMDLINE) > $(PRODUCT_OUT)/boot/cmdline
    $(hide) $(MKTARBALL) $(FS_GET_STATS) \
    $(hide) $(MKTARBALL) $(FS_GET_STATS) \
                 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
                 $(PRODUCT_OUT) boot $(PRIVATE_BOOT_TAR) \
                 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
                 $(INSTALLED_BOOTTARBALL_TARGET) $(TARGET_OUT)
@@ -1812,8 +1810,8 @@ ifdef INSTALLED_2NDBOOTLOADER_TARGET
	$(hide) $(ACP) \
	$(hide) $(ACP) \
		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
endif
endif
ifdef BOARD_KERNEL_CMDLINE
ifdef INTERNAL_KERNEL_CMDLINE
	$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
	$(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
endif
endif
ifdef BOARD_KERNEL_BASE
ifdef BOARD_KERNEL_BASE
	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
@@ -1841,8 +1839,8 @@ ifdef INSTALLED_2NDBOOTLOADER_TARGET
	$(hide) $(ACP) \
	$(hide) $(ACP) \
		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
		$(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
endif
endif
ifdef BOARD_KERNEL_CMDLINE
ifdef INTERNAL_KERNEL_CMDLINE
	$(hide) echo "$(BOARD_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
	$(hide) echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
endif
endif
ifdef BOARD_KERNEL_BASE
ifdef BOARD_KERNEL_BASE
	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
	$(hide) echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
+3 −0
Original line number Original line Diff line number Diff line
@@ -216,6 +216,9 @@ ifeq ($(TARGET_CPU_ABI),)
endif
endif
TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))
TARGET_CPU_ABI2 := $(strip $(TARGET_CPU_ABI2))


BOARD_KERNEL_BASE := $(strip $(BOARD_KERNEL_BASE))
BOARD_KERNEL_PAGESIZE := $(strip $(BOARD_KERNEL_PAGESIZE))

# Commands to generate .toc file common to ELF .so files.
# Commands to generate .toc file common to ELF .so files.
define _gen_toc_command_for_elf
define _gen_toc_command_for_elf
$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
+3 −10
Original line number Original line Diff line number Diff line
@@ -504,12 +504,9 @@ endif


FULL_BUILD := true
FULL_BUILD := true


# Before we go and include all of the module makefiles, stash away
# Before we go and include all of the module makefiles, mark the PRODUCT_*
# the PRODUCT_* values so that later we can verify they are not modified.
# values readonly so that they won't be modified.
stash_product_vars:=true
$(call readonly-product-vars)
ifeq ($(stash_product_vars),true)
  $(call stash-product-vars, __STASHED)
endif


ifneq ($(ONE_SHOT_MAKEFILE),)
ifneq ($(ONE_SHOT_MAKEFILE),)
# We've probably been invoked by the "mm" shell function
# We've probably been invoked by the "mm" shell function
@@ -574,10 +571,6 @@ endif # ONE_SHOT_MAKEFILE
# Now with all Android.mks loaded we can do post cleaning steps.
# Now with all Android.mks loaded we can do post cleaning steps.
include $(BUILD_SYSTEM)/post_clean.mk
include $(BUILD_SYSTEM)/post_clean.mk


ifeq ($(stash_product_vars),true)
  $(call assert-product-vars, __STASHED)
endif

# -------------------------------------------------------------------
# -------------------------------------------------------------------
# All module makefiles have been included at this point.
# All module makefiles have been included at this point.
# -------------------------------------------------------------------
# -------------------------------------------------------------------
+4 −22
Original line number Original line Diff line number Diff line
@@ -296,30 +296,12 @@ _product_stash_var_list += \
	GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \
	GLOBAL_CLANG_CFLAGS_NO_OVERRIDE \


#
#
# Stash values of the variables in _product_stash_var_list.
# Mark the variables in _product_stash_var_list as readonly
# $(1): Renamed prefix
#
#
define stash-product-vars
define readonly-product-vars
$(foreach v,$(_product_stash_var_list), \
$(foreach v,$(_product_stash_var_list), \
        $(eval $(strip $(1))_rot26_$(v):=$$($$(v))) \
	$(eval $(v) ?=) \
 )
	$(eval .KATI_READONLY := $(v)) \
endef

#
# Assert that the the variable stashed by stash-product-vars remains untouched.
# $(1): The prefix as supplied to stash-product-vars
#
define assert-product-vars
$(strip \
  $(eval changed_variables:=)
  $(foreach v,$(_product_stash_var_list), \
    $(if $(call streq,$($(v)),$($(strip $(1))_rot26_$(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
endef