Merge changes I4d88733c,I61943476,Ibed9c96d

* changes:
  remove buildinfo_common.sh
  Partial cherry-pick of ag/10260813
  <partition>/build.prop rules are defined using macro
This commit is contained in:
Jiyong Park 2020-06-08 00:58:48 +00:00 committed by Gerrit Code Review
commit c844de4241
3 changed files with 149 additions and 203 deletions

View File

@ -329,6 +329,8 @@ ADDITIONAL_PRODUCT_PROPERTIES += ro.product.vndk.version=$(PRODUCT_PRODUCT_VNDK_
endif endif
endif endif
ADDITIONAL_PRODUCT_PROPERTIES += ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)
# ----------------------------------------------------------------- # -----------------------------------------------------------------
### ###
### In this section we set up the things that are different ### In this section we set up the things that are different

View File

@ -24,38 +24,89 @@ ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true)
endif endif
BUILDINFO_SH := build/make/tools/buildinfo.sh BUILDINFO_SH := build/make/tools/buildinfo.sh
BUILDINFO_COMMON_SH := build/make/tools/buildinfo_common.sh
POST_PROCESS_PROPS := $(HOST_OUT_EXECUTABLES)/post_process_props$(HOST_EXECUTABLE_SUFFIX) POST_PROCESS_PROPS := $(HOST_OUT_EXECUTABLES)/post_process_props$(HOST_EXECUTABLE_SUFFIX)
# Generates a set of sysprops common to all partitions to a file. # Emits a set of sysprops common to all partitions to a file.
# $(1): Partition name # $(1): Partition name
# $(2): Output file name # $(2): Output file name
define generate-common-build-props define generate-common-build-props
PRODUCT_BRAND="$(PRODUCT_BRAND)" \ echo "####################################" >> $(2);\
PRODUCT_DEVICE="$(TARGET_DEVICE)" \ echo "# from generate-common-build-props" >> $(2);\
PRODUCT_MANUFACTURER="$(PRODUCT_MANUFACTURER)" \ echo "# These properties identify this partition image." >> $(2);\
PRODUCT_MODEL="$(PRODUCT_MODEL)" \ echo "####################################" >> $(2);\
PRODUCT_NAME="$(TARGET_PRODUCT)" \ $(if $(filter system,$(1)),\
$(call generate-common-build-props-with-product-vars-set,$(1),$(2)) echo "ro.product.$(1).brand=$(PRODUCT_SYSTEM_BRAND)" >> $(2);\
echo "ro.product.$(1).device=$(PRODUCT_SYSTEM_DEVICE)" >> $(2);\
echo "ro.product.$(1).manufacturer=$(PRODUCT_SYSTEM_MANUFACTURER)" >> $(2);\
echo "ro.product.$(1).model=$(PRODUCT_SYSTEM_MODEL)" >> $(2);\
echo "ro.product.$(1).name=$(PRODUCT_SYSTEM_NAME)" >> $(2);\
,\
echo "ro.product.$(1).brand=$(PRODUCT_BRAND)" >> $(2);\
echo "ro.product.$(1).device=$(TARGET_DEVICE)" >> $(2);\
echo "ro.product.$(1).manufacturer=$(PRODUCT_MANUFACTURER)" >> $(2);\
echo "ro.product.$(1).model=$(PRODUCT_MODEL)" >> $(2);\
echo "ro.product.$(1).name=$(TARGET_PRODUCT)" >> $(2);\
)\
echo "ro.$(1).build.date=`$(DATE_FROM_FILE)`" >> $(2);\
echo "ro.$(1).build.date.utc=`$(DATE_FROM_FILE) +%s`" >> $(2);\
echo "ro.$(1).build.fingerprint=$(BUILD_FINGERPRINT_FROM_FILE)" >> $(2);\
echo "ro.$(1).build.id=$(BUILD_ID)" >> $(2);\
echo "ro.$(1).build.tags=$(BUILD_VERSION_TAGS)" >> $(2);\
echo "ro.$(1).build.type=$(TARGET_BUILD_VARIANT)" >> $(2);\
echo "ro.$(1).build.version.incremental=$(BUILD_NUMBER_FROM_FILE)" >> $(2);\
echo "ro.$(1).build.version.release=$(PLATFORM_VERSION)" >> $(2);\
echo "ro.$(1).build.version.sdk=$(PLATFORM_SDK_VERSION)" >> $(2);\
endef endef
# Like the above macro, but requiring the relevant PRODUCT_ environment # Rule for generating <partition>/build.prop file
# variables to be set when called. #
define generate-common-build-props-with-product-vars-set # $(1): partition name
BUILD_FINGERPRINT="$(BUILD_FINGERPRINT_FROM_FILE)" \ # $(2): path to the output
BUILD_ID="$(BUILD_ID)" \ # $(3): path to the input *.prop files. The contents of the files are directly
BUILD_NUMBER="$(BUILD_NUMBER_FROM_FILE)" \ # emitted to the output
BUILD_VERSION_TAGS="$(BUILD_VERSION_TAGS)" \ # $(4): list of variable names each of which contains name=value pairs
DATE="$(DATE_FROM_FILE)" \ # $(5): optional list of prop names to force remove from the output. Properties from both
PLATFORM_SDK_VERSION="$(PLATFORM_SDK_VERSION)" \ # $(3) and (4) are affected.
PLATFORM_VERSION_LAST_STABLE="$(PLATFORM_VERSION_LAST_STABLE)" \ define build-properties
PLATFORM_VERSION="$(PLATFORM_VERSION)" \ ALL_DEFAULT_INSTALLED_MODULES += $(2)
TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
bash $(BUILDINFO_COMMON_SH) "$(1)" >> $(2) # TODO(b/117892318): eliminate the call to uniq-pairs-by-first-component when
# it is guaranteed that there is no dup.
$(foreach name,$(strip $(4)),\
$(eval _resolved_$(name) := $$(call collapse-pairs, $$(call uniq-pairs-by-first-component,$$($(name)),=)))\
)
$(2): $(POST_PROCESS_PROPS) $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) $(3)
$(hide) echo Building $$@
$(hide) mkdir -p $$(dir $$@)
$(hide) rm -f $$@ && touch $$@
$(hide) $$(call generate-common-build-props,$(call to-lower,$(strip $(1))),$$@)
$(hide) $(foreach file,$(strip $(3)),\
if [ -f "$(file)" ]; then\
echo "" >> $$@;\
echo "####################################" >> $$@;\
echo "# from $(file)" >> $$@;\
echo "####################################" >> $$@;\
cat $(file) >> $$@;\
fi;)
$(hide) $(foreach name,$(strip $(4)),\
echo "" >> $$@;\
echo "####################################" >> $$@;\
echo "# from variable $(name)" >> $$@;\
echo "####################################" >> $$@;\
$$(foreach line,$$(_resolved_$(name)),\
echo "$$(line)" >> $$@;\
)\
)
$(hide) $(POST_PROCESS_PROPS) $$@ $(5)
$(hide) echo "# end of file" >> $$@
endef endef
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# build.prop # system/build.prop
#
intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop
INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET)
@ -182,7 +233,7 @@ system_prop_file := $(TARGET_SYSTEM_PROP)
else else
system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
endif endif
$(intermediate_system_build_prop): $(BUILDINFO_SH) $(BUILDINFO_COMMON_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(API_FINGERPRINT) $(POST_PROCESS_PROPS) $(intermediate_system_build_prop): $(BUILDINFO_SH) $(INTERNAL_BUILD_ID_MAKEFILE) $(BUILD_SYSTEM)/version_defaults.mk $(system_prop_file) $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(API_FINGERPRINT) $(POST_PROCESS_PROPS)
@echo Target buildinfo: $@ @echo Target buildinfo: $@
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(hide) rm -f $@ && touch $@ $(hide) rm -f $@ && touch $@
@ -195,12 +246,7 @@ ifneq ($(PRODUCT_OEM_PROPERTIES),)
$(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \ $(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \
echo "import /oem/oem.prop $(prop)" >> $@;) echo "import /oem/oem.prop $(prop)" >> $@;)
endif endif
$(hide) PRODUCT_BRAND="$(PRODUCT_SYSTEM_BRAND)" \ $(hide) $(call generate-common-build-props,system,$@)
PRODUCT_MANUFACTURER="$(PRODUCT_SYSTEM_MANUFACTURER)" \
PRODUCT_MODEL="$(PRODUCT_SYSTEM_MODEL)" \
PRODUCT_NAME="$(PRODUCT_SYSTEM_NAME)" \
PRODUCT_DEVICE="$(PRODUCT_SYSTEM_DEVICE)" \
$(call generate-common-build-props-with-product-vars-set,system,$@)
$(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \
TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \ TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \
TARGET_DEVICE="$(TARGET_DEVICE)" \ TARGET_DEVICE="$(TARGET_DEVICE)" \
@ -258,167 +304,94 @@ $(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop)
$(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@ $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# vendor build.prop # vendor/build.prop
# #
# For verifying that the vendor build is what we think it is _prop_files_ := $(if $(TARGET_VENDOR_PROP),\
INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop $(TARGET_VENDOR_PROP),\
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop))
ifdef TARGET_VENDOR_PROP
vendor_prop_files := $(TARGET_VENDOR_PROP)
else
vendor_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop)
endif
android_info_prop := $(call intermediates-dir-for,ETC,android_info_prop)/android_info.prop android_info_prop := $(call intermediates-dir-for,ETC,android_info_prop)/android_info.prop
$(android_info_prop): $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(android_info_prop): $(INSTALLED_ANDROID_INFO_TXT_TARGET)
cat $< | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' > $@ cat $< | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' > $@
vendor_prop_files += $(android_info_prop) _prop_files_ += $(android_info_pro)
ifdef property_overrides_split_enabled ifdef property_overrides_split_enabled
FINAL_VENDOR_BUILD_PROPERTIES += \ # Order matters here. When there are duplicates, the last one wins.
$(call collapse-pairs, $(PRODUCT_PROPERTY_OVERRIDES) $(ADDITIONAL_VENDOR_PROPERTIES)) # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter
FINAL_VENDOR_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ _prop_vars_ := \
$(FINAL_VENDOR_BUILD_PROPERTIES),=) ADDITIONAL_VENDOR_PROPERTIES \
endif # property_overrides_split_enabled PRODUCT_PROPERTY_OVERRIDES
$(INSTALLED_VENDOR_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(vendor_prop_files)
@echo Target vendor buildinfo: $@
@mkdir -p $(dir $@)
$(hide) rm -f $@ && touch $@
$(hide) $(call generate-common-build-props,vendor,$@)
$(hide) echo "#" >> $@; \
echo "# ADDITIONAL VENDOR BUILD PROPERTIES" >> $@; \
echo "#" >> $@;
ifdef property_overrides_split_enabled
$(hide) $(foreach file,$(vendor_prop_files), \
if [ -f "$(file)" ]; then \
echo Target vendor properties from: "$(file)"; \
echo "" >> $@; \
echo "#" >> $@; \
echo "# from $(file)" >> $@; \
echo "#" >> $@; \
cat $(file) >> $@; \
echo "# end of $(file)" >> $@; \
fi;)
$(hide) $(foreach line,$(FINAL_VENDOR_BUILD_PROPERTIES), \
echo "$(line)" >> $@;)
endif # property_overrides_split_enabled
$(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_VENDOR_PROPERTY_BLACKLIST)
# -----------------------------------------------------------------
# product build.prop
INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_BUILD_PROP_TARGET)
ifdef TARGET_PRODUCT_PROP
product_prop_files := $(TARGET_PRODUCT_PROP)
else else
product_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/product.prop) _prop_vars_ :=
endif endif
FINAL_PRODUCT_PROPERTIES += \ INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
$(call collapse-pairs, $(PRODUCT_PRODUCT_PROPERTIES) $(ADDITIONAL_PRODUCT_PROPERTIES)) $(eval $(call build-properties,\
FINAL_PRODUCT_PROPERTIES := $(call uniq-pairs-by-first-component, \ vendor,\
$(FINAL_PRODUCT_PROPERTIES),=) $(INSTALLED_VENDOR_BUILD_PROP_TARGET),\
$(_prop_files_),\
$(_prop_vars_),\
$(PRODUCT_VENDOR_PROPERTY_BLACKLIST)))
$(INSTALLED_PRODUCT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(product_prop_files) # -----------------------------------------------------------------
@echo Target product buildinfo: $@ # product/build.prop
@mkdir -p $(dir $@) #
$(hide) rm -f $@ && touch $@
$(hide) $(call generate-common-build-props,product,$@) _prop_files_ := $(if $(TARGET_PRODUCT_PROP),\
$(hide) $(foreach file,$(product_prop_files), \ $(TARGET_PRODUCT_PROP),\
if [ -f "$(file)" ]; then \ $(wildcard $(TARGET_DEVICE_DIR)/product.prop))
echo Target product properties from: "$(file)"; \
echo "" >> $@; \ # Order matters here. When there are duplicates, the last one wins.
echo "#" >> $@; \ # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter
echo "# from $(file)" >> $@; \ _prop_vars_ := \
echo "#" >> $@; \ ADDITIONAL_PRODUCT_PROPERTIES \
cat $(file) >> $@; \ PRODUCT_PRODUCT_PROPERTIES
echo "# end of $(file)" >> $@; \
fi;) INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/build.prop
$(hide) echo "#" >> $@; \ $(eval $(call build-properties,\
echo "# ADDITIONAL PRODUCT PROPERTIES" >> $@; \ product,\
echo "#" >> $@; \ $(INSTALLED_PRODUCT_BUILD_PROP_TARGET),\
echo "ro.build.characteristics=$(TARGET_AAPT_CHARACTERISTICS)" >> $@; $(_prop_files_),\
$(hide) $(foreach line,$(FINAL_PRODUCT_PROPERTIES), \ $(_prop_vars_),\
echo "$(line)" >> $@;) $(empty)))
$(hide) $(POST_PROCESS_PROPS) $@
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# odm build.prop # odm/build.prop
INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop #
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_ODM_BUILD_PROP_TARGET) _prop_files_ := $(if $(TARGET_ODM_PROP),\
$(TARGET_ODM_PROP),\
$(wildcard $(TARGET_DEVICE_DIR)/odm.prop))
ifdef TARGET_ODM_PROP # Order matters here. When there are duplicates, the last one wins.
odm_prop_files := $(TARGET_ODM_PROP) # TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter
else _prop_vars_ := \
odm_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/odm.prop) ADDITIONAL_ODM_PROPERTIES \
endif PRODUCT_ODM_PROPERTIES
FINAL_ODM_BUILD_PROPERTIES += \ INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/build.prop
$(call collapse-pairs, $(PRODUCT_ODM_PROPERTIES) $(ADDITIONAL_ODM_PROPERTIES)) $(eval $(call build-properties,\
FINAL_ODM_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ odm,\
$(FINAL_ODM_BUILD_PROPERTIES),=) $(INSTALLED_ODM_BUILD_PROP_TARGET),\
$(_prop_files),\
$(INSTALLED_ODM_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(odm_prop_files) $(_prop_vars_),\
@echo Target odm buildinfo: $@ $(empty)))
@mkdir -p $(dir $@)
$(hide) rm -f $@ && touch $@
$(hide) $(call generate-common-build-props,odm,$@)
$(hide) $(foreach file,$(odm_prop_files), \
if [ -f "$(file)" ]; then \
echo Target odm properties from: "$(file)"; \
echo "" >> $@; \
echo "#" >> $@; \
echo "# from $(file)" >> $@; \
echo "#" >> $@; \
cat $(file) >> $@; \
echo "# end of $(file)" >> $@; \
fi;)
$(hide) echo "#" >> $@; \
echo "# ADDITIONAL ODM BUILD PROPERTIES" >> $@; \
echo "#" >> $@;
$(hide) $(foreach line,$(FINAL_ODM_BUILD_PROPERTIES), \
echo "$(line)" >> $@;)
$(hide) $(POST_PROCESS_PROPS) $@
# ----------------------------------------------------------------- # -----------------------------------------------------------------
# system_ext build.prop # system_ext/build.prop
#
_prop_files_ := $(if $(TARGET_SYSTEM_EXT_PROP),\
$(TARGET_SYSTEM_EXT_PROP),\
$(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop))
# Order matters here. When there are duplicates, the last one wins.
# TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter
_prop_vars_ := PRODUCT_SYSTEM_EXT_PROPERTIES
INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/build.prop INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/build.prop
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) $(eval $(call build-properties,\
system_ext,\
ifdef TARGET_SYSTEM_EXT_PROP $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET),\
system_ext_prop_files := $(TARGET_SYSTEM_EXT_PROP) $(_prop_files_),\
else $(_prop_vars_),\
system_ext_prop_files := $(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop) $(empty)))
endif
FINAL_SYSTEM_EXT_PROPERTIES += \
$(call collapse-pairs, $(PRODUCT_SYSTEM_EXT_PROPERTIES))
FINAL_SYSTEM_EXT_PROPERTIES := $(call uniq-pairs-by-first-component, \
$(FINAL_SYSTEM_EXT_PROPERTIES),=)
$(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET): $(BUILDINFO_COMMON_SH) $(POST_PROCESS_PROPS) $(system_ext_prop_files)
@echo Target system_ext buildinfo: $@
@mkdir -p $(dir $@)
$(hide) rm -f $@ && touch $@
$(hide) $(call generate-common-build-props,system_ext,$@)
$(hide) $(foreach file,$(system_ext_prop_files), \
if [ -f "$(file)" ]; then \
echo Target system_ext properties from: "$(file)"; \
echo "" >> $@; \
echo "#" >> $@; \
echo "# from $(file)" >> $@; \
echo "#" >> $@; \
cat $(file) >> $@; \
echo "# end of $(file)" >> $@; \
fi;)
$(hide) echo "#" >> $@; \
echo "# ADDITIONAL SYSTEM_EXT BUILD PROPERTIES" >> $@; \
echo "#" >> $@;
$(hide) $(foreach line,$(FINAL_SYSTEM_EXT_PROPERTIES), \
echo "$(line)" >> $@;)
$(hide) $(POST_PROCESS_PROPS) $@

