summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2024-06-20 12:56:16 -0700
committer Cole Faust <colefaust@google.com> 2024-06-20 14:51:39 -0700
commit95ff089b84842b4ddfe2ff210ac8b847b07253b9 (patch)
tree7abb401c3198f85e4b2f63a7cd29f21c52249186
parentb2302013ec44db5c0f97c48f87f223dad426143f (diff)
Add soong_config_set_bool
To allow typing soong config variables as bools for using in soong select expressions. Bug: 323382414 Test: m nothing --no-skip-soong-tests Change-Id: I39496cd2a3366689e3f232ba10353a7d56d8d1ed
-rw-r--r--core/android_soong_config_vars.mk2
-rw-r--r--core/config.mk13
-rw-r--r--core/soong_config.mk12
3 files changed, 26 insertions, 1 deletions
diff --git a/core/android_soong_config_vars.mk b/core/android_soong_config_vars.mk
index 13a5bc0f5b..6d4bed256d 100644
--- a/core/android_soong_config_vars.mk
+++ b/core/android_soong_config_vars.mk
@@ -37,7 +37,7 @@ $(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64)
$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER)
# PRODUCT_PRECOMPILED_SEPOLICY defaults to true. Explicitly check if it's "false" or not.
-$(call add_soong_config_var_value,ANDROID,PRODUCT_PRECOMPILED_SEPOLICY,$(if $(filter false,$(PRODUCT_PRECOMPILED_SEPOLICY)),false,true))
+$(call soong_config_set_bool,ANDROID,PRODUCT_PRECOMPILED_SEPOLICY,$(if $(filter false,$(PRODUCT_PRECOMPILED_SEPOLICY)),false,true))
ifdef ART_DEBUG_OPT_FLAG
$(call soong_config_set,art_module,art_debug_opt_flag,$(ART_DEBUG_OPT_FLAG))
diff --git a/core/config.mk b/core/config.mk
index 9f134d3ad5..99337fcb77 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -316,6 +316,19 @@ $(call soong_config_define_internal,$1,$2) \
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(strip $3))
endef
+# soong_config_set_bool is the same as soong_config_set, but it will
+# also type the variable as a bool, so that when using select() expressions
+# in blueprint files they can use boolean values instead of strings.
+# It will only accept "true" for its value, any other value will be
+# treated as false.
+# $1 is the namespace. $2 is the variable name. $3 is the variable value.
+# Ex: $(call soong_config_set_bool,acme,COOL_FEATURE,true)
+define soong_config_set_bool
+$(call soong_config_define_internal,$1,$2) \
+$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(filter true,$3))
+$(eval SOONG_CONFIG_TYPE_$(strip $1)_$(strip $2):=bool)
+endef
+
# soong_config_append appends to the value of the variable in the given Soong
# config namespace. If the variable does not exist, it will be defined. If the
# namespace does not exist, it will be defined.
diff --git a/core/soong_config.mk b/core/soong_config.mk
index 8948046eef..068034bb13 100644
--- a/core/soong_config.mk
+++ b/core/soong_config.mk
@@ -262,6 +262,18 @@ $(foreach namespace,$(sort $(SOONG_CONFIG_NAMESPACES)),\
$(call end_json_map))
$(call end_json_map)
+# Add the types of the variables in VendorVars. Since this is much newer
+# than VendorVars, which has a history of just using string values for everything,
+# variables are assumed to be strings by default. For strings, SOONG_CONFIG_TYPE_*
+# will not be set, and they will not have an entry in the VendorVarTypes map.
+$(call add_json_map, VendorVarTypes)
+$(foreach namespace,$(sort $(SOONG_CONFIG_NAMESPACES)),\
+ $(call add_json_map, $(namespace))\
+ $(foreach key,$(sort $(SOONG_CONFIG_$(namespace))),\
+ $(if $(SOONG_CONFIG_TYPE_$(namespace)_$(key)),$(call add_json_str,$(key),$(subst ",\",$(SOONG_CONFIG_TYPE_$(namespace)_$(key))))))\
+ $(call end_json_map))
+$(call end_json_map)
+
$(call add_json_bool, EnforceProductPartitionInterface, $(filter true,$(PRODUCT_ENFORCE_PRODUCT_PARTITION_INTERFACE)))
$(call add_json_str, DeviceCurrentApiLevelForVendorModules, $(BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES))