papp-text/dos2unix: Bump to version 7.4.1
[gentoo.git] / eclass / meson.eclass
index 1b080396626cff957a90e0a95bd39c3f0024d121..fa859ace996f2433955cd0adb4a6b503816f6045 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2017-2018 Gentoo Authors
+# Copyright 2017-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: meson.eclass
@@ -41,7 +41,7 @@ esac
 
 if [[ -z ${_MESON_ECLASS} ]]; then
 
-inherit ninja-utils python-utils-r1 toolchain-funcs
+inherit multiprocessing ninja-utils python-utils-r1 toolchain-funcs
 
 fi
 
@@ -50,10 +50,10 @@ EXPORT_FUNCTIONS src_configure src_compile src_test src_install
 if [[ -z ${_MESON_ECLASS} ]]; then
 _MESON_ECLASS=1
 
-MESON_DEPEND=">=dev-util/meson-0.45.1
+MESON_DEPEND=">=dev-util/meson-0.48.2
        >=dev-util/ninja-1.7.2"
 
-if [[ ${EAPI:-0} == [0123456] ]]; then
+if [[ ${EAPI:-0} == [6] ]]; then
        DEPEND=${MESON_DEPEND}
 else
        BDEPEND=${MESON_DEPEND}
@@ -78,6 +78,12 @@ fi
 # Optional meson arguments as Bash array; this should be defined before
 # calling meson_src_configure.
 
+# @VARIABLE: emesontestargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Optional meson test arguments as Bash array; this should be defined before
+# calling meson_src_test.
+
 
 read -d '' __MESON_ARRAY_PARSER <<"EOF"
 import shlex
@@ -154,6 +160,7 @@ _meson_create_cross_file() {
        objcpp = $(_meson_env_array "$(tc-getPROG OBJCXX c++)")
        pkgconfig = '$(tc-getPKG_CONFIG)'
        strip = $(_meson_env_array "$(tc-getSTRIP)")
+       windres = $(_meson_env_array "$(tc-getRC)")
 
        [properties]
        c_args = $(_meson_env_array "${CFLAGS} ${CPPFLAGS}")
@@ -188,6 +195,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:
@@ -224,30 +244,46 @@ meson_src_configure() {
 }
 
 # @FUNCTION: meson_src_compile
+# @USAGE: [extra ninja arguments]
 # @DESCRIPTION:
 # This is the meson_src_compile function.
 meson_src_compile() {
        debug-print-function ${FUNCNAME} "$@"
 
-       eninja -C "${BUILD_DIR}"
+       eninja -C "${BUILD_DIR}" "$@"
 }
 
 # @FUNCTION: meson_src_test
+# @USAGE: [extra meson test arguments]
 # @DESCRIPTION:
 # This is the meson_src_test function.
 meson_src_test() {
        debug-print-function ${FUNCNAME} "$@"
 
-       eninja -C "${BUILD_DIR}" test
+       local mesontestargs=(
+               -C "${BUILD_DIR}"
+       )
+       [[ -n ${NINJAOPTS} || -n ${MAKEOPTS} ]] &&
+               mesontestargs+=(
+                       --num-processes "$(makeopts_jobs ${NINJAOPTS:-${MAKEOPTS}})"
+               )
+
+       # Append additional arguments from ebuild
+       mesontestargs+=("${emesontestargs[@]}")
+
+       set -- meson test "${mesontestargs[@]}" "$@"
+       echo "$@" >&2
+       "$@" || die "tests failed"
 }
 
 # @FUNCTION: meson_src_install
+# @USAGE: [extra ninja install arguments]
 # @DESCRIPTION:
 # This is the meson_src_install function.
 meson_src_install() {
        debug-print-function ${FUNCNAME} "$@"
 
-       DESTDIR="${D}" eninja -C "${BUILD_DIR}" install
+       DESTDIR="${D}" eninja -C "${BUILD_DIR}" install "$@"
        einstalldocs
 }