1# 2# Copyright (C) 2020 The Android Open Source Project 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16 17# sysprop.mk defines rules for generating <partition>/[etc/]build.prop files 18 19# ----------------------------------------------------------------- 20# property_overrides_split_enabled 21property_overrides_split_enabled := 22ifeq ($(BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED), true) 23 property_overrides_split_enabled := true 24endif 25 26POST_PROCESS_PROPS := $(HOST_OUT_EXECUTABLES)/post_process_props$(HOST_EXECUTABLE_SUFFIX) 27 28# Emits a set of sysprops common to all partitions to a file. 29# $(1): Partition name 30# $(2): Output file name 31define generate-common-build-props 32 echo "####################################" >> $(2);\ 33 echo "# from generate-common-build-props" >> $(2);\ 34 echo "# These properties identify this partition image." >> $(2);\ 35 echo "####################################" >> $(2);\ 36 echo "ro.product.$(1).brand=$(PRODUCT_BRAND)" >> $(2);\ 37 echo "ro.product.$(1).device=$(TARGET_DEVICE)" >> $(2);\ 38 echo "ro.product.$(1).manufacturer=$(PRODUCT_MANUFACTURER)" >> $(2);\ 39 echo "ro.product.$(1).model=$(PRODUCT_MODEL)" >> $(2);\ 40 echo "ro.product.$(1).name=$(TARGET_PRODUCT)" >> $(2);\ 41 if [ -n "$(strip $(PRODUCT_MODEL_FOR_ATTESTATION))" ]; then \ 42 echo "ro.product.model_for_attestation=$(PRODUCT_MODEL_FOR_ATTESTATION)" >> $(2);\ 43 fi; \ 44 if [ -n "$(strip $(PRODUCT_BRAND_FOR_ATTESTATION))" ]; then \ 45 echo "ro.product.brand_for_attestation=$(PRODUCT_BRAND_FOR_ATTESTATION)" >> $(2);\ 46 fi; \ 47 if [ -n "$(strip $(PRODUCT_NAME_FOR_ATTESTATION))" ]; then \ 48 echo "ro.product.name_for_attestation=$(PRODUCT_NAME_FOR_ATTESTATION)" >> $(2);\ 49 fi; \ 50 if [ -n "$(strip $(PRODUCT_DEVICE_FOR_ATTESTATION))" ]; then \ 51 echo "ro.product.device_for_attestation=$(PRODUCT_DEVICE_FOR_ATTESTATION)" >> $(2);\ 52 fi; \ 53 if [ -n "$(strip $(PRODUCT_MANUFACTURER_FOR_ATTESTATION))" ]; then \ 54 echo "ro.product.manufacturer_for_attestation=$(PRODUCT_MANUFACTURER_FOR_ATTESTATION)" >> $(2);\ 55 fi; \ 56 $(if $(filter true,$(ZYGOTE_FORCE_64)),\ 57 $(if $(filter vendor,$(1)),\ 58 echo "ro.$(1).product.cpu.abilist=$(TARGET_CPU_ABI_LIST_64_BIT)" >> $(2);\ 59 echo "ro.$(1).product.cpu.abilist32=" >> $(2);\ 60 echo "ro.$(1).product.cpu.abilist64=$(TARGET_CPU_ABI_LIST_64_BIT)" >> $(2);\ 61 )\ 62 ,\ 63 $(if $(filter system vendor odm,$(1)),\ 64 echo "ro.$(1).product.cpu.abilist=$(TARGET_CPU_ABI_LIST)" >> $(2);\ 65 echo "ro.$(1).product.cpu.abilist32=$(TARGET_CPU_ABI_LIST_32_BIT)" >> $(2);\ 66 echo "ro.$(1).product.cpu.abilist64=$(TARGET_CPU_ABI_LIST_64_BIT)" >> $(2);\ 67 )\ 68 )\ 69 echo "ro.$(1).build.date=`$(DATE_FROM_FILE)`" >> $(2);\ 70 echo "ro.$(1).build.date.utc=`$(DATE_FROM_FILE) +%s`" >> $(2);\ 71 # Allow optional assignments for ARC forward-declarations (b/249168657) 72 # TODO: Remove any tag-related inconsistencies once the goals from 73 # go/arc-android-sigprop-changes have been achieved. 74 echo "ro.$(1).build.fingerprint?=$(BUILD_FINGERPRINT_FROM_FILE)" >> $(2);\ 75 echo "ro.$(1).build.id?=$(BUILD_ID)" >> $(2);\ 76 echo "ro.$(1).build.tags?=$(BUILD_VERSION_TAGS)" >> $(2);\ 77 echo "ro.$(1).build.type=$(TARGET_BUILD_VARIANT)" >> $(2);\ 78 echo "ro.$(1).build.version.incremental=$(BUILD_NUMBER_FROM_FILE)" >> $(2);\ 79 echo "ro.$(1).build.version.release=$(PLATFORM_VERSION_LAST_STABLE)" >> $(2);\ 80 echo "ro.$(1).build.version.release_or_codename=$(PLATFORM_VERSION)" >> $(2);\ 81 echo "ro.$(1).build.version.sdk=$(PLATFORM_SDK_VERSION)" >> $(2);\ 82 echo "ro.$(1).build.version.sdk_minor=$(PLATFORM_SDK_MINOR_VERSION)" >> $(2);\ 83 84endef 85 86# Rule for generating <partition>/[etc/]build.prop file 87# 88# $(1): partition name 89# $(2): path to the output 90# $(3): path to the input *.prop files. The contents of the files are directly 91# emitted to the output 92# $(4): list of variable names each of which contains name=value pairs 93# $(5): optional list of prop names to force remove from the output. Properties from both 94# $(3) and (4) are affected 95# $(6): optional list of files to append at the end. The content of each file is emitted 96# to the output 97# $(7): optional flag to skip common properties generation 98define build-properties 99ALL_DEFAULT_INSTALLED_MODULES += $(2) 100 101$(eval # Properties can be assigned using `prop ?= value` or `prop = value` syntax.) 102$(eval # Eliminate spaces around the ?= and = separators.) 103$(foreach name,$(strip $(4)),\ 104 $(eval _temp := $$(call collapse-pairs,$$($(name)),?=))\ 105 $(eval _resolved_$(name) := $$(call collapse-pairs,$$(_temp),=))\ 106) 107 108$(eval # Implement the legacy behavior when BUILD_BROKEN_DUP_SYSPROP is on.) 109$(eval # Optional assignments are all converted to normal assignments and) 110$(eval # when their duplicates the first one wins) 111$(if $(filter true,$(BUILD_BROKEN_DUP_SYSPROP)),\ 112 $(foreach name,$(strip $(4)),\ 113 $(eval _temp := $$(subst ?=,=,$$(_resolved_$(name))))\ 114 $(eval _resolved_$(name) := $$(call uniq-pairs-by-first-component,$$(_resolved_$(name)),=))\ 115 )\ 116 $(eval _option := --allow-dup)\ 117) 118 119$(2): $(POST_PROCESS_PROPS) $(INTERNAL_BUILD_ID_MAKEFILE) $(3) $(6) $(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC) 120 $(hide) echo Building $$@ 121 $(hide) mkdir -p $$(dir $$@) 122 $(hide) rm -f $$@ && touch $$@ 123ifneq ($(strip $(7)), true) 124 $(hide) $$(call generate-common-build-props,$(call to-lower,$(strip $(1))),$$@) 125endif 126 $(hide) $(foreach file,$(strip $(3)),\ 127 if [ -f "$(file)" ]; then\ 128 echo "" >> $$@;\ 129 echo "####################################" >> $$@;\ 130 echo "# from $(file)" >> $$@;\ 131 echo "####################################" >> $$@;\ 132 cat $(file) >> $$@;\ 133 fi;) 134 $(hide) $(foreach name,$(strip $(4)),\ 135 echo "" >> $$@;\ 136 echo "####################################" >> $$@;\ 137 echo "# from variable $(name)" >> $$@;\ 138 echo "####################################" >> $$@;\ 139 $$(foreach line,$$(_resolved_$(name)),\ 140 echo "$$(line)" >> $$@;\ 141 )\ 142 ) 143 $(hide) $(POST_PROCESS_PROPS) $$(_option) \ 144 --sdk-version $(PLATFORM_SDK_VERSION) \ 145 --kernel-version-file-for-uffd-gc "$(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC)" \ 146 $$@ $(5) 147 $(hide) $(foreach file,$(strip $(6)),\ 148 if [ -f "$(file)" ]; then\ 149 cat $(file) >> $$@;\ 150 fi;) 151 $(hide) echo "# end of file" >> $$@ 152 153$(call declare-1p-target,$(2)) 154endef 155 156# ----------------------------------------------------------------- 157# Define fingerprint, thumbprint, and version tags for the current build 158# 159# BUILD_VERSION_TAGS is a comma-separated list of tags chosen by the device 160# implementer that further distinguishes the build. It's basically defined 161# by the device implementer. Here, we are adding a mandatory tag that 162# identifies the signing config of the build. 163BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS) 164ifeq ($(TARGET_BUILD_TYPE),debug) 165 BUILD_VERSION_TAGS += debug 166endif 167# The "test-keys" tag marks builds signed with the old test keys, 168# which are available in the SDK. "dev-keys" marks builds signed with 169# non-default dev keys (usually private keys from a vendor directory). 170# Both of these tags will be removed and replaced with "release-keys" 171# when the target-files is signed in a post-build step. 172ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/testkey) 173BUILD_KEYS := test-keys 174else 175BUILD_KEYS := dev-keys 176endif 177BUILD_VERSION_TAGS += $(BUILD_KEYS) 178BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS))) 179 180# BUILD_FINGERPRINT is used used to uniquely identify the combined build and 181# product; used by the OTA server. 182ifeq (,$(strip $(BUILD_FINGERPRINT))) 183 BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 184endif 185 186BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt 187ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE).tmp && (if ! cmp -s $(BUILD_FINGERPRINT_FILE).tmp $(BUILD_FINGERPRINT_FILE); then mv $(BUILD_FINGERPRINT_FILE).tmp $(BUILD_FINGERPRINT_FILE); else rm $(BUILD_FINGERPRINT_FILE).tmp; fi) && grep " " $(BUILD_FINGERPRINT_FILE))) 188 $(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))") 189endif 190BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE)) 191# unset it for safety. 192BUILD_FINGERPRINT := 193 194# BUILD_THUMBPRINT is used to uniquely identify the system build; used by the 195# OTA server. This purposefully excludes any product-specific variables. 196ifeq (,$(strip $(BUILD_THUMBPRINT))) 197 BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS) 198endif 199 200BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt 201ifeq ($(strip $(HAS_BUILD_NUMBER)),true) 202$(BUILD_THUMBPRINT_FILE): $(BUILD_NUMBER_FILE) 203endif 204ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE))) 205 $(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))") 206endif 207# unset it for safety. 208BUILD_THUMBPRINT_FILE := 209BUILD_THUMBPRINT := 210 211KNOWN_OEM_THUMBPRINT_PROPERTIES := \ 212 ro.product.brand \ 213 ro.product.name \ 214 ro.product.device 215OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\ 216 $(PRODUCT_OEM_PROPERTIES)) 217KNOWN_OEM_THUMBPRINT_PROPERTIES:= 218 219# ----------------------------------------------------------------- 220# system/build.prop 221# 222# system/build.prop is built by Soong. See system-build.prop module in 223# build/soong/Android.bp. 224 225INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop 226 227# ----------------------------------------------------------------- 228# vendor/build.prop 229# 230_prop_files_ := $(if $(TARGET_VENDOR_PROP),\ 231 $(TARGET_VENDOR_PROP),\ 232 $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop)) 233 234android_info_prop := $(call intermediates-dir-for,ETC,android_info_prop)/android_info.prop 235$(android_info_prop): $(INSTALLED_ANDROID_INFO_TXT_TARGET) 236 cat $< | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' > $@ 237 238_prop_files_ += $(android_info_prop) 239 240ifdef property_overrides_split_enabled 241# Order matters here. When there are duplicates, the last one wins. 242# TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter 243_prop_vars_ := \ 244 ADDITIONAL_VENDOR_PROPERTIES \ 245 PRODUCT_VENDOR_PROPERTIES 246 247# TODO(b/117892318): deprecate this 248_prop_vars_ += \ 249 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \ 250 PRODUCT_PROPERTY_OVERRIDES 251else 252_prop_vars_ := 253endif 254 255INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop 256$(eval $(call build-properties,\ 257 vendor,\ 258 $(INSTALLED_VENDOR_BUILD_PROP_TARGET),\ 259 $(_prop_files_),\ 260 $(_prop_vars_),\ 261 $(PRODUCT_VENDOR_PROPERTY_BLACKLIST),\ 262 $(empty),\ 263 $(empty))) 264 265$(eval $(call declare-1p-target,$(INSTALLED_VENDOR_BUILD_PROP_TARGET))) 266 267# ----------------------------------------------------------------- 268# product/etc/build.prop 269# 270# product/etc/build.prop is built by Soong. See product-build.prop module in 271# build/soong/Android.bp. 272 273INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/etc/build.prop 274 275# ---------------------------------------------------------------- 276# odm/etc/build.prop 277# 278# odm/etc/build.prop is built by Soong. See odm-build.prop module in 279# build/soong/Android.bp. 280 281INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop 282 283# ---------------------------------------------------------------- 284# vendor_dlkm/etc/build.prop 285# odm_dlkm/etc/build.prop 286# system_dlkm/build.prop 287# These are built by Soong. See build/soong/Android.bp 288 289INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR_DLKM)/etc/build.prop 290INSTALLED_ODM_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM_DLKM)/etc/build.prop 291INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_DLKM)/etc/build.prop 292ALL_DEFAULT_INSTALLED_MODULES += \ 293 $(INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET) \ 294 $(INSTALLED_ODM_DLKM_BUILD_PROP_TARGET) \ 295 $(INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET) \ 296 297# ----------------------------------------------------------------- 298# system_ext/etc/build.prop 299# 300# system_ext/etc/build.prop is built by Soong. See system-build.prop module in 301# build/soong/Android.bp. 302 303INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/etc/build.prop 304 305RAMDISK_BUILD_PROP_REL_PATH := system/etc/ramdisk/build.prop 306ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT)) 307INSTALLED_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/$(RAMDISK_BUILD_PROP_REL_PATH) 308else 309INSTALLED_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RAMDISK_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH) 310endif 311 312ALL_INSTALLED_BUILD_PROP_FILES := \ 313 $(INSTALLED_BUILD_PROP_TARGET) \ 314 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \ 315 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \ 316 $(INSTALLED_ODM_BUILD_PROP_TARGET) \ 317 $(INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET) \ 318 $(INSTALLED_ODM_DLKM_BUILD_PROP_TARGET) \ 319 $(INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET) \ 320 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) \ 321 $(INSTALLED_RAMDISK_BUILD_PROP_TARGET) 322 323# $1 installed file path, e.g. out/target/product/vsoc_x86_64/system/build.prop 324define is-build-prop 325$(if $(findstring $1,$(ALL_INSTALLED_BUILD_PROP_FILES)),Y) 326endef 327