public inbox for gentoo-guru@lists.gentoo.org
 help / color / mirror / Atom feed
From: Andrew Ammerlaan <andrewammerlaan@gentoo.org>
To: gentoo-guru@lists.gentoo.org
Subject: Re: [gentoo-guru] [PATCH 1/3] build2.eclass: new eclass
Date: Mon, 6 Jun 2022 13:07:01 +0200	[thread overview]
Message-ID: <bcfa928a-8b1f-2c9b-7890-21f3bb31d2db@gentoo.org> (raw)
In-Reply-To: <20220606102016.18956-2-cyber+gentoo@sysrq.in>

On 06/06/2022 12:20, Anna (cybertailor) Vyalkova wrote:
> Signed-off-by: Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
> ---
>   eclass/build2.eclass | 150 +++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 150 insertions(+)
>   create mode 100644 eclass/build2.eclass
> 
> diff --git a/eclass/build2.eclass b/eclass/build2.eclass
> new file mode 100644
> index 000000000..002b08c6e
> --- /dev/null
> +++ b/eclass/build2.eclass
> @@ -0,0 +1,150 @@
> +# Copyright 2022 Gentoo Authors
> +# Distributed under the terms of the GNU General Public License v2
> +
> +# @ECLASS: build2.eclass
> +# @MAINTAINER:
> +# Anna Vyalkova <cyber+gentoo@sysrq.in>
> +# @AUTHOR:
> +# Anna Vyalkova <cyber+gentoo@sysrq.in>
> +# @SUPPORTED_EAPIS: 8
> +# @BLURB: eclass for packages using build2
> +# @DESCRIPTION:
> +# Utility eclass providing wrapper functions for the build2 build system along
> +# with default phase functions.
> +
> +case ${EAPI:-0} in
> +	8) ;;
> +	*) die "${ECLASS}: EAPI ${EAPI:-0} unsupported."
> +esac
> +
> +if [[ ! ${_BUILD2_ECLASS} ]]; then
> +
> +inherit edo multiprocessing toolchain-funcs
> +
> +fi
> +
> +EXPORT_FUNCTIONS src_configure src_compile src_test src_install

I think this should also be within the if. If we accidentally inherit it 
twice somehow then we should not export the functions twice, right?

