From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-dev+bounces-80467-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 74EE7139694
	for <garchives@archives.gentoo.org>; Thu,  4 May 2017 03:11:56 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id ED534E0CCB;
	Thu,  4 May 2017 03:11:45 +0000 (UTC)
Received: from mail-io0-x229.google.com (mail-io0-x229.google.com [IPv6:2607:f8b0:4001:c06::229])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A0C95E0CBC
	for <gentoo-dev@lists.gentoo.org>; Thu,  4 May 2017 03:11:45 +0000 (UTC)
Received: by mail-io0-x229.google.com with SMTP id f102so4851738ioi.2
        for <gentoo-dev@lists.gentoo.org>; Wed, 03 May 2017 20:11:45 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=sender:date:from:to:subject:message-id:mail-followup-to
         :mime-version:content-disposition:user-agent;
        bh=gOPqwD2DVmzPsKw/+DCr1RDS3gto1+FGFiY/NHMG9os=;
        b=B7PqUutEMl8ras7/PqG2fHGt3JhpmKi91BV7SsEnZkmFhNGJpSgTGWPPj1vE6Y3Fq9
         VJqtEO02c7EtsX1z9J3zePQ8sD2I0/xOC5N/EOu+nNgPEHzbmnf8GE8BR2FYVHYEvmBQ
         9AMnlRTumqOzpG/SKB7gEFspoXGBPPDlXbTwACP17mal68y7WVYTfR3wpbmFN9HOS4k7
         a2l0XLW1QXlveUQWbl5NkpkKN+tM9b5nzMLitQleYP/tDK9lMooyWLXX65LH6OUYxQv4
         7wkuH5XC8XfSsBzX/2iWxxczb3kV70qQgwUnvHn+U2K+GwwkIjrtCyFrDFG1mY09m3Ac
         EGzw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:sender:date:from:to:subject:message-id
         :mail-followup-to:mime-version:content-disposition:user-agent;
        bh=gOPqwD2DVmzPsKw/+DCr1RDS3gto1+FGFiY/NHMG9os=;
        b=Dp5knQQ1GL3A8LaST8WOmDmykFS9j87l/IYDTjghh/QoRtWHFzMY2nwmHt17q9avUL
         idceKiS9eIvzMPC9DDTiPyM2owEKopmM2HZuA7+kloGDQbPwMnUei+QImb+b0eRf0c00
         lj8tOnm/MrL1rmkep9pPOF37GSR8Eg71qQt8VSTQhYhJwqk6rUocJk6rWiDUh8eOqKMU
         kKLmxj7DUYCiBaxcWUrrLSdh70HuXzzUL3rWnuTM4ShXXluFTIjEyTQjFnOg+x8irtNx
         /u3PrBbDMiMr17zm9Am/3L+WHPEFxE3cexBkbpGHxbrPHdpPq6/s/6VKlJb3l4IaTdlH
         8g8w==
X-Gm-Message-State: AN3rC/6xslpk21ThiIL4TgvfKDi4jAi5yoB67BMUt5nLBpGAHilykCCu
	vUK2RvRWxVT7OLjG
X-Received: by 10.157.46.112 with SMTP id c45mr13450469otd.73.1493867504596;
        Wed, 03 May 2017 20:11:44 -0700 (PDT)
Received: from linux1 (cpe-66-68-34-247.austin.res.rr.com. [66.68.34.247])
        by smtp.gmail.com with ESMTPSA id a40sm558597oic.11.2017.05.03.20.11.43
        for <gentoo-dev@lists.gentoo.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 03 May 2017 20:11:43 -0700 (PDT)
Sender: William Hubbs <w.d.hubbs@gmail.com>
Received: (nullmailer pid 17039 invoked by uid 1000);
	Thu, 04 May 2017 03:11:43 -0000
Date: Wed, 3 May 2017 22:11:43 -0500
From: William Hubbs <williamh@gentoo.org>
To: gentoo development <gentoo-dev@lists.gentoo.org>
Subject: [gentoo-dev] new eclass: meson.eclass for the meson build system
Message-ID: <20170504031143.GA16993@linux1>
Mail-Followup-To: gentoo development <gentoo-dev@lists.gentoo.org>
Precedence: bulk
List-Post: <mailto:gentoo-dev@lists.gentoo.org>
List-Help: <mailto:gentoo-dev+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-dev+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-dev+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-dev.gentoo.org>
X-BeenThere: gentoo-dev@lists.gentoo.org
Reply-to: gentoo-dev@lists.gentoo.org
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="2B/JsCI69OhZNC5r"
Content-Disposition: inline
User-Agent: Mutt/1.5.24 (2015-08-30)
X-Archives-Salt: 57148ad9-cdbd-45cf-aff7-bc17a7dcaacb
X-Archives-Hash: 81f05663fc40bc8787cfd9966befbc60


