From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 4C16B139694 for ; Thu, 4 May 2017 06:07:28 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 33527E0CB6; Thu, 4 May 2017 06:07:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 CCCB9E0BEA for ; Thu, 4 May 2017 06:07:13 +0000 (UTC) Received: from pomiot (d202-252.icpnet.pl [109.173.202.252]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 9BD123416BF; Thu, 4 May 2017 06:07:11 +0000 (UTC) Message-ID: <1493878027.1446.4.camel@gentoo.org> Subject: Re: [gentoo-dev] new eclass: meson.eclass for the meson build system From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Date: Thu, 04 May 2017 08:07:07 +0200 In-Reply-To: <20170504031143.GA16993@linux1> References: <20170504031143.GA16993@linux1> Organization: Gentoo Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-YRkW23oJW7XQslU2Eu1f" X-Mailer: Evolution 3.22.6 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org Mime-Version: 1.0 X-Archives-Salt: 8b74d135-be94-4ca4-be67-1c773e6b902f X-Archives-Hash: fb45c5638bb65aa5ecba4a1043226081 --=-YRkW23oJW7XQslU2Eu1f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On =C5=9Bro, 2017-05-03 at 22:11 -0500, William Hubbs wrote: > # Copyright 2017 Gentoo Foundation > # Distributed under the terms of the GNU General Public License v2 >=20 > # @ECLASS: meson.eclass > # @MAINTAINER: > # William Hubbs > # @BLURB: common ebuild functions for meson-based packages > # @DESCRIPTION: > # > # @EXAMPLE: > # Typical ebuild using meson.eclass: > # > # @CODE > # EAPI=3D6 > # > # inherit meson > # > # ... > # > # src_configure() { > # local mymesonargs=3D( > # -Dqt4=3D$(usex qt4 true false) > # -Dthreads=3D$(usex threads true false) > # -Dtiff=3D$(usex tiff true false) > # ) > # meson_src_configure > # } > # > # ... > # > # @CODE >=20 > case ${EAPI:-0} in > 6) ;; > *) die "EAPI=3D${EAPI} is not supported" ;; > esac >=20 > EXPORT_FUNCTIONS src_configure src_compile src_install src_test It's usually better to order them in run order, i.e. test before install. >=20 > if [[ -z ${_MESON} ]]; then > _MESON=3D1 _MESON_ECLASS would fit the common naming (and reduce risk of accidental collisions). >=20 > inherit ninja-utils toolchain-funcs >=20 > DEPEND=3D">=3Ddev-util/meson-0.39.1 > >=3Ddev-util/ninja-1.7.2" >=20 > # @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. >=20 > # @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} >=20 > # @VARIABLE: mymesonargs > # @DEFAULT_UNSET > # @DESCRIPTION: > # Optional meson arguments as Bash array; this should be defined before > # calling meson_src_configure. >=20 > # create a cross file for meson > # fixme: populate one instead of just touching it > _create_cross_file() { You definitely want to prefix those functions with '_meson', otherwise there's high risk of collisions. > touch "${T}"/meson.crossfile > } >=20 > # set the build directory > _set_build_dir(){ > BUILD_DIR=3D"${BUILD_DIR:-${WORKDIR}/${P}-build}" : "${BUILD_DIR:=3D${WORKDIR}/${P}-build}" Plus mis-indent. Plus the doc before said it's using underscore between ${P} and build, so you may want to unify that. > } >=20 > # @FUNCTION: meson_src_configure > # @DESCRIPTION: > # this is the meson_src_configure function > meson_src_configure() { > debug-print-function ${FUNCNAME} "$@" >=20 > # Common args > local mesonargs=3D( > --buildtype plain > --libdir "$(get_libdir)" > --localstatedir "${EPREFIX}/var/lib" > --prefix "${EPREFIX}"/usr > --sysconfdir "${EPREFIX}/etc" > ) >=20 > if tc-is-cross-compiler; then > _create_cross_file || die "unable to write meson cross file" > mesonargs+=3D( > --cross-file "${T}"/meson.crossfile > ) > fi >=20 > # Append additional arguments from ebuild > mesonargs+=3D("${mymesonargs[@]}") >=20 > _set_build_dir > set -- meson "${mesonargs[@]}" "$@" \ > "${EMESON_SOURCE:-${S}}" "${BUILD_DIR}" You've got double space between the paths. > echo "$@" > "$@" || die > } >=20 > # @FUNCTION: meson_src_compile > # @DESCRIPTION: > # This is the meson_src_compile function. > meson_src_compile() { > debug-print-function ${FUNCNAME} "$@" >=20 > eninja -v -C "${BUILD_DIR}" || die eninja dies on its own in EAPI 4+. > } >=20 > # @FUNCTION: meson_src_test > # @DESCRIPTION: > # this is the meson_src_test function. > meson_src_test() { > debug-print-function ${FUNCNAME} "$@" >=20 > eninja -C "${BUILD_DIR}" test || die Why no -v here? > } >=20 > # @FUNCTION: meson_src_install > # @DESCRIPTION: > # this is the meson_src_install function. > meson_src_install() { > debug-print-function ${FUNCNAME} "$@" >=20 > DESTDIR=3D"${ED}" eninja -C "${BUILD_DIR}" install || die Wouldn't this result in double EPREFIX, since you're passing EPREFIX to configure already? > } >=20 > fi --=20 Best regards, Micha=C5=82 G=C3=B3rny --=-YRkW23oJW7XQslU2Eu1f Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- iQKTBAABCgB9FiEEXr8g+Zb7PCLMb8pAur8dX/jIEQoFAlkKxQtfFIAAAAAALgAo aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDVF QkYyMEY5OTZGQjNDMjJDQzZGQ0E0MEJBQkYxRDVGRjhDODExMEEACgkQur8dX/jI EQoPVg/9E01BlFyzOC0cXhtxCk9Zb/uwYHftW8TXvaMcOW0vypQt/caoQQhmvXin wYzDeI2MLWdRRQGn8HWt1WL9uLlKjcL/S/xeEhLc+Fl1M51XrYJsinfAOe5v0Fxa r5aIDWXhtlwA4ZbVB1EUsx+x90GiSMojpyml0DlKtH/uoIeIbX2Vbcu0lfANEHvI glT8iC2CGjb+ScdC6G1p22/vksgBWJWrwi8Sy0hycKrN61BTvJnNGO2quUVuRXiU wk2asvcpSKZNn0O4codwSg66bA/zDQZkjKcid4Dy/ecMqPFFbUbFWIu5qKv7Qobd PLmSrzVX2Fo5aAIA+P1kIdaESzwvqiJllBEOTV6Ik6pq5gbXJjHI0MDQDrhY8THP kGUF0j/amjdL6koUI78C75f6F1z/RZxc9TVsMl6P+Fo4hG8XqXsM0VR1/g8LQJSB GNmrIPTRXtHmexUWh7+ukqt/HUT4bq2/OVIwHIKbEe88fpGb49iRsMn94snZ1Myu /d0FVO5j4DgIwBsqJmUInBAEfOiQ6Ki7pwV3iWx21WUGl+hhNKGRq5yGrtigmo5m B0SrU1te1IHOEttLhX9j332OUk7dNn5L5uRwwwk2j+UUHlLUb55aLcF7jh2vBUgb fcy5MNXSMx8VRhp1SQmkj9QNo52SqxAt1uyFxiBy7P1Zc9n11ns= =NWXq -----END PGP SIGNATURE----- --=-YRkW23oJW7XQslU2Eu1f--