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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 8F2DF158091 for ; Tue, 7 Jun 2022 06:26:49 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6231CE089C; Tue, 7 Jun 2022 06:26:47 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 4557CE089C for ; Tue, 7 Jun 2022 06:26:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5F1A8341773 for ; Tue, 7 Jun 2022 06:26:45 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E9612326 for ; Tue, 7 Jun 2022 06:26:43 +0000 (UTC) From: "Anna Vyalkova" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anna Vyalkova" Message-ID: <1654583163.3358a8f78e1177010e6653fa2eb084b02b0f4ead.cybertailor@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/build2.eclass X-VCS-Directories: eclass/ X-VCS-Committer: cybertailor X-VCS-Committer-Name: Anna Vyalkova X-VCS-Revision: 3358a8f78e1177010e6653fa2eb084b02b0f4ead X-VCS-Branch: dev Date: Tue, 7 Jun 2022 06:26:43 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b7a61e76-45a7-4d17-b222-588570013714 X-Archives-Hash: a2aa9fd5e8cb5a7dda878b46010e7598 commit: 3358a8f78e1177010e6653fa2eb084b02b0f4ead Author: Anna (cybertailor) Vyalkova sysrq in> AuthorDate: Mon Jun 6 10:05:42 2022 +0000 Commit: Anna Vyalkova sysrq in> CommitDate: Tue Jun 7 06:26:03 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=3358a8f7 build2.eclass: new eclass Signed-off-by: Anna (cybertailor) Vyalkova sysrq.in> eclass/build2.eclass | 150 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) 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 +# @AUTHOR: +# Anna Vyalkova +# @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 + +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: [...] +# @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: [...] +# @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: [...] +# @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