From 0229ecfae50a470eff98eb8934694c18d78b7035 Mon Sep 17 00:00:00 2001 From: Greg Kaiser Date: Thu, 9 Nov 2023 20:28:55 +0000 Subject: [PATCH] Reland: Require TARGET_RELEASE for builds Relanding because we've fixed a number of the broken build setups this change exposed. We will push to fix forward broken build setups instead of reverting this change again. Rather than use an unsupported flag setting that the user likely doesn't even realize is being used, we immediately stop the build. This error message is more verbose, mentioning 'lunch', because it's anticipated a lot more users will hit this issue when first switching to trunk stable, and more details will hopefully help them out. We have some complication in that some internal commands set TARGET_RELEASE to an empty string. We put in logic to allow that path. Since $(error) immediately stops the build, we also get rid of some 'else' logic and indentation, to hopefully offset some of the complication we've added. Bug: 307946156 Change-Id: I0fa4a1c876e607401f4c7f945b9971cfb8db71a0 Test: 'lunch' (still) works; A build attempt without `TARGET_RELEASE` set (now) fails --- core/release_config.mk | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/core/release_config.mk b/core/release_config.mk index e1e0726057..3b594b251a 100644 --- a/core/release_config.mk +++ b/core/release_config.mk @@ -82,28 +82,32 @@ $(foreach f, $(config_map_files), \ ) FLAG_DECLARATION_FILES := -# If TARGET_RELEASE is set, fail if there is no matching release config -# If it isn't set, no release config files will be included and all flags -# will get their default values. -ifneq ($(TARGET_RELEASE),) +ifeq ($(TARGET_RELEASE),) + # We allow some internal paths to explicitly set TARGET_RELEASE to the + # empty string. For the most part, 'make' treats unset and empty string as + # the same. But the following line differentiates, and will only assign + # if the variable was completely unset. + TARGET_RELEASE ?= was_unset + ifeq ($(TARGET_RELEASE),was_unset) + $(error No release config set for target; please set TARGET_RELEASE, or if building on the command line use 'lunch --', where release is one of: $(_all_release_configs)) + endif + # Instead of leaving this string empty, we want to default to a valid + # setting. Full builds coming through this path is a bug, but in case + # of such a bug, we want to at least get consistent, valid results. + TARGET_RELEASE = trunk_staging +endif + ifeq ($(filter $(_all_release_configs), $(TARGET_RELEASE)),) $(error No release config found for TARGET_RELEASE: $(TARGET_RELEASE). Available releases are: $(_all_release_configs)) -else - # Choose flag files - # Don't sort this, use it in the order they gave us. - # Do allow duplicate entries, retaining only the first usage. - flag_value_files := - $(foreach f,$(_all_release_configs.$(TARGET_RELEASE).FILES), \ - $(if $(filter $(f),$(flag_value_files)),,$(eval flag_value_files += $(f)))\ - ) -endif -else -# Useful for finding scripts etc that aren't passing or setting TARGET_RELEASE -ifneq ($(FAIL_IF_NO_RELEASE_CONFIG),) - $(error FAIL_IF_NO_RELEASE_CONFIG was set and TARGET_RELEASE was not) endif + +# Choose flag files +# Don't sort this, use it in the order they gave us. +# Do allow duplicate entries, retaining only the first usage. flag_value_files := -endif +$(foreach f,$(_all_release_configs.$(TARGET_RELEASE).FILES), \ + $(if $(filter $(f),$(flag_value_files)),,$(eval flag_value_files += $(f)))\ +) # Unset variables so they can't use them define declare-release-config