blob: a96ea8fed352cff4a0f40c9d146fadef23b60d84 [file] [log] [blame]
Joe Onorato63a84552023-06-29 14:34:18 -07001# Copyright (C) 2023 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15#
16# This file is included by build/make/core/Makefile, and contains the logic for
17# the combined flags files.
18#
19
20# TODO: Should we do all of the images in $(IMAGES_TO_BUILD)?
21_FLAG_PARTITIONS := product system system_ext vendor
22
23
24# -----------------------------------------------------------------
Joe Onorato63a84552023-06-29 14:34:18 -070025# Aconfig Flags
26
27# Create a summary file of build flags for each partition
Ted Bauer98bedd82023-09-14 15:28:12 +000028# $(1): built aconfig flags file (out)
29# $(2): installed aconfig flags file (out)
Joe Onorato63a84552023-06-29 14:34:18 -070030# $(3): input aconfig files for the partition (in)
31define generate-partition-aconfig-flag-file
32$(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1)))
33$(eval $(strip $(1)): PRIVATE_IN := $(strip $(3)))
Joe Onoratob2093492023-08-19 19:00:04 -070034$(strip $(1)): $(ACONFIG) $(strip $(3))
Joe Onorato63a84552023-06-29 14:34:18 -070035 mkdir -p $$(dir $$(PRIVATE_OUT))
36 $$(if $$(PRIVATE_IN), \
Colin Cross706b0c32023-12-05 16:39:20 -080037 $$(ACONFIG) dump --dedup --format protobuf --out $$(PRIVATE_OUT) \
Joe Onorato63a84552023-06-29 14:34:18 -070038 $$(addprefix --cache ,$$(PRIVATE_IN)), \
Ted Bauerc0d16592023-11-01 16:03:51 +000039 echo -n > $$(PRIVATE_OUT) \
Joe Onorato63a84552023-06-29 14:34:18 -070040 )
41$(call copy-one-file, $(1), $(2))
42endef
43
44
45$(foreach partition, $(_FLAG_PARTITIONS), \
Ted Bauer98bedd82023-09-14 15:28:12 +000046 $(eval aconfig_flag_summaries_protobuf.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig_flags.pb) \
Joe Onorato63a84552023-06-29 14:34:18 -070047 $(eval $(call generate-partition-aconfig-flag-file, \
Ted Bauer98bedd82023-09-14 15:28:12 +000048 $(TARGET_OUT_FLAGS)/$(partition)/aconfig_flags.pb, \
49 $(aconfig_flag_summaries_protobuf.$(partition)), \
50 $(sort $(foreach m,$(call register-names-for-partition, $(partition)), \
51 $(ALL_MODULES.$(m).ACONFIG_FILES) \
52 )), \
Joe Onorato63a84552023-06-29 14:34:18 -070053 )) \
54)
55
LaMont Jones2e47c7b2024-01-26 18:23:47 +000056# Collect the on-device flags into a single file, similar to all_aconfig_declarations.
57required_aconfig_flags_files := \
58 $(sort $(foreach partition, $(filter $(IMAGES_TO_BUILD), $(_FLAG_PARTITIONS)), \
59 $(aconfig_flag_summaries_protobuf.$(partition)) \
60 ))
61
62.PHONY: device_aconfig_declarations
63device_aconfig_declarations: $(PRODUCT_OUT)/device_aconfig_declarations.pb
64$(eval $(call generate-partition-aconfig-flag-file, \
65 $(TARGET_OUT_FLAGS)/device_aconfig_declarations.pb, \
66 $(PRODUCT_OUT)/device_aconfig_declarations.pb, \
67 $(sort $(required_aconfig_flags_files)) \
68)) \
69
Dennis Shenc39f3782024-01-12 16:38:04 +000070# Create a set of storage file for each partition
Dennis Shenf2d4c8d2024-01-23 20:50:54 +000071# $(1): built aconfig flags storage package map file (out)
72# $(2): built aconfig flags storage flag map file (out)
73# $(3): built aconfig flags storage flag val file (out)
74# $(4): installed aconfig flags storage package map file (out)
75# $(5): installed aconfig flags storage flag map file (out)
76# $(6): installed aconfig flags storage flag value file (out)
77# $(7): input aconfig files for the partition (in)
Dennis Shen34a21ca2024-03-25 19:56:33 +000078# $(8): partition name
Dennis Shenc39f3782024-01-12 16:38:04 +000079define generate-partition-aconfig-storage-file
Dennis Shenf2d4c8d2024-01-23 20:50:54 +000080$(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1)))
81$(eval $(strip $(1)): PRIVATE_IN := $(strip $(7)))
82$(strip $(1)): $(ACONFIG) $(strip $(7))
83 mkdir -p $$(dir $$(PRIVATE_OUT))
Dennis Shenc39f3782024-01-12 16:38:04 +000084 $$(if $$(PRIVATE_IN), \
Dennis Shen34a21ca2024-03-25 19:56:33 +000085 $$(ACONFIG) create-storage --container $(8) --file package_map --out $$(PRIVATE_OUT) \
Dennis Shenc39f3782024-01-12 16:38:04 +000086 $$(addprefix --cache ,$$(PRIVATE_IN)), \
87 )
Dennis Shenf2d4c8d2024-01-23 20:50:54 +000088 touch $$(PRIVATE_OUT)
89$(eval $(strip $(2)): PRIVATE_OUT := $(strip $(2)))
90$(eval $(strip $(2)): PRIVATE_IN := $(strip $(7)))
91$(strip $(2)): $(ACONFIG) $(strip $(7))
92 mkdir -p $$(dir $$(PRIVATE_OUT))
93 $$(if $$(PRIVATE_IN), \
Dennis Shen34a21ca2024-03-25 19:56:33 +000094 $$(ACONFIG) create-storage --container $(8) --file flag_map --out $$(PRIVATE_OUT) \
Dennis Shenf2d4c8d2024-01-23 20:50:54 +000095 $$(addprefix --cache ,$$(PRIVATE_IN)), \
96 )
97 touch $$(PRIVATE_OUT)
98$(eval $(strip $(3)): PRIVATE_OUT := $(strip $(3)))
99$(eval $(strip $(3)): PRIVATE_IN := $(strip $(7)))
100$(strip $(3)): $(ACONFIG) $(strip $(7))
101 mkdir -p $$(dir $$(PRIVATE_OUT))
102 $$(if $$(PRIVATE_IN), \
Dennis Shen34a21ca2024-03-25 19:56:33 +0000103 $$(ACONFIG) create-storage --container $(8) --file flag_val --out $$(PRIVATE_OUT) \
Dennis Shenf2d4c8d2024-01-23 20:50:54 +0000104 $$(addprefix --cache ,$$(PRIVATE_IN)), \
105 )
106 touch $$(PRIVATE_OUT)
107$(call copy-one-file, $(strip $(1)), $(4))
108$(call copy-one-file, $(strip $(2)), $(5))
109$(call copy-one-file, $(strip $(3)), $(6))
Dennis Shenc39f3782024-01-12 16:38:04 +0000110endef
111
112ifeq ($(RELEASE_CREATE_ACONFIG_STORAGE_FILE),true)
113$(foreach partition, $(_FLAG_PARTITIONS), \
Dennis Shenbebbf542024-02-28 15:26:28 +0000114 $(eval aconfig_storage_package_map.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/package.map) \
115 $(eval aconfig_storage_flag_map.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/flag.map) \
116 $(eval aconfig_storage_flag_val.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/flag.val) \
Dennis Shenc39f3782024-01-12 16:38:04 +0000117 $(eval $(call generate-partition-aconfig-storage-file, \
Dennis Shenf2d4c8d2024-01-23 20:50:54 +0000118 $(TARGET_OUT_FLAGS)/$(partition)/package.map, \
119 $(TARGET_OUT_FLAGS)/$(partition)/flag.map, \
120 $(TARGET_OUT_FLAGS)/$(partition)/flag.val, \
Dennis Shenc39f3782024-01-12 16:38:04 +0000121 $(aconfig_storage_package_map.$(partition)), \
122 $(aconfig_storage_flag_map.$(partition)), \
123 $(aconfig_storage_flag_val.$(partition)), \
124 $(sort $(foreach m,$(call register-names-for-partition, $(partition)), \
125 $(ALL_MODULES.$(m).ACONFIG_FILES) \
126 )), \
Dennis Shen34a21ca2024-03-25 19:56:33 +0000127 $(partition), \
Dennis Shenc39f3782024-01-12 16:38:04 +0000128 )) \
129)
130endif
Joe Onorato63a84552023-06-29 14:34:18 -0700131
132# -----------------------------------------------------------------
133# Install the ones we need for the configured product
134required_flags_files := \
135 $(sort $(foreach partition, $(filter $(IMAGES_TO_BUILD), $(_FLAG_PARTITIONS)), \
136 $(build_flag_summaries.$(partition)) \
Ted Bauer98bedd82023-09-14 15:28:12 +0000137 $(aconfig_flag_summaries_protobuf.$(partition)) \
Dennis Shenc39f3782024-01-12 16:38:04 +0000138 $(aconfig_storage_package_map.$(partition)) \
139 $(aconfig_storage_flag_map.$(partition)) \
140 $(aconfig_storage_flag_val.$(partition)) \
Joe Onorato63a84552023-06-29 14:34:18 -0700141 ))
142
143ALL_DEFAULT_INSTALLED_MODULES += $(required_flags_files)
Wei Li9b4cf432023-08-08 17:26:49 -0700144ALL_FLAGS_FILES := $(required_flags_files)
Joe Onorato63a84552023-06-29 14:34:18 -0700145
146# TODO: Remove
147.PHONY: flag-files
148flag-files: $(required_flags_files)
149
150
151# Clean up
152required_flags_files:=
LaMont Jones2e47c7b2024-01-26 18:23:47 +0000153required_aconfig_flags_files:=
Joe Onorato63a84552023-06-29 14:34:18 -0700154$(foreach partition, $(_FLAG_PARTITIONS), \
155 $(eval build_flag_summaries.$(partition):=) \
Ted Bauer98bedd82023-09-14 15:28:12 +0000156 $(eval aconfig_flag_summaries_protobuf.$(partition):=) \
Dennis Shenc39f3782024-01-12 16:38:04 +0000157 $(eval aconfig_storage_package_map.$(partition):=) \
158 $(eval aconfig_storage_flag_map.$(partition):=) \
159 $(eval aconfig_storage_flag_val.$(partition):=) \
Joe Onorato63a84552023-06-29 14:34:18 -0700160)
161