logo

overlay

My (experimental) gentoo overlay
commit: c1992a88e1a8acb9a303e04dad69ed2731f837f5
parent: a2a608e80f96c09d79b87d694651155bc15aef97
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 16 Jun 2019 00:42:27 +0200

eclass/mix.eclass: New eclass

Diffstat:

Aeclass/mix.eclass86+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 86 insertions(+), 0 deletions(-)

diff --git a/eclass/mix.eclass b/eclass/mix.eclass @@ -0,0 +1,86 @@ +# Copyright 2019 Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# Distributed under the terms of the GNU General Public License v2 + +# @ECLASS: mix.eclass +# @MAINTAINER: +# Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# @AUTHOR: +# Haelwenn (lanodan) Monnier <contact@hacktivis.me> +# @SUPPORTED_EAPIS: 6 7 +# @BLURB: Build Elixir projects using dev-util/mix. +# @DESCRIPTION: +# An eclass providing functions to build Elixir projects using dev-util/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}" + +# @ECLASS-VARIABLE: MIX_ENV +MIX_ENV="prod" + +# @FUNCTION: emix +# @USAGE: <targets> +# @DESCRIPTION: +# Run mix with whatever. 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 +} + +# @FUNCTION: mix_src_install +# @DESCRIPTION: +# Install project with mix. +mix_src_install() { + debug-print-function ${FUNCNAME} "${@}" + + local dest="/usr/$(get_libdir)/elixir/lib/${P}" + + insinto "${dest}" + pushd "_build/${MIX_BUILD_NAME}/lib/${PN}" >/dev/null + doins -r ebin + popd >/dev/null + [[ -d priv ]] && doins -r priv +}