-# Copyright 2017 Gentoo Foundation
+# Copyright 2017-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: meson.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# Mike Gilbert <floppym@gentoo.org>
+# @SUPPORTED_EAPIS: 6 7
# @BLURB: common ebuild functions for meson-based packages
# @DESCRIPTION:
# This eclass contains the default phase functions for packages which
# @CODE
case ${EAPI:-0} in
- 6) ;;
+ 6|7) ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
-if [[ ${__MESON_AUTO_DEPEND+set} == "set" ]] ; then
- # See if we were included already, but someone changed the value
- # of MESON_AUTO_DEPEND on us. We could reload the entire
- # eclass at that point, but that adds overhead, and it's trivial
- # to re-order inherit in eclasses/ebuilds instead. #409611
- if [[ ${__MESON_AUTO_DEPEND} != ${MESON_AUTO_DEPEND} ]] ; then
- die "MESON_AUTO_DEPEND changed value between inherits; please inherit meson.eclass first! ${__MESON_AUTO_DEPEND} -> ${MESON_AUTO_DEPEND}"
- fi
-fi
-
if [[ -z ${_MESON_ECLASS} ]]; then
-inherit ninja-utils python-utils-r1 toolchain-funcs
+inherit multiprocessing ninja-utils python-utils-r1 toolchain-funcs
fi
if [[ -z ${_MESON_ECLASS} ]]; then
_MESON_ECLASS=1
-MESON_DEPEND=">=dev-util/meson-0.40.0
+MESON_DEPEND=">=dev-util/meson-0.48.2
>=dev-util/ninja-1.7.2"
-# @ECLASS-VARIABLE: MESON_AUTO_DEPEND
-# @DESCRIPTION:
-# Set to 'no' to disable automatically adding to DEPEND. This lets
-# ebuilds form conditional depends by using ${MESON_DEPEND} in
-# their own DEPEND string.
-: ${MESON_AUTO_DEPEND:=yes}
-if [[ ${MESON_AUTO_DEPEND} != "no" ]] ; then
+if [[ ${EAPI:-0} == [6] ]]; then
DEPEND=${MESON_DEPEND}
+else
+ BDEPEND=${MESON_DEPEND}
fi
-__MESON_AUTO_DEPEND=${MESON_AUTO_DEPEND} # See top of eclass
# @ECLASS-VARIABLE: BUILD_DIR
# @DEFAULT_UNSET
# 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
# This may require adjustment based on CFLAGS
local cpu=${CHOST%%-*}
- cat > "${T}/meson.${CHOST}" <<-EOF
+ cat > "${T}/meson.${CHOST}.${ABI}" <<-EOF
[binaries]
- ar = '$(tc-getAR)'
- c = '$(tc-getCC)'
- cpp = '$(tc-getCXX)'
+ ar = $(_meson_env_array "$(tc-getAR)")
+ c = $(_meson_env_array "$(tc-getCC)")
+ cpp = $(_meson_env_array "$(tc-getCXX)")
+ fortran = $(_meson_env_array "$(tc-getFC)")
+ llvm-config = '$(tc-getPROG LLVM_CONFIG llvm-config)'
+ objc = $(_meson_env_array "$(tc-getPROG OBJC cc)")
+ objcpp = $(_meson_env_array "$(tc-getPROG OBJCXX c++)")
pkgconfig = '$(tc-getPKG_CONFIG)'
- strip = '$(tc-getSTRIP)'
+ strip = $(_meson_env_array "$(tc-getSTRIP)")
+ windres = $(_meson_env_array "$(tc-getRC)")
[properties]
c_args = $(_meson_env_array "${CFLAGS} ${CPPFLAGS}")
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:
# This is the meson_src_configure function.
meson_src_configure() {
--wrap-mode nodownload
)
- if tc-is-cross-compiler; then
+ if tc-is-cross-compiler || [[ ${ABI} != ${DEFAULT_ABI-${ABI}} ]]; then
_meson_create_cross_file || die "unable to write meson cross file"
- mesonargs+=( --cross-file "${T}/meson.${CHOST}" )
+ mesonargs+=( --cross-file "${T}/meson.${CHOST}.${ABI}" )
fi
# https://bugs.gentoo.org/625396
}
# @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
}