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 302FC158009 for ; Mon, 26 Jun 2023 11:24:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CBFC1E0931; Mon, 26 Jun 2023 11:24:24 +0000 (UTC) Received: from smtp.gentoo.org (dev.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)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B5FFDE0931 for ; Mon, 26 Jun 2023 11:24:24 +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 EDD30340DE7 for ; Mon, 26 Jun 2023 11:24:23 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1CD69ACC for ; Mon, 26 Jun 2023 11:24:21 +0000 (UTC) From: "Andrew Ammerlaan" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Andrew Ammerlaan" Message-ID: <1687633985.c64dbb92037c38a5afb44467023b7ece43d662c5.andrewammerlaan@gentoo> Subject: [gentoo-commits] repo/proj/guru:master commit in: eclass/ X-VCS-Repository: repo/proj/guru X-VCS-Files: eclass/mix.eclass X-VCS-Directories: eclass/ X-VCS-Committer: andrewammerlaan X-VCS-Committer-Name: Andrew Ammerlaan X-VCS-Revision: c64dbb92037c38a5afb44467023b7ece43d662c5 X-VCS-Branch: master Date: Mon, 26 Jun 2023 11: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: 20134c95-55f8-431d-aa25-816214239ea4 X-Archives-Hash: 69019011d633a896b76f195114009511 commit: c64dbb92037c38a5afb44467023b7ece43d662c5 Author: Haelwenn (lanodan) Monnier hacktivis me> AuthorDate: Sat Jun 24 19:13:05 2023 +0000 Commit: Andrew Ammerlaan gentoo org> CommitDate: Sat Jun 24 19:13:05 2023 +0000 URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=c64dbb92 mix.eclass: New eclass, used by www-apps/pleroma Signed-off-by: Haelwenn (lanodan) Monnier hacktivis.me> eclass/mix.eclass | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/eclass/mix.eclass b/eclass/mix.eclass new file mode 100644 index 000000000..b7d464731 --- /dev/null +++ b/eclass/mix.eclass @@ -0,0 +1,95 @@ +# Copyright 2019-2023 Haelwenn (lanodan) Monnier +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: mix.eclass +# @MAINTAINER: +# Haelwenn (lanodan) Monnier +# @AUTHOR: +# Haelwenn (lanodan) Monnier +# @SUPPORTED_EAPIS: 6 7 8 +# @BLURB: Build Elixir projects using Elixir's mix +# @DESCRIPTION: +# An eclass providing functions to build Elixir projects using Elixir's mix +# +# mix is a tool which tries to resolve dependencies itself + +case "${EAPI:-0}" in + 0|1|2|3|4|5) + die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}" + ;; + 6|7) + ;; + *) + die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}" + ;; +esac + +EXPORT_FUNCTIONS src_prepare src_compile src_install + +RDEPEND="dev-lang/elixir" +DEPEND="${RDEPEND}" + +# Erlang/Elixir software fails to build when another version with API +# differences is present +BDEPEND="!<${CATEGORY}/${P} !>${CATEGORY}/${P}" + +# @ECLASS-VARIABLE: HEX_OFFLINE +HEX_OFFLINE=1 + +# @ECLASS-VARIABLE: MIX_ENV +MIX_ENV="prod" + +# @ECLASS-VARIABLE: MIX_NO_DEPS +MIX_NO_DEPS=1 + +# @FUNCTION: emix +# @USAGE: +# @DESCRIPTION: +# Run mix with provided arguments. Die on failure +emix() { + debug-print-function ${FUNCNAME} "${@}" + + (( $# > 0 )) || die "emix: at least one target is required" + + MIX_ENV="${MIX_ENV}" mix "$@" || die -n "mix $@ failed" +} + +# @ECLASS-VARIABLE: MIX_REWRITE +MIX_REWRITE="" + +# @ECLASS-VARIABLE: MIX_BUILD_NAME +MIX_BUILD_NAME="${MIX_ENV}" + +# @FUNCTION: mix_src_prepare +mix_src_prepare() { + if [[ "${MIX_REWRITE}" != "" ]] + then + sed -i -E -e 's@\{.*(only|optional): .*},?@@' mix.exs || die "failed removing only & optionnal deps" + rm -f mix.lock + fi + + default +} + +# @FUNCTION: mix_src_compile +# @DESCRIPTION: +# Compile project with mix. +mix_src_compile() { + debug-print-function ${FUNCNAME} "${@}" + + emix compile --no-deps-check +} + +# @FUNCTION: mix_src_install +# @DESCRIPTION: +# Install project with mix. +mix_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + insinto "/usr/$(get_libdir)/elixir/lib/${P}" + pushd "_build/${MIX_BUILD_NAME}/lib/${PN}" >/dev/null + for reldir in src ebin priv include; do + [ -d "$reldir" ] && doins -r "$(realpath ${reldir})" + done + popd >/dev/null +}