diff options
author | 2020-05-26 03:18:36 +0900 | |
---|---|---|
committer | 2020-06-08 10:09:12 +0900 | |
commit | bb26c6f2bfde3eb97589e3f27eb848c778ef9b29 (patch) | |
tree | b007f060c8b8815444710ef91dd7fbe9eb94ed76 | |
parent | c844de42410f6263525639af1ba390fa187250bb (diff) |
Rule for system/build.prop is also from macro
Like other <partition>/build.prop files, the build rule for
system/build.prop is also created using the build-properties macro.
system/build.prop has a few number of auto-generate properties that the
macro doesn't create. Those properties are emitted to intermediate files
using manually crafted rules, the paths to the files are fed to the
macro, where their contents are copied to system/build.prop.
This change also refactors the code fragment that defines BUILD_*
variables that identifes the given build.
Bug: 117892318
Test: m
Change-Id: Ic218283b40fedeaddacb3fda93167edbec86094c
-rw-r--r-- | core/Makefile | 4 | ||||
-rw-r--r-- | core/sysprop.mk | 183 |
2 files changed, 91 insertions, 96 deletions
diff --git a/core/Makefile b/core/Makefile index 52239af862..27f8756e71 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1645,7 +1645,7 @@ $(foreach prop,$(1), \ endef $(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \ - $(intermediate_system_build_prop) \ + $(INSTALLED_BUILD_PROP_TARGET) \ $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \ $(INSTALLED_ODM_BUILD_PROP_TARGET) \ $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \ @@ -1653,7 +1653,7 @@ $(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \ @echo "Target recovery buildinfo: $@" $(hide) mkdir -p $(dir $@) $(hide) rm -f $@ - $(hide) cat $(intermediate_system_build_prop) >> $@ + $(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@ $(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@ $(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@ $(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@ diff --git a/core/sysprop.mk b/core/sysprop.mk index e5e847e177..14fa828a17 100644 --- a/core/sysprop.mk +++ b/core/sysprop.mk @@ -103,34 +103,13 @@ $(2): $(POST_PROCESS_PROPS) $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) $(3 $(hide) echo "# end of file" >> $$@ endef - # ----------------------------------------------------------------- -# system/build.prop +# Define fingerprint, thumbprint, and version tags for the current build # -intermediate_system_build_prop := $(call intermediates-dir-for,ETC,system_build_prop)/build.prop -INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop -ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_BUILD_PROP_TARGET) - -# TODO(b/117892318) merge DEFAULT into BUILD -FINAL_DEFAULT_PROPERTIES := \ - $(call collapse-pairs, $(PRODUCT_SYSTEM_DEFAULT_PROPERTIES)) -FINAL_DEFAULT_PROPERTIES := $(call uniq-pairs-by-first-component, \ - $(FINAL_DEFAULT_PROPERTIES),=) - -FINAL_BUILD_PROPERTIES := \ - $(call collapse-pairs, $(ADDITIONAL_SYSTEM_PROPERTIES)) - -# For non-Treble devices, consider vendor properties as system properties -ifndef property_overrides_split_enabled -FINAL_BUILD_PROPERTIES += \ - $(call collapse-pairs, $(ADDITIONAL_VENDOR_PROPERTIES)) -endif - -FINAL_BUILD_PROPERTIES := $(call uniq-pairs-by-first-component, \ - $(FINAL_BUILD_PROPERTIES),=) - -# A list of arbitrary tags describing the build configuration. -# Force ":=" so we can use += +# BUILD_VERSION_TAGS is a comma-separated list of tags chosen by the device +# implementer that further distinguishes the build. It's basically defined +# by the device implementer. Here, we are adding a mandatory tag that +# identifies the signing config of the build. BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) ifeq ($(TARGET_BUILD_TYPE),debug) BUILD_VERSION_TAGS += debug @@ -148,11 +127,8 @@ endif BUILD_VERSION_TAGS += $(BUILD_KEYS) BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) -# A human-readable string that descibes this build in detail. -build_desc := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS) -$(intermediate_system_build_prop): PRIVATE_BUILD_DESC := $(build_desc) - -# The string used to uniquely identify the combined build and product; used by the OTA server. +# BUILD_FINGERPRINT is used used to uniquely identify the combined build and +# product; used by the OTA server. ifeq (,$(strip $(BUILD_FINGERPRINT))) ifeq ($(strip $(HAS_BUILD_NUMBER)),false) BF_BUILD_NUMBER := $(BUILD_USERNAME)$$($(DATE_FROM_FILE) +%m%d%H%M) @@ -172,8 +148,8 @@ BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE)) # unset it for safety. BUILD_FINGERPRINT := -# The string used to uniquely identify the system build; used by the OTA server. -# This purposefully excludes any product-specific variables. +# BUILD_THUMBPRINT is used to uniquely identify the system build; used by the +# OTA server. This purposefully excludes any product-specific variables. ifeq (,$(strip $(BUILD_THUMBPRINT))) BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) endif @@ -186,14 +162,14 @@ BUILD_THUMBPRINT_FROM_FILE := $$(cat $(BUILD_THUMBPRINT_FILE)) # unset it for safety. BUILD_THUMBPRINT := -KNOWN_OEM_THUMBPRINT_PROPERTIES := \ - ro.product.brand \ - ro.product.name \ - ro.product.device -OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ - $(PRODUCT_OEM_PROPERTIES)) +# ----------------------------------------------------------------- +# Define human readable strings that describe this build +# + +# BUILD_ID: detail info; has the same info as the build fingerprint +BUILD_DESC := $(TARGET_PRODUCT)-$(TARGET_BUILD_VARIANT) $(PLATFORM_VERSION) $(BUILD_ID) $(BUILD_NUMBER_FROM_FILE) $(BUILD_VERSION_TAGS) -# Display parameters shown under Settings -> About Phone +# BUILD_DISPLAY_ID is shown under Settings -> About Phone ifeq ($(TARGET_BUILD_VARIANT),user) # User builds should show: # release build number or branch.buld_number non-release builds @@ -206,17 +182,9 @@ ifeq ($(TARGET_BUILD_VARIANT),user) endif else # Non-user builds should show detailed build information - BUILD_DISPLAY_ID := $(build_desc) + BUILD_DISPLAY_ID := $(BUILD_DESC) endif -# Accepts a whitespace separated list of product locales such as -# (en_US en_AU en_GB...) and returns the first locale in the list with -# underscores replaced with hyphens. In the example above, this will -# return "en-US". -define get-default-product-locale -$(strip $(subst _,-, $(firstword $(1)))) -endef - # TARGET_BUILD_FLAVOR and ro.build.flavor are used only by the test # harness to distinguish builds. Only add _asan for a sanitized build # if it isn't already a part of the flavor (via a dedicated lunch @@ -228,31 +196,36 @@ TARGET_BUILD_FLAVOR := $(TARGET_BUILD_FLAVOR)_asan endif endif -ifdef TARGET_SYSTEM_PROP -system_prop_file := $(TARGET_SYSTEM_PROP) -else -system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) -endif -$(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: $@ - @mkdir -p $(dir $@) - $(hide) rm -f $@ && touch $@ - $(hide) $(foreach line,$(FINAL_DEFAULT_PROPERTIES), \ - echo "$(line)" >> $@;) -ifneq ($(PRODUCT_OEM_PROPERTIES),) - $(hide) echo "#" >> $@; \ - echo "# PRODUCT_OEM_PROPERTIES" >> $@; \ - echo "#" >> $@; - $(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \ - echo "import /oem/oem.prop $(prop)" >> $@;) -endif - $(hide) $(call generate-common-build-props,system,$@) +KNOWN_OEM_THUMBPRINT_PROPERTIES := \ + ro.product.brand \ + ro.product.name \ + ro.product.device +OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ + $(PRODUCT_OEM_PROPERTIES)) +KNOWN_OEM_THUMBPRINT_PROPERTIES:= + +# ----------------------------------------------------------------- +# system/build.prop +# +# Note: parts of this file that can't be generated by the build-properties +# macro are manually created as separate files and then fed into the macro + +# Accepts a whitespace separated list of product locales such as +# (en_US en_AU en_GB...) and returns the first locale in the list with +# underscores replaced with hyphens. In the example above, this will +# return "en-US". +define get-default-product-locale +$(strip $(subst _,-, $(firstword $(1)))) +endef + +gen_from_buildinfo_sh := $(call intermediates-dir-for,ETC,system_build_prop)/buildinfo.prop +$(gen_from_buildinfo_sh): $(INTERNAL_BUILD_ID_MAKEFILE) $(API_FINGERPRINT) $(hide) TARGET_BUILD_TYPE="$(TARGET_BUILD_VARIANT)" \ TARGET_BUILD_FLAVOR="$(TARGET_BUILD_FLAVOR)" \ TARGET_DEVICE="$(TARGET_DEVICE)" \ PRODUCT_DEFAULT_LOCALE="$(call get-default-product-locale,$(PRODUCT_LOCALES))" \ PRODUCT_DEFAULT_WIFI_CHANNELS="$(PRODUCT_DEFAULT_WIFI_CHANNELS)" \ - PRIVATE_BUILD_DESC="$(PRIVATE_BUILD_DESC)" \ + PRIVATE_BUILD_DESC="$(BUILD_DESC)" \ BUILD_ID="$(BUILD_ID)" \ BUILD_DISPLAY_ID="$(BUILD_DISPLAY_ID)" \ DATE="$(DATE_FROM_FILE)" \ @@ -277,31 +250,53 @@ endif TARGET_CPU_ABI_LIST_64_BIT="$(TARGET_CPU_ABI_LIST_64_BIT)" \ TARGET_CPU_ABI="$(TARGET_CPU_ABI)" \ TARGET_CPU_ABI2="$(TARGET_CPU_ABI2)" \ - bash $(BUILDINFO_SH) >> $@ - $(hide) $(foreach file,$(system_prop_file), \ - if [ -f "$(file)" ]; then \ - echo Target buildinfo from: "$(file)"; \ - echo "" >> $@; \ - echo "#" >> $@; \ - echo "# from $(file)" >> $@; \ - echo "#" >> $@; \ - cat $(file) >> $@; \ - echo "# end of $(file)" >> $@; \ - fi;) - $(if $(FINAL_BUILD_PROPERTIES), \ - $(hide) echo >> $@; \ - echo "#" >> $@; \ - echo "# ADDITIONAL_SYSTEM_PROPERTIES" >> $@; \ - echo "#" >> $@; ) - $(hide) $(foreach line,$(FINAL_BUILD_PROPERTIES), \ - echo "$(line)" >> $@;) - $(hide) $(POST_PROCESS_PROPS) $@ $(PRODUCT_SYSTEM_PROPERTY_BLACKLIST) - -build_desc := - -$(INSTALLED_BUILD_PROP_TARGET): $(intermediate_system_build_prop) - @echo "Target build info: $@" - $(hide) grep -v 'ro.product.first_api_level' $(intermediate_system_build_prop) > $@ + bash $(BUILDINFO_SH) > $@ + +ifneq ($(PRODUCT_OEM_PROPERTIES),) +import_oem_prop := $(call intermediates-dir-for,ETC,system_build_prop)/oem.prop + +$(import_oem_prop): + $(hide) echo "#" >> $@; \ + echo "# PRODUCT_OEM_PROPERTIES" >> $@; \ + echo "#" >> $@; + $(hide) $(foreach prop,$(PRODUCT_OEM_PROPERTIES), \ + echo "import /oem/oem.prop $(prop)" >> $@;) +else +import_oem_prop := +endif + +ifdef TARGET_SYSTEM_PROP +system_prop_file := $(TARGET_SYSTEM_PROP) +else +system_prop_file := $(wildcard $(TARGET_DEVICE_DIR)/system.prop) +endif + +_prop_files_ := \ + $(import_oem_prop) \ + $(gen_from_buildinfo_sh) \ + $(system_prop_file) + +# 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_ := \ + ADDITIONAL_SYSTEM_PROPERTIES \ + PRODUCT_SYSTEM_DEFAULT_PROPERTIES + +ifndef property_overrides_split_enabled +_prop_vars_ += \ + ADDITIONAL_VENDOR_PROPERTIES +endif + +_blacklist_names_ := \ + $(PRODUCT_SYSTEM_PROPERTY_BLACKLIST) \ + ro.product.first_api_level + +INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop + +$(eval $(call build-properties,system,$(INSTALLED_BUILD_PROP_TARGET),\ +$(_prop_files_),$(_prop_vars_),\ +$(_blacklist_names_))) + # ----------------------------------------------------------------- # vendor/build.prop |