--2B/JsCI69OhZNC5r
Content-Type: multipart/mixed; boundary="AhhlLboLdkugWU4S"
Content-Disposition: inline


--AhhlLboLdkugWU4S
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

All,

the following is my proposed eclass for handling packages that use the
meson build system.

Please let me know what you think.

William


--AhhlLboLdkugWU4S
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="meson.eclass"

# Copyright 2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: meson.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# @BLURB: common ebuild functions for meson-based packages
# @DESCRIPTION:
#
# @EXAMPLE:
# Typical ebuild using meson.eclass:
#
# @CODE
# EAPI=6
#
# inherit meson
#
# ...
#
# src_configure() {
# 	local mymesonargs=(
# 		-Dqt4=$(usex qt4 true false)
# 		-Dthreads=$(usex threads true false)
# 		-Dtiff=$(usex tiff true false)
# 	)
# 	meson_src_configure
# }
#
# ...
#
# @CODE

case ${EAPI:-0} in
	6) ;;
	*) die "EAPI=${EAPI} is not supported" ;;
esac

EXPORT_FUNCTIONS src_configure src_compile src_install src_test

if [[ -z ${_MESON} ]]; then
_MESON=1

	inherit ninja-utils toolchain-funcs

DEPEND=">=dev-util/meson-0.39.1
	>=dev-util/ninja-1.7.2"

# @ECLASS-VARIABLE: BUILD_DIR
# @DEFAULT_UNSET
# @DESCRIPTION:
# Build directory, location where all generated files should be placed.
# If this isn't set, it defaults to ${WORKDIR}/${P}_build.

# @ECLASS-VARIABLE: EMESON_SOURCE
# @DEFAULT_UNSET
# @DESCRIPTION:
# The location of the source files for the project;this is the source
# directory to pass to meson.
# If this isn't set, it defaults to ${S}

# @VARIABLE: mymesonargs
# @DEFAULT_UNSET
# @DESCRIPTION:
# Optional meson arguments as Bash array; this should be defined before
# calling meson_src_configure.

# create a cross file for meson
# fixme: populate one instead of just touching it
_create_cross_file() {
	touch "${T}"/meson.crossfile
}

# set the build directory
_set_build_dir(){
		BUILD_DIR="${BUILD_DIR:-${WORKDIR}/${P}-build}"
}

# @FUNCTION: meson_src_configure
# @DESCRIPTION:
# this is the meson_src_configure function
meson_src_configure() {
	debug-print-function ${FUNCNAME} "$@"

	# Common args
	local mesonargs=(
		--buildtype plain
		--libdir "$(get_libdir)"
		--localstatedir "${EPREFIX}/var/lib"
		--prefix "${EPREFIX}"/usr
		--sysconfdir "${EPREFIX}/etc"
		)

	if tc-is-cross-compiler; then
		_create_cross_file || die "unable to write meson cross file"
		mesonargs+=(
			--cross-file "${T}"/meson.crossfile
		)
	fi

	# Append additional arguments from ebuild
	mesonargs+=("${mymesonargs[@]}")

	_set_build_dir
	set -- meson "${mesonargs[@]}" "$@" \
		"${EMESON_SOURCE:-${S}}"  "${BUILD_DIR}"
	echo "$@"
	"$@" || die
}

# @FUNCTION: meson_src_compile
# @DESCRIPTION:
# This is the meson_src_compile function.
meson_src_compile() {
	debug-print-function ${FUNCNAME} "$@"

	eninja -v -C "${BUILD_DIR}" || die
}

# @FUNCTION: meson_src_test
# @DESCRIPTION:
# this is the meson_src_test function.
meson_src_test() {
	debug-print-function ${FUNCNAME} "$@"

	eninja -C "${BUILD_DIR}" test || die
}

# @FUNCTION: meson_src_install
# @DESCRIPTION:
# this is the meson_src_install function.
meson_src_install() {
	debug-print-function ${FUNCNAME} "$@"

	DESTDIR="${ED}" eninja -C "${BUILD_DIR}" install || die
}

fi

--AhhlLboLdkugWU4S--

--2B/JsCI69OhZNC5r
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature

-----BEGIN PGP SIGNATURE-----

iF0EARECAB0WIQTVeuxEZo4uUHOkQAluVBb0MMRlOAUCWQqb6QAKCRBuVBb0MMRl
OACdAJ0a0YjI8grN8JPTxSY/WUKNhomY0wCfbvCyz9UVEcP9zy/x/Lv0qRDyeC4=
=axoE
-----END PGP SIGNATURE-----

--2B/JsCI69OhZNC5r--