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
diff --git a/core/config.mk b/core/config.mk
index 9f134d3..99337fc 100644
--- a/core/config.mk
+++ b/core/config.mk
@@ -316,6 +316,19 @@
 $(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.