View File

@ -1,29 +0,0 @@
#!/bin/bash
partition="$1"
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <partition>" 1>&2
exit 1
fi
echo "# begin common build properties"
echo "# autogenerated by $0"
echo "ro.${partition}.build.date=`$DATE`"
echo "ro.${partition}.build.date.utc=`$DATE +%s`"
echo "ro.${partition}.build.fingerprint=$BUILD_FINGERPRINT"
echo "ro.${partition}.build.id=$BUILD_ID"
echo "ro.${partition}.build.tags=$BUILD_VERSION_TAGS"
echo "ro.${partition}.build.type=$TARGET_BUILD_TYPE"
echo "ro.${partition}.build.version.incremental=$BUILD_NUMBER"
echo "ro.${partition}.build.version.release=$PLATFORM_VERSION"
echo "ro.${partition}.build.version.sdk=$PLATFORM_SDK_VERSION"
echo "ro.product.${partition}.brand=$PRODUCT_BRAND"
echo "ro.product.${partition}.device=$PRODUCT_DEVICE"
echo "ro.product.${partition}.manufacturer=$PRODUCT_MANUFACTURER"
echo "ro.product.${partition}.model=$PRODUCT_MODEL"
echo "ro.product.${partition}.name=$PRODUCT_NAME"
echo "# end common build properties"