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 CB7DB15808B for ; Thu, 31 Mar 2022 07:24:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0B755E07C5; Thu, 31 Mar 2022 07:24:25 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 5BA14E07C5 for ; Thu, 31 Mar 2022 07:24:24 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 smtp.gentoo.org (Postfix) with ESMTPS id E0ACC340F81 for ; Thu, 31 Mar 2022 07:24:22 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3619E317 for ; Thu, 31 Mar 2022 07:24:21 +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: <1648691858.bd38be65c80afe2e7ec56e4cc05b5e8388170fa3.cybertailor@gentoo> Subject: [gentoo-commits] repo/proj/guru:dev commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/qbs.eclass X-VCS-Directories: eclass/ X-VCS-Committer: cybertailor X-VCS-Committer-Name: Anna Vyalkova X-VCS-Revision: bd38be65c80afe2e7ec56e4cc05b5e8388170fa3 X-VCS-Branch: dev Date: Thu, 31 Mar 2022 07:24:21 +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: 5bfc2d6a-abc7-4386-b3f3-aecd78f07f72 X-Archives-Hash: ceb390fef5078072cc4f51743d4fb129 commit: bd38be65c80afe2e7ec56e4cc05b5e8388170fa3 Author: Anna (cybertailor) Vyalkova sysrq in> AuthorDate: Thu Mar 31 01:56:33 2022 +0000 Commit: Anna Vyalkova sysrq in> CommitDate: Thu Mar 31 01:57:38 2022 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=bd38be65 qbs.eclass: new eclass Signed-off-by: Anna (cybertailor) Vyalkova sysrq.in> eclass/qbs.eclass | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) diff --git a/eclass/qbs.eclass b/eclass/qbs.eclass new file mode 100644 index 000000000..6c3f06310 --- /dev/null +++ b/eclass/qbs.eclass @@ -0,0 +1,186 @@ +# Copyright 2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: qbs.eclass +# @AUTHOR: +# Anna Vyalkova +# @MAINTAINER: +# Anna Vyalkova +# @SUPPORTED_EAPIS: 8 +# @PROVIDES: qmake-utils +# @BLURB: eclass to build qbs-based packages +# @DESCRIPTION: +# Utility eclass providing wrapper functions for Qbs build system. + +if [[ ! ${_QBS_ECLASS} ]]; then + +case ${EAPI} in + 8) ;; + *) die "${ECLASS}: EAPI ${EAPI} unsupported." +esac + +inherit multiprocessing toolchain-funcs qmake-utils + +# @ECLASS-VARIABLE: QBS_COMMAND_ECHO_MODE +# @USER_VARIABLE +# @DESCRIPTION: +# Determines what kind of output to show when executing commands. Possible +# values are: +# +# - silent +# +# - summary +# +# - command-line (the default) +# +# - command-line-with-environment +: ${QBS_COMMAND_ECHO_MODE:=command-line} + +BDEPEND="dev-util/qbs" + +EXPORT_FUNCTIONS src_configure src_compile src_install + +# @FUNCTION: eqbs +# @USAGE: [...] +# @DESCRIPTION: +# Run Qbs. This command dies on failure. +eqbs() { + debug-print-function ${FUNCNAME} "${@}" + + set -- qbs "${@}" + einfo "${@}" + "${@}" || die -n + + local ret=${?} + return ${ret} +} + +# @FUNCTION: _flags_to_js_array +# @INTERNAL +# @USAGE: [...] +# @RETURN: arguments quoted and separated by comma +_flags_to_js_array() { + if [[ ! ${@} ]]; then + echo "[]" + else + local -a array + printf -v array "'%s', " "${@}" + echo "[${array%, }]" + fi +} + +# @FUNCTION: _filter_ldflags +# @INTERNAL +# @USAGE: [...] +# @RETURN: flags for the linker (with -Wl and -Xlinker removed) +_filter_ldflags() { + local -a flags + while [[ ${@} ]]; do + if [[ ${1} == -Wl,* ]]; then + IFS=, read -ra flags <<< "${1#-Wl,}" + printf "%s " "${flags[@]}" + elif [[ ${1} == -Xlinker ]]; then + shift + printf "%s " "${1}" + fi + shift + done +} + +# @FUNCTION: qbs_src_configure +# @DESCRIPTION: +# Setup toolchain and Qt for the "gentoo" profile. +# Set Qbs preferences to match user settings. Configure build flags and +# installation prefix. +qbs_src_configure() { + debug-print-function ${FUNCNAME} "${@}" + + eqbs setup-toolchains "$(tc-getCC)" gentooToolchain + eqbs config profiles.gentooToolchain.archiverPath "$(tc-getAR)" + eqbs config profiles.gentooToolchain.assemblerPath "$(tc-getAS)" + eqbs config profiles.gentooToolchain.nmPath "$(tc-getNM)" + eqbs config profiles.gentooToolchain.objcopyPath "$(tc-getOBJCOPY)" + eqbs config profiles.gentooToolchain.stripPath "$(tc-getSTRIP)" + + eqbs setup-qt "$(qt5_get_bindir)/qmake" gentoo + qbs_config baseProfile gentooToolchain + + qbs_config preferences.jobs "$(makeopts_jobs)" + if [[ "${NOCOLOR}" == true || "${NOCOLOR}" == yes ]]; then + qbs_config preferences.useColoredOutput false + fi + + qbs_config qbs.installPrefix "${EPREFIX}/usr" + qbs_config qbs.sysroot "${ESYSROOT}" + qbs_config qbs.optimization "" # don't add unwanted flags + + qbs_config cpp.cFlags "$(_flags_to_js_array ${CFLAGS})" + qbs_config cpp.cppFlags "$(_flags_to_js_array ${CPPFLAGS})" + qbs_config cpp.cxxFlags "$(_flags_to_js_array ${CXXFLAGS})" + qbs_config cpp.linkerFlags "$(_flags_to_js_array $(_filter_ldflags ${LDFLAGS}))" +} + +# @FUNCTION: qbs_config +# @USAGE: +# @DESCRIPTION: +# Set a preference for the "gentoo" profile. +qbs_config() { + debug-print-function ${FUNCNAME} "${@}" + + (( $# == 2 )) || \ + die "${FUNCNAME} takes exactly two arguments" + + local key=${1} + local value=${2} + + eqbs config "profiles.gentoo.${key}" "${value}" +} + +# @FUNCTION: qbs_src_compile +# @USAGE: [...] +# @DESCRIPTION: +# General function for compiling with qbs. All arguments are passed +# to qbs_build. +qbs_src_compile() { + debug-print-function ${FUNCNAME} "${@}" + + qbs_build "${@}" +} + +# @FUNCTION: qbs_build +# @USAGE: [...] +# @DESCRIPTION: +# Build the package using qbs build. +qbs_build() { + debug-print-function ${FUNCNAME} "${@}" + + local qbsargs=( + --no-install + --command-echo-mode "${QBS_COMMAND_ECHO_MODE}" + profile:gentoo + config:release + ) + + eqbs build "${@}" "${qbsargs[@]}" +} + +# @FUNCTION: qbs_src_install +# @USAGE: [...] +# @DESCRIPTION: +# Install the package using qbs install. +qbs_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + local qbsargs=( + --no-build + --install-root "${D}" + --command-echo-mode "${QBS_COMMAND_ECHO_MODE}" + profile:gentoo + config:release + ) + + eqbs install "${@}" "${qbsargs[@]}" +} + +_QBS_ECLASS=1 +fi