meson.eclass: add meson_feature function
authorMart Raudsepp <leio@gentoo.org>
Mon, 4 Mar 2019 08:38:02 +0000 (10:38 +0200)
committerMatt Turner <mattst88@gentoo.org>
Sun, 17 Mar 2019 19:17:00 +0000 (12:17 -0700)
This can be used to simplify controlling meson_options.txt entries
of type 'feature'.

Signed-off-by: Mart Raudsepp <leio@gentoo.org>
Signed-off-by: Matt Turner <mattst88@gentoo.org>
eclass/meson.eclass

index 75291d7bdd1b81b4515e33aff54fce5aee6440a7..65b09932a7ac0bd3c8c179b9e390ba70f4c66c8c 100644 (file)
@@ -188,6 +188,19 @@ meson_use() {
        usex "$1" "-D${2-$1}=true" "-D${2-$1}=false"
 }
 
+# @FUNCTION: meson_feature
+# @USAGE: <USE flag> [option name]
+# @DESCRIPTION:
+# Given a USE flag and meson project option, outputs a string like:
+#
+#   -Doption=enabled
+#   -Doption=disabled
+#
+# If the project option is unspecified, it defaults to the USE flag.
+meson_feature() {
+       usex "$1" "-D${2-$1}=enabled" "-D${2-$1}=disabled"
+}
+
 # @FUNCTION: meson_src_configure
 # @USAGE: [extra meson arguments]
 # @DESCRIPTION: