Joe Onorato | 964f401 | 2023-05-06 12:29:01 -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 | |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 15 | |
| 16 | # ----------------------------------------------------------------- |
LaMont Jones | 052282b | 2024-05-16 10:46:49 -0700 | [diff] [blame] | 17 | # Determine which pass this is. |
| 18 | # ----------------------------------------------------------------- |
| 19 | # On the first pass, we are asked for only PRODUCT_RELEASE_CONFIG_MAPS, |
| 20 | # on the second pass, we are asked for whatever else is wanted. |
| 21 | _final_product_config_pass:= |
| 22 | ifneq (PRODUCT_RELEASE_CONFIG_MAPS,$(DUMP_MANY_VARS)) |
| 23 | _final_product_config_pass:=true |
| 24 | endif |
| 25 | |
| 26 | # ----------------------------------------------------------------- |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 27 | # Choose the flag files |
| 28 | # ----------------------------------------------------------------- |
Joe Onorato | 1f65551 | 2023-06-12 23:29:25 -0700 | [diff] [blame] | 29 | # Release configs are defined in reflease_config_map files, which map |
| 30 | # the short name (e.g. -next) used in lunch to the starlark files |
| 31 | # defining the build flag values. |
| 32 | # |
| 33 | # (If you're thinking about aconfig flags, there is one build flag, |
Joe Onorato | 6aa48f8 | 2023-06-21 15:17:42 -0700 | [diff] [blame] | 34 | # RELEASE_ACONFIG_VALUE_SETS, that sets which aconfig_value_set |
Joe Onorato | 1f65551 | 2023-06-12 23:29:25 -0700 | [diff] [blame] | 35 | # module to use to set the aconfig flag values.) |
| 36 | # |
| 37 | # The short release config names *can* appear multiple times, to allow |
| 38 | # for AOSP and vendor specific flags under the same name, but the |
| 39 | # individual flag values must appear in exactly one config. Vendor |
| 40 | # does not override AOSP, or anything like that. This is because |
| 41 | # vendor code usually includes prebuilts, and having vendor compile |
| 42 | # with different flags from AOSP increases the likelihood of flag |
| 43 | # mismatch. |
| 44 | |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 45 | # Do this first, because we're going to unset TARGET_RELEASE before |
| 46 | # including anyone, so they don't start making conditionals based on it. |
| 47 | # This logic is in make because starlark doesn't understand optional |
| 48 | # vendor files. |
| 49 | |
| 50 | # If this is a google source tree, restrict it to only the one file |
| 51 | # which has OWNERS control. If it isn't let others define their own. |
| 52 | # TODO: Remove wildcard for build/release one when all branch manifests |
| 53 | # have updated. |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 54 | _must_protobuf := |
LaMont Jones | 91fa432 | 2024-03-29 14:50:50 -0700 | [diff] [blame] | 55 | config_map_files := $(wildcard build/release/release_config_map.mk) \ |
LaMont Jones | 318dafe | 2024-03-07 17:08:05 -0800 | [diff] [blame] | 56 | $(wildcard vendor/google_shared/build/release/release_config_map.mk) \ |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 57 | $(if $(wildcard vendor/google/release/release_config_map.mk), \ |
| 58 | vendor/google/release/release_config_map.mk, \ |
| 59 | $(sort \ |
| 60 | $(wildcard device/*/release/release_config_map.mk) \ |
| 61 | $(wildcard device/*/*/release/release_config_map.mk) \ |
| 62 | $(wildcard vendor/*/release/release_config_map.mk) \ |
| 63 | $(wildcard vendor/*/*/release/release_config_map.mk) \ |
| 64 | ) \ |
| 65 | ) |
| 66 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 67 | protobuf_map_files := $(wildcard build/release/release_config_map.textproto) \ |
| 68 | $(wildcard vendor/google_shared/build/release/release_config_map.textproto) \ |
| 69 | $(if $(wildcard vendor/google/release/release_config_map.textproto), \ |
| 70 | vendor/google/release/release_config_map.textproto, \ |
| 71 | $(sort \ |
| 72 | $(wildcard device/*/release/release_config_map.textproto) \ |
| 73 | $(wildcard device/*/*/release/release_config_map.textproto) \ |
| 74 | $(wildcard vendor/*/release/release_config_map.textproto) \ |
| 75 | $(wildcard vendor/*/*/release/release_config_map.textproto) \ |
| 76 | ) \ |
| 77 | ) |
| 78 | |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 79 | # PRODUCT_RELEASE_CONFIG_MAPS is set by Soong using an initial run of product |
| 80 | # config to capture only the list of config maps needed by the build. |
| 81 | # Keep them in the order provided, but remove duplicates. |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 82 | # Treat .mk and .textproto as equal for duplicate elimination, but force |
| 83 | # protobuf if any PRODUCT_RELEASE_CONFIG_MAPS specify .textproto. |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 84 | $(foreach map,$(PRODUCT_RELEASE_CONFIG_MAPS), \ |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 85 | $(if $(filter $(basename $(map)),$(basename $(config_map_files))),, \ |
| 86 | $(eval config_map_files += $(map))) \ |
| 87 | $(if $(filter $(basename $(map)).textproto,$(map)),$(eval _must_protobuf := true)) \ |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 88 | ) |
| 89 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 90 | |
| 91 | # If we are missing the textproto version of any of $(config_map_files), we cannot use protobuf. |
| 92 | _can_protobuf := true |
| 93 | $(foreach map,$(config_map_files), \ |
| 94 | $(if $(wildcard $(basename $(map)).textproto),,$(eval _can_protobuf :=)) \ |
| 95 | ) |
| 96 | # If we are missing the mk version of any of $(protobuf_map_files), we must use protobuf. |
| 97 | $(foreach map,$(protobuf_map_files), \ |
| 98 | $(if $(wildcard $(basename $(map)).mk),,$(eval _must_protobuf := true)) \ |
| 99 | ) |
| 100 | |
| 101 | ifneq (,$(_must_protobuf)) |
| 102 | ifeq (,$(_can_protobuf)) |
LaMont Jones | 052282b | 2024-05-16 10:46:49 -0700 | [diff] [blame] | 103 | # We must use protobuf, but we cannot use protobuf. |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 104 | $(error release config is a mixture of .scl and .textproto) |
| 105 | endif |
| 106 | endif |
| 107 | |
| 108 | _use_protobuf := |
| 109 | ifneq (,$(_must_protobuf)) |
| 110 | _use_protobuf := true |
| 111 | else |
| 112 | ifneq ($(_can_protobuf),) |
| 113 | # Determine the default |
| 114 | $(foreach map,$(config_map_files), \ |
| 115 | $(if $(wildcard $(dir $(map))/build_config/DEFAULT=proto),$(eval _use_protobuf := true)) \ |
| 116 | $(if $(wildcard $(dir $(map))/build_config/DEFAULT=make),$(eval _use_protobuf := )) \ |
| 117 | ) |
| 118 | # Update for this specific release config only (no inheritance). |
| 119 | $(foreach map,$(config_map_files), \ |
| 120 | $(if $(wildcard $(dir $(map))/build_config/$(TARGET_RELEASE)=proto),$(eval _use_protobuf := true)) \ |
| 121 | $(if $(wildcard $(dir $(map))/build_config/$(TARGET_RELEASE)=make),$(eval _use_protobuf := )) \ |
| 122 | ) |
| 123 | endif |
| 124 | endif |
| 125 | |
| 126 | ifneq (,$(_use_protobuf)) |
| 127 | # The .textproto files are the canonical source of truth. |
| 128 | _args := $(foreach map,$(config_map_files), --map $(map) ) |
| 129 | ifneq (,$(_must_protobuf)) |
| 130 | # Disable the build flag in release-config. |
| 131 | _args += --guard=false |
| 132 | endif |
LaMont Jones | 052282b | 2024-05-16 10:46:49 -0700 | [diff] [blame] | 133 | _flags_file:=$(OUT_DIR)/soong/release-config/release_config-$(TARGET_PRODUCT)-$(TARGET_RELEASE).vars |
| 134 | # release-config generates $(_flags_varmk) |
| 135 | _flags_varmk:=$(_flags_file:.vars=.varmk) |
| 136 | $(shell $(OUT_DIR)/release-config $(_args) >$(OUT_DIR)/release-config.out 2>&1 && touch -t 200001010000 $(_flags_varmk)) |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 137 | $(if $(filter-out 0,$(.SHELLSTATUS)),$(error release-config failed to run)) |
LaMont Jones | 052282b | 2024-05-16 10:46:49 -0700 | [diff] [blame] | 138 | ifneq (,$(_final_product_config_pass)) |
| 139 | # Save the final version of the config. |
| 140 | $(shell if ! cmp --quiet $(_flags_varmk) $(_flags_file); then cp $(_flags_varmk) $(_flags_file); fi) |
| 141 | # This will also set _all_release_configs and _used_files for us. |
| 142 | $(eval include $(_flags_file)) |
| 143 | $(KATI_extra_file_deps $(OUT_DIR)/release-config $(protobuf_map_files) $(_flags_file)) |
| 144 | else |
| 145 | # This is the first pass of product config. |
| 146 | $(eval include $(_flags_varmk)) |
| 147 | endif |
| 148 | _used_files := |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 149 | ifeq (,$(_must_protobuf)$(RELEASE_BUILD_FLAGS_IN_PROTOBUF)) |
| 150 | _use_protobuf := |
| 151 | endif |
| 152 | endif |
| 153 | ifeq (,$(_use_protobuf)) |
| 154 | # The .mk files are the canonical source of truth. |
| 155 | |
| 156 | |
LaMont Jones | 61b0f79 | 2024-01-30 23:04:02 +0000 | [diff] [blame] | 157 | # Declare an alias release-config |
| 158 | # |
| 159 | # This should be used to declare a release as an alias of another, meaning no |
| 160 | # release config files should be present. |
| 161 | # |
| 162 | # $1 config name |
| 163 | # $2 release config for which it is an alias |
| 164 | define alias-release-config |
| 165 | $(call _declare-release-config,$(1),,$(2),true) |
| 166 | endef |
| 167 | |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 168 | # Declare or extend a release-config. |
| 169 | # |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 170 | # The order of processing is: |
| 171 | # 1. Recursively apply any overridden release configs. Only apply each config |
| 172 | # the first time we reach it. |
| 173 | # 2. Apply any files for this release config, in the order they were added to |
| 174 | # the declaration. |
| 175 | # |
| 176 | # Example: |
| 177 | # With these declarations: |
| 178 | # $(declare-release-config foo, foo.scl) |
| 179 | # $(declare-release-config bar, bar.scl, foo) |
| 180 | # $(declare-release-config baz, baz.scl, bar) |
| 181 | # $(declare-release-config bif, bif.scl, foo baz) |
| 182 | # $(declare-release-config bop, bop.scl, bar baz) |
| 183 | # |
| 184 | # TARGET_RELEASE: |
| 185 | # - bar will use: foo.scl bar.scl |
| 186 | # - baz will use: foo.scl bar.scl baz.scl |
| 187 | # - bif will use: foo.scl bar.scl baz.scl bif.scl |
| 188 | # - bop will use: foo.scl bar.scl baz.scl bop.scl |
| 189 | # |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 190 | # $1 config name |
| 191 | # $2 release config files |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 192 | # $3 overridden release config |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 193 | define declare-release-config |
LaMont Jones | 61b0f79 | 2024-01-30 23:04:02 +0000 | [diff] [blame] | 194 | $(call _declare-release-config,$(1),$(2),$(3),) |
| 195 | endef |
| 196 | |
| 197 | define _declare-release-config |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 198 | $(if $(strip $(2)$(3)),, \ |
| 199 | $(error declare-release-config: config $(strip $(1)) must have release config files, override another release config, or both) \ |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 200 | ) |
LaMont Jones | 61b0f79 | 2024-01-30 23:04:02 +0000 | [diff] [blame] | 201 | $(if $(strip $(4)),$(eval _all_release_configs.$(strip $(1)).ALIAS := true)) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 202 | $(eval _all_release_configs := $(sort $(_all_release_configs) $(strip $(1)))) |
LaMont Jones | a6b6e67 | 2023-11-27 20:12:36 +0000 | [diff] [blame] | 203 | $(if $(strip $(3)), \ |
| 204 | $(if $(filter $(_all_release_configs), $(strip $(3))), |
| 205 | $(if $(filter $(_all_release_configs.$(strip $(1)).OVERRIDES),$(strip $(3))),, |
| 206 | $(eval _all_release_configs.$(strip $(1)).OVERRIDES := $(_all_release_configs.$(strip $(1)).OVERRIDES) $(strip $(3)))), \ |
| 207 | $(error No release config $(strip $(3))) \ |
| 208 | ) \ |
| 209 | ) |
Joe Onorato | 1f65551 | 2023-06-12 23:29:25 -0700 | [diff] [blame] | 210 | $(eval _all_release_configs.$(strip $(1)).DECLARED_IN := $(_included) $(_all_release_configs.$(strip $(1)).DECLARED_IN)) |
| 211 | $(eval _all_release_configs.$(strip $(1)).FILES := $(_all_release_configs.$(strip $(1)).FILES) $(strip $(2))) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 212 | endef |
| 213 | |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 214 | # Include the config map files and populate _flag_declaration_files. |
LaMont Jones | 451abd6 | 2024-03-14 10:48:55 -0700 | [diff] [blame] | 215 | # If the file is found more than once, only include it the first time. |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 216 | _flag_declaration_files := |
LaMont Jones | 451abd6 | 2024-03-14 10:48:55 -0700 | [diff] [blame] | 217 | _included_config_map_files := |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 218 | $(foreach f, $(config_map_files), \ |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 219 | $(eval FLAG_DECLARATION_FILES:= ) \ |
LaMont Jones | 451abd6 | 2024-03-14 10:48:55 -0700 | [diff] [blame] | 220 | $(if $(filter $(_included_config_map_files),$(f)),,\ |
| 221 | $(eval _included := $(f)) \ |
| 222 | $(eval include $(f)) \ |
| 223 | $(eval _flag_declaration_files += $(FLAG_DECLARATION_FILES)) \ |
| 224 | $(eval _included_config_map_files += $(f)) \ |
| 225 | ) \ |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 226 | ) |
| 227 | FLAG_DECLARATION_FILES := |
| 228 | |
LaMont Jones | 76452d8 | 2024-03-20 12:24:21 -0700 | [diff] [blame] | 229 | # Verify that all inherited/overridden release configs are declared. |
| 230 | $(foreach config,$(_all_release_configs),\ |
| 231 | $(foreach r,$(all_release_configs.$(r).OVERRIDES),\ |
| 232 | $(if $(strip $(_all_release_configs.$(r).FILES)$(_all_release_configs.$(r).OVERRIDES)),,\ |
| 233 | $(error Release config $(config) [declared in: $(_all_release_configs.$(r).DECLARED_IN)] inherits from non-existent $(r).)\ |
| 234 | ))) |
| 235 | # Verify that alias configs do not have config files. |
| 236 | $(foreach r,$(_all_release_configs),\ |
| 237 | $(if $(_all_release_configs.$(r).ALIAS),$(if $(_all_release_configs.$(r).FILES),\ |
| 238 | $(error Alias release config "$(r)" may not specify release config files $(_all_release_configs.$(r).FILES))\ |
| 239 | ))) |
| 240 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 241 | # Use makefiles |
| 242 | endif |
| 243 | |
Greg Kaiser | 0229ecf | 2023-11-09 20:28:55 +0000 | [diff] [blame] | 244 | ifeq ($(TARGET_RELEASE),) |
| 245 | # We allow some internal paths to explicitly set TARGET_RELEASE to the |
| 246 | # empty string. For the most part, 'make' treats unset and empty string as |
| 247 | # the same. But the following line differentiates, and will only assign |
| 248 | # if the variable was completely unset. |
| 249 | TARGET_RELEASE ?= was_unset |
| 250 | ifeq ($(TARGET_RELEASE),was_unset) |
| 251 | $(error No release config set for target; please set TARGET_RELEASE, or if building on the command line use 'lunch <target>-<release>-<build_type>', where release is one of: $(_all_release_configs)) |
| 252 | endif |
| 253 | # Instead of leaving this string empty, we want to default to a valid |
| 254 | # setting. Full builds coming through this path is a bug, but in case |
| 255 | # of such a bug, we want to at least get consistent, valid results. |
| 256 | TARGET_RELEASE = trunk_staging |
| 257 | endif |
| 258 | |
LaMont Jones | 76452d8 | 2024-03-20 12:24:21 -0700 | [diff] [blame] | 259 | # During pass 1 of product config, using a non-existent release config is not an error. |
| 260 | # We can safely assume that we are doing pass 1 if DUMP_MANY_VARS=="PRODUCT_RELEASE_CONFIG_MAPS". |
LaMont Jones | 052282b | 2024-05-16 10:46:49 -0700 | [diff] [blame] | 261 | ifneq (,$(_final_product_config_pass)) |
LaMont Jones | 76452d8 | 2024-03-20 12:24:21 -0700 | [diff] [blame] | 262 | ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) |
| 263 | $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) |
| 264 | endif |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 265 | endif |
Greg Kaiser | 0229ecf | 2023-11-09 20:28:55 +0000 | [diff] [blame] | 266 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 267 | ifeq (,$(_use_protobuf)) |
Greg Kaiser | 0229ecf | 2023-11-09 20:28:55 +0000 | [diff] [blame] | 268 | # Choose flag files |
| 269 | # Don't sort this, use it in the order they gave us. |
| 270 | # Do allow duplicate entries, retaining only the first usage. |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 271 | flag_value_files := |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 272 | |
| 273 | # Apply overrides recursively |
| 274 | # |
| 275 | # $1 release config that we override |
| 276 | applied_releases := |
| 277 | define _apply-release-config-overrides |
| 278 | $(foreach r,$(1), \ |
| 279 | $(if $(filter $(r),$(applied_releases)),, \ |
| 280 | $(foreach o,$(_all_release_configs.$(r).OVERRIDES),$(call _apply-release-config-overrides,$(o)))\ |
| 281 | $(eval applied_releases += $(r))\ |
LaMont Jones | a6b6e67 | 2023-11-27 20:12:36 +0000 | [diff] [blame] | 282 | $(foreach f,$(_all_release_configs.$(r).FILES), \ |
| 283 | $(if $(filter $(f),$(flag_value_files)),,$(eval flag_value_files += $(f)))\ |
| 284 | )\ |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 285 | )\ |
Greg Kaiser | 0229ecf | 2023-11-09 20:28:55 +0000 | [diff] [blame] | 286 | ) |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 287 | endef |
| 288 | $(call _apply-release-config-overrides,$(TARGET_RELEASE)) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 289 | # Unset variables so they can't use them |
| 290 | define declare-release-config |
| 291 | $(error declare-release-config can only be called from inside release_config_map.mk files) |
| 292 | endef |
LaMont Jones | 76452d8 | 2024-03-20 12:24:21 -0700 | [diff] [blame] | 293 | define _apply-release-config-overrides |
LaMont Jones | 55d5fc5 | 2024-01-23 19:15:49 +0000 | [diff] [blame] | 294 | $(error invalid use of apply-release-config-overrides) |
| 295 | endef |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 296 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 297 | # use makefiles |
| 298 | endif |
| 299 | |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 300 | # TODO: Remove this check after enough people have sourced lunch that we don't |
| 301 | # need to worry about it trying to do get_build_vars TARGET_RELEASE. Maybe after ~9/2023 |
| 302 | ifneq ($(CALLED_FROM_SETUP),true) |
| 303 | define TARGET_RELEASE |
| 304 | $(error TARGET_RELEASE may not be accessed directly. Use individual flags.) |
| 305 | endef |
| 306 | else |
| 307 | TARGET_RELEASE:= |
| 308 | endif |
| 309 | .KATI_READONLY := TARGET_RELEASE |
| 310 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 311 | ifeq (,$(_use_protobuf)) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 312 | $(foreach config, $(_all_release_configs), \ |
| 313 | $(eval _all_release_configs.$(config).DECLARED_IN:= ) \ |
| 314 | $(eval _all_release_configs.$(config).FILES:= ) \ |
| 315 | ) |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 316 | applied_releases:= |
| 317 | # use makefiles |
| 318 | endif |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 319 | _all_release_configs:= |
| 320 | config_map_files:= |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 321 | protobuf_map_files:= |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 322 | |
| 323 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 324 | ifeq (,$(_use_protobuf)) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 325 | # ----------------------------------------------------------------- |
| 326 | # Flag declarations and values |
| 327 | # ----------------------------------------------------------------- |
| 328 | # This part is in starlark. We generate a root starlark file that loads |
| 329 | # all of the flags declaration files that we found, and the flag_value_files |
| 330 | # that we chose from the config map above. Then we run that, and load the |
| 331 | # results of that into the make environment. |
| 332 | |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 333 | # _flag_declaration_files is the combined list of FLAG_DECLARATION_FILES set by |
| 334 | # release_config_map.mk files above. |
Joe Onorato | 964f401 | 2023-05-06 12:29:01 -0700 | [diff] [blame] | 335 | |
Cole Faust | 386b374 | 2023-06-06 16:55:58 -0700 | [diff] [blame] | 336 | # Because starlark can't find files with $(wildcard), write an entrypoint starlark script that |
| 337 | # contains the result of the above wildcards for the starlark code to use. |
| 338 | filename_to_starlark=$(subst /,_,$(subst .,_,$(1))) |
Cole Faust | 9a106f3 | 2023-11-08 09:51:04 -0800 | [diff] [blame] | 339 | _c:=load("//build/make/core/release_config.scl", "release_config") |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 340 | _c+=$(newline)def add(d, k, v): |
| 341 | _c+=$(newline)$(space)d = dict(d) |
| 342 | _c+=$(newline)$(space)d[k] = v |
| 343 | _c+=$(newline)$(space)return d |
LaMont Jones | 38b195e | 2023-11-06 22:14:51 +0000 | [diff] [blame] | 344 | _c+=$(foreach f,$(_flag_declaration_files),$(newline)load("$(f)", flags_$(call filename_to_starlark,$(f)) = "flags")) |
| 345 | _c+=$(newline)all_flags = [] $(foreach f,$(_flag_declaration_files),+ [add(x, "declared_in", "$(f)") for x in flags_$(call filename_to_starlark,$(f))]) |
Joe Onorato | d6df20a | 2023-06-09 18:51:00 -0700 | [diff] [blame] | 346 | _c+=$(foreach f,$(flag_value_files),$(newline)load("//$(f)", values_$(call filename_to_starlark,$(f)) = "values")) |
| 347 | _c+=$(newline)all_values = [] $(foreach f,$(flag_value_files),+ [add(x, "set_in", "$(f)") for x in values_$(call filename_to_starlark,$(f))]) |
| 348 | _c+=$(newline)variables_to_export_to_make = release_config(all_flags, all_values) |
Cole Faust | 9a106f3 | 2023-11-08 09:51:04 -0800 | [diff] [blame] | 349 | $(file >$(OUT_DIR)/release_config_entrypoint.scl,$(_c)) |
Cole Faust | 386b374 | 2023-06-06 16:55:58 -0700 | [diff] [blame] | 350 | _c:= |
| 351 | filename_to_starlark:= |
Joe Onorato | 964f401 | 2023-05-06 12:29:01 -0700 | [diff] [blame] | 352 | |
Cole Faust | 386b374 | 2023-06-06 16:55:58 -0700 | [diff] [blame] | 353 | # Exclude the entrypoint file as a dependency (by passing it as the 2nd argument) so that we don't |
| 354 | # rerun kati every build. Kati will replay the $(file) command that generates it every build, |
| 355 | # updating its timestamp. |
| 356 | # |
| 357 | # We also need to pass --allow_external_entrypoint to rbcrun in case the OUT_DIR is set to something |
| 358 | # outside of the source tree. |
Cole Faust | 9a106f3 | 2023-11-08 09:51:04 -0800 | [diff] [blame] | 359 | $(call run-starlark,$(OUT_DIR)/release_config_entrypoint.scl,$(OUT_DIR)/release_config_entrypoint.scl,--allow_external_entrypoint) |
Joe Onorato | 7b578d3 | 2023-05-19 09:13:36 -0700 | [diff] [blame] | 360 | |
LaMont Jones | 20dd4c2 | 2024-05-01 11:24:08 -0700 | [diff] [blame] | 361 | # use makefiles |
| 362 | endif |
| 363 | _can_protobuf := |
| 364 | _must_protobuf := |
| 365 | _use_protobuf := |