Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 1 | # 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 Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 25 | # Aconfig Flags |
| 26 | |
| 27 | # Create a summary file of build flags for each partition |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 28 | # $(1): built aconfig flags file (out) |
| 29 | # $(2): installed aconfig flags file (out) |
LaMont Jones | acbe15e | 2024-06-26 14:32:51 -0700 | [diff] [blame] | 30 | # $(3): the partition (in) |
| 31 | # $(4): input aconfig files for the partition (in) |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 32 | define generate-partition-aconfig-flag-file |
| 33 | $(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1))) |
LaMont Jones | acbe15e | 2024-06-26 14:32:51 -0700 | [diff] [blame] | 34 | $(eval $(strip $(1)): PRIVATE_IN := $(strip $(4))) |
| 35 | $(strip $(1)): $(ACONFIG) $(strip $(4)) |
| 36 | mkdir -p $$(dir $$(PRIVATE_OUT)) |
| 37 | $$(if $$(PRIVATE_IN), \ |
| 38 | $$(ACONFIG) dump --dedup --format protobuf --out $$(PRIVATE_OUT) \ |
| 39 | --filter container:$$(strip $(3)) $$(addprefix --cache ,$$(PRIVATE_IN)), \ |
| 40 | echo -n > $$(PRIVATE_OUT) \ |
| 41 | ) |
| 42 | $(call copy-one-file, $(1), $(2)) |
| 43 | endef |
| 44 | |
| 45 | # Create a summary file of build flags for each partition |
| 46 | # $(1): built aconfig flags file (out) |
| 47 | # $(2): installed aconfig flags file (out) |
| 48 | # $(3): input aconfig files for the partition (in) |
| 49 | define generate-global-aconfig-flag-file |
| 50 | $(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1))) |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 51 | $(eval $(strip $(1)): PRIVATE_IN := $(strip $(3))) |
Joe Onorato | b209349 | 2023-08-19 19:00:04 -0700 | [diff] [blame] | 52 | $(strip $(1)): $(ACONFIG) $(strip $(3)) |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 53 | mkdir -p $$(dir $$(PRIVATE_OUT)) |
| 54 | $$(if $$(PRIVATE_IN), \ |
Colin Cross | 706b0c3 | 2023-12-05 16:39:20 -0800 | [diff] [blame] | 55 | $$(ACONFIG) dump --dedup --format protobuf --out $$(PRIVATE_OUT) \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 56 | $$(addprefix --cache ,$$(PRIVATE_IN)), \ |
Ted Bauer | c0d1659 | 2023-11-01 16:03:51 +0000 | [diff] [blame] | 57 | echo -n > $$(PRIVATE_OUT) \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 58 | ) |
| 59 | $(call copy-one-file, $(1), $(2)) |
| 60 | endef |
| 61 | |
| 62 | |
| 63 | $(foreach partition, $(_FLAG_PARTITIONS), \ |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 64 | $(eval aconfig_flag_summaries_protobuf.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig_flags.pb) \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 65 | $(eval $(call generate-partition-aconfig-flag-file, \ |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 66 | $(TARGET_OUT_FLAGS)/$(partition)/aconfig_flags.pb, \ |
| 67 | $(aconfig_flag_summaries_protobuf.$(partition)), \ |
LaMont Jones | acbe15e | 2024-06-26 14:32:51 -0700 | [diff] [blame] | 68 | $(partition), \ |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 69 | $(sort $(foreach m,$(call register-names-for-partition, $(partition)), \ |
| 70 | $(ALL_MODULES.$(m).ACONFIG_FILES) \ |
| 71 | )), \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 72 | )) \ |
| 73 | ) |
| 74 | |
LaMont Jones | 2e47c7b | 2024-01-26 18:23:47 +0000 | [diff] [blame] | 75 | # Collect the on-device flags into a single file, similar to all_aconfig_declarations. |
| 76 | required_aconfig_flags_files := \ |
| 77 | $(sort $(foreach partition, $(filter $(IMAGES_TO_BUILD), $(_FLAG_PARTITIONS)), \ |
| 78 | $(aconfig_flag_summaries_protobuf.$(partition)) \ |
| 79 | )) |
| 80 | |
| 81 | .PHONY: device_aconfig_declarations |
| 82 | device_aconfig_declarations: $(PRODUCT_OUT)/device_aconfig_declarations.pb |
LaMont Jones | acbe15e | 2024-06-26 14:32:51 -0700 | [diff] [blame] | 83 | $(eval $(call generate-global-aconfig-flag-file, \ |
LaMont Jones | 2e47c7b | 2024-01-26 18:23:47 +0000 | [diff] [blame] | 84 | $(TARGET_OUT_FLAGS)/device_aconfig_declarations.pb, \ |
| 85 | $(PRODUCT_OUT)/device_aconfig_declarations.pb, \ |
| 86 | $(sort $(required_aconfig_flags_files)) \ |
| 87 | )) \ |
| 88 | |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 89 | # Create a set of storage file for each partition |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 90 | # $(1): built aconfig flags storage package map file (out) |
| 91 | # $(2): built aconfig flags storage flag map file (out) |
| 92 | # $(3): built aconfig flags storage flag val file (out) |
| 93 | # $(4): installed aconfig flags storage package map file (out) |
| 94 | # $(5): installed aconfig flags storage flag map file (out) |
| 95 | # $(6): installed aconfig flags storage flag value file (out) |
| 96 | # $(7): input aconfig files for the partition (in) |
Dennis Shen | 34a21ca | 2024-03-25 19:56:33 +0000 | [diff] [blame] | 97 | # $(8): partition name |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 98 | define generate-partition-aconfig-storage-file |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 99 | $(eval $(strip $(1)): PRIVATE_OUT := $(strip $(1))) |
| 100 | $(eval $(strip $(1)): PRIVATE_IN := $(strip $(7))) |
| 101 | $(strip $(1)): $(ACONFIG) $(strip $(7)) |
| 102 | mkdir -p $$(dir $$(PRIVATE_OUT)) |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 103 | $$(if $$(PRIVATE_IN), \ |
Dennis Shen | 34a21ca | 2024-03-25 19:56:33 +0000 | [diff] [blame] | 104 | $$(ACONFIG) create-storage --container $(8) --file package_map --out $$(PRIVATE_OUT) \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 105 | $$(addprefix --cache ,$$(PRIVATE_IN)), \ |
| 106 | ) |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 107 | touch $$(PRIVATE_OUT) |
| 108 | $(eval $(strip $(2)): PRIVATE_OUT := $(strip $(2))) |
| 109 | $(eval $(strip $(2)): PRIVATE_IN := $(strip $(7))) |
| 110 | $(strip $(2)): $(ACONFIG) $(strip $(7)) |
| 111 | mkdir -p $$(dir $$(PRIVATE_OUT)) |
| 112 | $$(if $$(PRIVATE_IN), \ |
Dennis Shen | 34a21ca | 2024-03-25 19:56:33 +0000 | [diff] [blame] | 113 | $$(ACONFIG) create-storage --container $(8) --file flag_map --out $$(PRIVATE_OUT) \ |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 114 | $$(addprefix --cache ,$$(PRIVATE_IN)), \ |
| 115 | ) |
| 116 | touch $$(PRIVATE_OUT) |
| 117 | $(eval $(strip $(3)): PRIVATE_OUT := $(strip $(3))) |
| 118 | $(eval $(strip $(3)): PRIVATE_IN := $(strip $(7))) |
| 119 | $(strip $(3)): $(ACONFIG) $(strip $(7)) |
| 120 | mkdir -p $$(dir $$(PRIVATE_OUT)) |
| 121 | $$(if $$(PRIVATE_IN), \ |
Dennis Shen | 34a21ca | 2024-03-25 19:56:33 +0000 | [diff] [blame] | 122 | $$(ACONFIG) create-storage --container $(8) --file flag_val --out $$(PRIVATE_OUT) \ |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 123 | $$(addprefix --cache ,$$(PRIVATE_IN)), \ |
| 124 | ) |
| 125 | touch $$(PRIVATE_OUT) |
| 126 | $(call copy-one-file, $(strip $(1)), $(4)) |
| 127 | $(call copy-one-file, $(strip $(2)), $(5)) |
| 128 | $(call copy-one-file, $(strip $(3)), $(6)) |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 129 | endef |
| 130 | |
| 131 | ifeq ($(RELEASE_CREATE_ACONFIG_STORAGE_FILE),true) |
| 132 | $(foreach partition, $(_FLAG_PARTITIONS), \ |
Dennis Shen | bebbf54 | 2024-02-28 15:26:28 +0000 | [diff] [blame] | 133 | $(eval aconfig_storage_package_map.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/package.map) \ |
| 134 | $(eval aconfig_storage_flag_map.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/flag.map) \ |
| 135 | $(eval aconfig_storage_flag_val.$(partition) := $(PRODUCT_OUT)/$(partition)/etc/aconfig/flag.val) \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 136 | $(eval $(call generate-partition-aconfig-storage-file, \ |
Dennis Shen | f2d4c8d | 2024-01-23 20:50:54 +0000 | [diff] [blame] | 137 | $(TARGET_OUT_FLAGS)/$(partition)/package.map, \ |
| 138 | $(TARGET_OUT_FLAGS)/$(partition)/flag.map, \ |
| 139 | $(TARGET_OUT_FLAGS)/$(partition)/flag.val, \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 140 | $(aconfig_storage_package_map.$(partition)), \ |
| 141 | $(aconfig_storage_flag_map.$(partition)), \ |
| 142 | $(aconfig_storage_flag_val.$(partition)), \ |
Zhi Dou | a4b2919 | 2024-07-03 19:41:27 +0000 | [diff] [blame] | 143 | $(aconfig_flag_summaries_protobuf.$(partition)), \ |
Dennis Shen | 34a21ca | 2024-03-25 19:56:33 +0000 | [diff] [blame] | 144 | $(partition), \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 145 | )) \ |
| 146 | ) |
| 147 | endif |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 148 | |
| 149 | # ----------------------------------------------------------------- |
| 150 | # Install the ones we need for the configured product |
| 151 | required_flags_files := \ |
| 152 | $(sort $(foreach partition, $(filter $(IMAGES_TO_BUILD), $(_FLAG_PARTITIONS)), \ |
| 153 | $(build_flag_summaries.$(partition)) \ |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 154 | $(aconfig_flag_summaries_protobuf.$(partition)) \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 155 | $(aconfig_storage_package_map.$(partition)) \ |
| 156 | $(aconfig_storage_flag_map.$(partition)) \ |
| 157 | $(aconfig_storage_flag_val.$(partition)) \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 158 | )) |
| 159 | |
| 160 | ALL_DEFAULT_INSTALLED_MODULES += $(required_flags_files) |
Wei Li | 9b4cf43 | 2023-08-08 17:26:49 -0700 | [diff] [blame] | 161 | ALL_FLAGS_FILES := $(required_flags_files) |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 162 | |
| 163 | # TODO: Remove |
| 164 | .PHONY: flag-files |
| 165 | flag-files: $(required_flags_files) |
| 166 | |
| 167 | |
| 168 | # Clean up |
| 169 | required_flags_files:= |
LaMont Jones | 2e47c7b | 2024-01-26 18:23:47 +0000 | [diff] [blame] | 170 | required_aconfig_flags_files:= |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 171 | $(foreach partition, $(_FLAG_PARTITIONS), \ |
| 172 | $(eval build_flag_summaries.$(partition):=) \ |
Ted Bauer | 98bedd8 | 2023-09-14 15:28:12 +0000 | [diff] [blame] | 173 | $(eval aconfig_flag_summaries_protobuf.$(partition):=) \ |
Dennis Shen | c39f378 | 2024-01-12 16:38:04 +0000 | [diff] [blame] | 174 | $(eval aconfig_storage_package_map.$(partition):=) \ |
| 175 | $(eval aconfig_storage_flag_map.$(partition):=) \ |
| 176 | $(eval aconfig_storage_flag_val.$(partition):=) \ |
Joe Onorato | 63a8455 | 2023-06-29 14:34:18 -0700 | [diff] [blame] | 177 | ) |
| 178 | |