> +
> +if [[ ! ${_BUILD2_ECLASS} ]]; then
> +
> +# @ECLASS_VARIABLE: BUILD2_VERBOSITY
> +# @USER_VARIABLE
> +# @DESCRIPTION:
> +# Determines what kind of output to show when executing commands.  All possible
> +# options are listed in b(1).
> +: ${BUILD2_VERBOSITY:=2}
> +
> +BDEPEND="dev-util/build2"
> +
> +# @FUNCTION: build2_src_configure
> +# @DESCRIPTION:
> +# Set build2 preferences to match user settings.  Configure toolchain, build
> +# flags and installation prefix.
> +build2_src_configure() {
> +	debug-print-function ${FUNCNAME} "${@}"
> +
> +	[[ -z ${mybargs} ]] && declare -a mybargs=()
> +	local mybargstype=$(declare -p mybargs 2>&-)
> +	if [[ "${mybargstype}" != "declare -a mybargs="* ]]; then
> +		die "mybargs must be declared as array"
> +	fi
> +
> +	local bargs=(
> +		config.cxx="$(tc-getCXX)"
> +		config.cxx.coptions="${CXXFLAGS}"
> +		config.cxx.loptions="${LDFLAGS}"
> +		config.c="$(tc-getCC)"
> +		config.cc.coptions="${CFLAGS}"
> +		config.cc.loptions="${LDFLAGS}"
> +		config.bin.ar="$(tc-getAR)"
> +		config.bin.ranlib="$(tc-getRANLIB)"
> +		config.bin.lib=shared
> +		config.install.root="${EPREFIX}"/usr
> +		config.install.lib="${EPREFIX}"/usr/$(get_libdir)
> +		config.install.doc="${EPREFIX}"/usr/share/doc/${PF}
> +		"${mybargs[@]}"
> +		--jobs $(makeopts_jobs)
> +		--verbose "${BUILD2_VERBOSITY}"
> +	)
> +
> +	edo b configure "${bargs[@]}"
> +}
> +
> +# @FUNCTION: build2_src_compile
> +# @USAGE: [<b args>...]
> +# @DESCRIPTION:
> +# General function for compiling with build2.  Tests are built conditionally.
> +build2_src_compile() {
> +	debug-print-function ${FUNCNAME} "${@}"
> +
> +	local build_tests=no
> +	local bargs=(
> +		"${@}"
> +		--jobs $(makeopts_jobs)
> +		--verbose "${BUILD2_VERBOSITY}"
> +	)
> +
> +	edo b update-for-install "${bargs[@]}"
> +	has test ${FEATURES} && edo b update-for-test "${bargs[@]}"
> +}
> +
> +# @FUNCTION: build2_src_test
> +# @USAGE: [<b args>...]
> +# @DESCRIPTION:
> +# Test the package using "b test".
> +build2_src_test() {
> +	debug-print-function ${FUNCNAME} "${@}"
> +
> +	local bargs=(
> +		"${@}"
> +		--jobs $(makeopts_jobs)
> +		--verbose "${BUILD2_VERBOSITY}"
> +	)
> +
> +	edo b test "${bargs[@]}"
> +}
> +
> +# @FUNCTION: build2_src_install
> +# @USAGE: [<b args>...]
> +# @DESCRIPTION:
> +# Install the package using "b install".
> +build2_src_install() {
> +	debug-print-function ${FUNCNAME} "${@}"
> +
> +	local bargs=(
> +		config.install.chroot="${D}"
> +		"${@}"
> +		--jobs $(makeopts_jobs)
> +		--verbose "${BUILD2_VERBOSITY}"
> +	)
> +
> +	edo b install "${bargs[@]}"
> +	einstalldocs
> +}
> +
> +# @FUNCTION: build2_pkg_die
> +# @INTERNAL
> +# @DESCRIPTION:
> +# EBUILD_DEATH_HOOK function to display a warning if ccache is enabled.
> +
> +if ! has build2_pkg_die ${EBUILD_DEATH_HOOKS}; then
> +	EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} build2_pkg_die"
> +fi
> +
> +build2_pkg_die() {
> +	if [[ "${EBUILD_PHASE}" != "compile" ]]; then
> +		return
> +	fi
> +
> +	if has ccache ${FEATURES}; then
> +		# build2 doesn't support ccache:
> +		# https://github.com/build2/build2/issues/86#issuecomment-647401742
> +		ewarn
> +		ewarn "!!! You have enabled ccache. Please try disabling ccache"
> +		ewarn "!!! before reporting a bug."
> +		ewarn
> +	fi
> +}
> +
> +_BUILD2_ECLASS=1
> +fi



  reply	other threads:[~2024-11-24 22:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 10:20 [gentoo-guru] [PATCH 0/3] New eclass for review Anna (cybertailor) Vyalkova
2022-06-06 10:20 ` [gentoo-guru] [PATCH 1/3] build2.eclass: new eclass Anna (cybertailor) Vyalkova
2022-06-06 11:07   ` Andrew Ammerlaan [this message]
2022-06-06 11:17     ` A.V.
2022-06-06 10:20 ` [gentoo-guru] [PATCH 2/3] dev-cpp/libcutl: use build2 eclass Anna (cybertailor) Vyalkova
2022-06-06 10:20 ` [gentoo-guru] [PATCH 3/3] dev-cpp/libstudxml: " Anna (cybertailor) Vyalkova

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bcfa928a-8b1f-2c9b-7890-21f3bb31d2db@gentoo.org \
    --to=andrewammerlaan@gentoo.org \
    --cc=gentoo-guru@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox