blob: e4f994f119434f8a894cbe9f215b6dd3754446d4 [file] [log] [blame]
Jiyong Parke1346862020-05-18 14:31:30 +09001#
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
Jiyong Parkc0bd8c72020-06-29 10:46:22 +090017# sysprop.mk defines rules for generating <partition>/[etc/]build.prop files
Jiyong Parke1346862020-05-18 14:31:30 +090018
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
Jiyong Parkae556382020-05-20 18:33:43 +090026POST_PROCESS_PROPS := $(HOST_OUT_EXECUTABLES)/post_process_props$(HOST_EXECUTABLE_SUFFIX)
Jiyong Parke1346862020-05-18 14:31:30 +090027
Jiyong Park35a83d12020-05-26 02:01:05 +090028# Emits a set of sysprops common to all partitions to a file.
Jiyong Parke1346862020-05-18 14:31:30 +090029# $(1): Partition name
30# $(2): Output file name
31define generate-common-build-props
Jiyong Park35a83d12020-05-26 02:01:05 +090032 echo "####################################" >> $(2);\
33 echo "# from generate-common-build-props" >> $(2);\
34 echo "# These properties identify this partition image." >> $(2);\
35 echo "####################################" >> $(2);\
Inseob Kimb97c96b2024-07-31 02:00:41 +000036 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; \
Christopher Ferris66b6fd62022-04-08 15:20:23 -070056 $(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 )\
SzuWei Linbaf5c812020-12-31 16:59:27 +080068 )\
Jiyong Park35a83d12020-05-26 02:01:05 +090069 echo "ro.$(1).build.date=`$(DATE_FROM_FILE)`" >> $(2);\
70 echo "ro.$(1).build.date.utc=`$(DATE_FROM_FILE) +%s`" >> $(2);\
Tiffany Yang19450e32023-05-23 17:36:54 -070071 # 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);\
Jiyong Park35a83d12020-05-26 02:01:05 +090077 echo "ro.$(1).build.type=$(TARGET_BUILD_VARIANT)" >> $(2);\
78 echo "ro.$(1).build.version.incremental=$(BUILD_NUMBER_FROM_FILE)" >> $(2);\
Tianjiee88ac672020-10-15 17:22:48 -070079 echo "ro.$(1).build.version.release=$(PLATFORM_VERSION_LAST_STABLE)" >> $(2);\
80 echo "ro.$(1).build.version.release_or_codename=$(PLATFORM_VERSION)" >> $(2);\
Jiyong Park35a83d12020-05-26 02:01:05 +090081 echo "ro.$(1).build.version.sdk=$(PLATFORM_SDK_VERSION)" >> $(2);\
Jiyong Parke1346862020-05-18 14:31:30 +090082
Jiyong Parke1346862020-05-18 14:31:30 +090083endef
84
Jiyong Parkc0bd8c72020-06-29 10:46:22 +090085# Rule for generating <partition>/[etc/]build.prop file
Jiyong Parke28fa802020-05-26 00:21:20 +090086#
87# $(1): partition name
88# $(2): path to the output
89# $(3): path to the input *.prop files. The contents of the files are directly
90# emitted to the output
91# $(4): list of variable names each of which contains name=value pairs
92# $(5): optional list of prop names to force remove from the output. Properties from both
Alexander Mishkovets5a6bc222020-11-11 15:25:37 +010093# $(3) and (4) are affected
94# $(6): optional list of files to append at the end. The content of each file is emitted
95# to the output
Oleksiy Avramchenkod3d0f7d2020-12-15 14:38:32 +010096# $(7): optional flag to skip common properties generation
Jiyong Parke28fa802020-05-26 00:21:20 +090097define build-properties
98ALL_DEFAULT_INSTALLED_MODULES += $(2)
99
Jiyong Parkd721e872020-06-22 17:30:57 +0900100$(eval # Properties can be assigned using `prop ?= value` or `prop = value` syntax.)
101$(eval # Eliminate spaces around the ?= and = separators.)
Jiyong Parke28fa802020-05-26 00:21:20 +0900102$(foreach name,$(strip $(4)),\
Jiyong Parkd721e872020-06-22 17:30:57 +0900103 $(eval _temp := $$(call collapse-pairs,$$($(name)),?=))\
104 $(eval _resolved_$(name) := $$(call collapse-pairs,$$(_temp),=))\
Jiyong Parke28fa802020-05-26 00:21:20 +0900105)
106
Jiyong Park0b4fccb2020-06-26 17:38:00 +0900107$(eval # Implement the legacy behavior when BUILD_BROKEN_DUP_SYSPROP is on.)
108$(eval # Optional assignments are all converted to normal assignments and)
109$(eval # when their duplicates the first one wins)
110$(if $(filter true,$(BUILD_BROKEN_DUP_SYSPROP)),\
111 $(foreach name,$(strip $(4)),\
112 $(eval _temp := $$(subst ?=,=,$$(_resolved_$(name))))\
113 $(eval _resolved_$(name) := $$(call uniq-pairs-by-first-component,$$(_resolved_$(name)),=))\
114 )\
115 $(eval _option := --allow-dup)\
Jiyong Parke28fa802020-05-26 00:21:20 +0900116)
117
Jiakai Zhang53dd8952024-01-18 17:22:13 +0000118$(2): $(POST_PROCESS_PROPS) $(INTERNAL_BUILD_ID_MAKEFILE) $(3) $(6) $(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC)
Jiyong Parke28fa802020-05-26 00:21:20 +0900119 $(hide) echo Building $$@
120 $(hide) mkdir -p $$(dir $$@)
121 $(hide) rm -f $$@ && touch $$@
Oleksiy Avramchenkod3d0f7d2020-12-15 14:38:32 +0100122ifneq ($(strip $(7)), true)
Jiyong Parke28fa802020-05-26 00:21:20 +0900123 $(hide) $$(call generate-common-build-props,$(call to-lower,$(strip $(1))),$$@)
Oleksiy Avramchenkod3d0f7d2020-12-15 14:38:32 +0100124endif
Spandan Das9ac5a642024-12-12 23:40:27 +0000125 # Make and Soong use different intermediate files to build vendor/build.prop.
126 # Although the sysprop contents are same, the absolute paths of android_info.prop are different.
127 # Print the filename for the intermediate files (files in OUT_DIR).
128 # This helps with validating mk->soong migration of android partitions.
Jiyong Parke28fa802020-05-26 00:21:20 +0900129 $(hide) $(foreach file,$(strip $(3)),\
130 if [ -f "$(file)" ]; then\
131 echo "" >> $$@;\
132 echo "####################################" >> $$@;\
Spandan Das9ac5a642024-12-12 23:40:27 +0000133 $(if $(filter $(OUT_DIR)/%,$(file)), \
134 echo "# from $(notdir $(file))" >> $$@;\
135 ,\
136 echo "# from $(file)" >> $$@;\
137 )\
Jiyong Parke28fa802020-05-26 00:21:20 +0900138 echo "####################################" >> $$@;\
139 cat $(file) >> $$@;\
140 fi;)
141 $(hide) $(foreach name,$(strip $(4)),\
142 echo "" >> $$@;\
143 echo "####################################" >> $$@;\
144 echo "# from variable $(name)" >> $$@;\
145 echo "####################################" >> $$@;\
146 $$(foreach line,$$(_resolved_$(name)),\
147 echo "$$(line)" >> $$@;\
148 )\
149 )
Jiakai Zhang53dd8952024-01-18 17:22:13 +0000150 $(hide) $(POST_PROCESS_PROPS) $$(_option) \
151 --sdk-version $(PLATFORM_SDK_VERSION) \
152 --kernel-version-file-for-uffd-gc "$(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC)" \
153 $$@ $(5)
Alexander Mishkovets5a6bc222020-11-11 15:25:37 +0100154 $(hide) $(foreach file,$(strip $(6)),\
155 if [ -f "$(file)" ]; then\
156 cat $(file) >> $$@;\
157 fi;)
Jiyong Parke28fa802020-05-26 00:21:20 +0900158 $(hide) echo "# end of file" >> $$@
Bob Badoure9bdbc52022-03-10 11:31:07 -0800159
Bob Badour1d31e2d2023-03-01 10:31:25 -0800160$(call declare-1p-target,$(2))
Jiyong Parke28fa802020-05-26 00:21:20 +0900161endef
162
Jiyong Parkbb26c6f2020-05-26 03:18:36 +0900163KNOWN_OEM_THUMBPRINT_PROPERTIES := \
164 ro.product.brand \
165 ro.product.name \
166 ro.product.device
167OEM_THUMBPRINT_PROPERTIES := $(filter $(KNOWN_OEM_THUMBPRINT_PROPERTIES),\
168 $(PRODUCT_OEM_PROPERTIES))
169KNOWN_OEM_THUMBPRINT_PROPERTIES:=
170
171# -----------------------------------------------------------------
172# system/build.prop
173#
Inseob Kimb97c96b2024-07-31 02:00:41 +0000174# system/build.prop is built by Soong. See system-build.prop module in
175# build/soong/Android.bp.
Jiyong Parkbb26c6f2020-05-26 03:18:36 +0900176
Jiyong Parkbb26c6f2020-05-26 03:18:36 +0900177INSTALLED_BUILD_PROP_TARGET := $(TARGET_OUT)/build.prop
178
Jiyong Parke1346862020-05-18 14:31:30 +0900179# -----------------------------------------------------------------
Jiyong Parke28fa802020-05-26 00:21:20 +0900180# vendor/build.prop
Jiyong Parke1346862020-05-18 14:31:30 +0900181#
Jiyong Parke28fa802020-05-26 00:21:20 +0900182_prop_files_ := $(if $(TARGET_VENDOR_PROP),\
183 $(TARGET_VENDOR_PROP),\
184 $(wildcard $(TARGET_DEVICE_DIR)/vendor.prop))
Jiyong Parke1346862020-05-18 14:31:30 +0900185
Jiyong Park3a2e95a2020-05-25 17:56:09 +0900186android_info_prop := $(call intermediates-dir-for,ETC,android_info_prop)/android_info.prop
187$(android_info_prop): $(INSTALLED_ANDROID_INFO_TXT_TARGET)
188 cat $< | grep 'require version-' | sed -e 's/require version-/ro.build.expect./g' > $@
189
Donghyun Jo8c65ef62021-03-02 08:51:03 +0900190_prop_files_ += $(android_info_prop)
Jiyong Park3a2e95a2020-05-25 17:56:09 +0900191
Jiyong Parke1346862020-05-18 14:31:30 +0900192ifdef property_overrides_split_enabled
Jiyong Parke28fa802020-05-26 00:21:20 +0900193# Order matters here. When there are duplicates, the last one wins.
194# TODO(b/117892318): don't allow duplicates so that the ordering doesn't matter
195_prop_vars_ := \
196 ADDITIONAL_VENDOR_PROPERTIES \
Jiyong Parkeb49b342020-05-29 17:50:03 +0900197 PRODUCT_VENDOR_PROPERTIES
198
199# TODO(b/117892318): deprecate this
200_prop_vars_ += \
201 PRODUCT_DEFAULT_PROPERTY_OVERRIDES \
Jiyong Parke28fa802020-05-26 00:21:20 +0900202 PRODUCT_PROPERTY_OVERRIDES
Jiyong Parke1346862020-05-18 14:31:30 +0900203else
Jiyong Parke28fa802020-05-26 00:21:20 +0900204_prop_vars_ :=
Jiyong Parke1346862020-05-18 14:31:30 +0900205endif
206
Jiyong Parke28fa802020-05-26 00:21:20 +0900207INSTALLED_VENDOR_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR)/build.prop
208$(eval $(call build-properties,\
209 vendor,\
210 $(INSTALLED_VENDOR_BUILD_PROP_TARGET),\
211 $(_prop_files_),\
212 $(_prop_vars_),\
Alexander Mishkovets5a6bc222020-11-11 15:25:37 +0100213 $(PRODUCT_VENDOR_PROPERTY_BLACKLIST),\
Oleksiy Avramchenkod3d0f7d2020-12-15 14:38:32 +0100214 $(empty),\
Alexander Mishkovets5a6bc222020-11-11 15:25:37 +0100215 $(empty)))
Jiyong Parke1346862020-05-18 14:31:30 +0900216
Bob Badour70c07dd2022-02-12 15:39:22 -0800217$(eval $(call declare-1p-target,$(INSTALLED_VENDOR_BUILD_PROP_TARGET)))
218
Jiyong Parke28fa802020-05-26 00:21:20 +0900219# -----------------------------------------------------------------
Jiyong Parkc0bd8c72020-06-29 10:46:22 +0900220# product/etc/build.prop
Jiyong Parke28fa802020-05-26 00:21:20 +0900221#
Inseob Kimd05947d2024-08-08 17:48:43 +0900222# product/etc/build.prop is built by Soong. See product-build.prop module in
223# build/soong/Android.bp.
Jiyong Parke28fa802020-05-26 00:21:20 +0900224
Jiyong Parkc0bd8c72020-06-29 10:46:22 +0900225INSTALLED_PRODUCT_BUILD_PROP_TARGET := $(TARGET_OUT_PRODUCT)/etc/build.prop
Alexander Mishkovets5a6bc222020-11-11 15:25:37 +0100226
Jiyong Parke1346862020-05-18 14:31:30 +0900227# ----------------------------------------------------------------
Jiyong Park62117c82020-06-26 09:56:31 +0900228# odm/etc/build.prop
Jiyong Parke28fa802020-05-26 00:21:20 +0900229#
Inseob Kimd05947d2024-08-08 17:48:43 +0900230# odm/etc/build.prop is built by Soong. See odm-build.prop module in
231# build/soong/Android.bp.
Jiyong Parke1346862020-05-18 14:31:30 +0900232
Jiyong Park62117c82020-06-26 09:56:31 +0900233INSTALLED_ODM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM)/etc/build.prop
Bob Badour70c07dd2022-02-12 15:39:22 -0800234
Yifan Hong51a971b2020-06-25 17:00:27 -0700235# ----------------------------------------------------------------
236# vendor_dlkm/etc/build.prop
Spandan Das27443562024-11-06 22:12:11 +0000237# odm_dlkm/etc/build.prop
238# system_dlkm/build.prop
239# These are built by Soong. See build/soong/Android.bp
Yifan Hong51a971b2020-06-25 17:00:27 -0700240
241INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_VENDOR_DLKM)/etc/build.prop
Yifan Hong81a092f2020-07-15 17:02:07 -0700242INSTALLED_ODM_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_ODM_DLKM)/etc/build.prop
Ramji Jiyani13a41372022-01-27 07:05:08 +0000243INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_DLKM)/etc/build.prop
Spandan Das27443562024-11-06 22:12:11 +0000244ALL_DEFAULT_INSTALLED_MODULES += \
245 $(INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET) \
246 $(INSTALLED_ODM_DLKM_BUILD_PROP_TARGET) \
247 $(INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET) \
Bob Badour70c07dd2022-02-12 15:39:22 -0800248
Jiyong Parke1346862020-05-18 14:31:30 +0900249# -----------------------------------------------------------------
Jiyong Parkc0bd8c72020-06-29 10:46:22 +0900250# system_ext/etc/build.prop
Jiyong Parke28fa802020-05-26 00:21:20 +0900251#
Inseob Kimd05947d2024-08-08 17:48:43 +0900252# system_ext/etc/build.prop is built by Soong. See system-build.prop module in
Inseob Kim6dbd7eb2024-08-05 12:50:01 +0900253# build/soong/Android.bp.
Jiyong Parke28fa802020-05-26 00:21:20 +0900254
Jiyong Parkc0bd8c72020-06-29 10:46:22 +0900255INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET := $(TARGET_OUT_SYSTEM_EXT)/etc/build.prop
Bob Badour70c07dd2022-02-12 15:39:22 -0800256
Yifan Hong33fd5d42020-09-24 18:18:26 -0700257RAMDISK_BUILD_PROP_REL_PATH := system/etc/ramdisk/build.prop
Cole Faust5f84cf72024-11-12 15:15:30 -0800258ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
259INSTALLED_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/$(RAMDISK_BUILD_PROP_REL_PATH)
260else
Yifan Hong33fd5d42020-09-24 18:18:26 -0700261INSTALLED_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RAMDISK_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
Cole Faust5f84cf72024-11-12 15:15:30 -0800262endif
Wei Li49933362023-01-04 17:13:47 -0800263
264ALL_INSTALLED_BUILD_PROP_FILES := \
265 $(INSTALLED_BUILD_PROP_TARGET) \
266 $(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
267 $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
268 $(INSTALLED_ODM_BUILD_PROP_TARGET) \
269 $(INSTALLED_VENDOR_DLKM_BUILD_PROP_TARGET) \
270 $(INSTALLED_ODM_DLKM_BUILD_PROP_TARGET) \
271 $(INSTALLED_SYSTEM_DLKM_BUILD_PROP_TARGET) \
272 $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) \
273 $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
274
275# $1 installed file path, e.g. out/target/product/vsoc_x86_64/system/build.prop
276define is-build-prop
277$(if $(findstring $1,$(ALL_INSTALLED_BUILD_PROP_FILES)),Y)
Tiffany Yang19450e32023-05-23 17:36:54 -0700278endef