* [gentoo-dev] Re: [PATCH 2/2] rebar3.eclass: add new eclass
[not found] ` <20240710071916.116114-3-flo@geekplace.eu>
@ 2024-07-11 3:38 ` Anna (cybertailor) Vyalkova
2024-07-15 2:39 ` Eli Schwartz
0 siblings, 1 reply; 3+ messages in thread
From: Anna (cybertailor) Vyalkova @ 2024-07-11 3:38 UTC (permalink / raw
To: gentoo-dev; +Cc: contact
On 2024-07-10 09:19, Florian Schmaus wrote:
>From: Florian Schmaus <flow@gentoo.org>
>
>Add a new eclass for dev-util/rebar:3, based on the work of Anna
>Vyalkova in ::guru (thanks!).
There's also rebar3.eclass in lanodanOverlay, hereby CC-ing Haelwenn on
this.
>The Erlang/OTP ecosystem is moving to Rebar3. Upstreams start to drop
>support for Rebar2, or at least consider it.
>
>Signed-off-by: Florian Schmaus <flow@gentoo.org>
>---
> eclass/rebar3.eclass | 204 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 204 insertions(+)
> create mode 100644 eclass/rebar3.eclass
>
>diff --git a/eclass/rebar3.eclass b/eclass/rebar3.eclass
>new file mode 100644
>index 000000000000..83363ab54602
>--- /dev/null
>+++ b/eclass/rebar3.eclass
>@@ -0,0 +1,204 @@
>+# Copyright 1999-2024 Gentoo Authors
>+# Distributed under the terms of the GNU General Public License v2
>+
>+# @ECLASS: rebar3.eclass
>+# @MAINTAINER:
>+# Florian Schmaus <flow@gentoo.org>
>+# @AUTHOR:
>+# Amadeusz Żołnowski <aidecoe@gentoo.org>
>+# Anna (cybertailor) Vyalkova <cyber+gentoo@sysrq.in>
>+# @SUPPORTED_EAPIS: 8
>+# @PROVIDES: rebar-utils
>+# @BLURB: Build Erlang/OTP projects using dev-util/rebar:3.
>+# @DESCRIPTION:
>+# An eclass providing functions to build Erlang/OTP projects using
>+# dev-util/rebar:3.
>+#
>+# rebar is a tool which tries to resolve dependencies itself which is by
>+# cloning remote git repositories. Dependent projects are usually expected to
>+# be in sub-directory 'deps' rather than looking at system Erlang lib
>+# directory. Projects relying on rebar usually don't have 'install' make
>+# targets. The eclass workarounds some of these problems. It handles
>+# installation in a generic way for Erlang/OTP structured projects.
>+
>+case ${EAPI} in
>+ 8) ;;
>+ *) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
>+esac
>+
>+if [[ -z ${_REBAR3_ECLASS} ]]; then
>+_REBAR3_ECLASS=1
>+
>+inherit edo rebar-utils
>+
>+RDEPEND="dev-lang/erlang:="
>+DEPEND="${RDEPEND}"
>+BDEPEND="
>+ dev-util/rebar:3
>+ >=sys-apps/gawk-4.1
>+"
>+
>+# @ECLASS_VARIABLE: REBAR_PROFILE
>+# @DESCRIPTION:
>+# Rebar profile to use.
>+: "${REBAR_PROFILE:=default}"
>+
>+# @ECLASS_VARIABLE: REBAR_APP_SRC
>+# @DESCRIPTION:
>+# Relative path to .app.src description file.
>+: "${REBAR_APP_SRC:=src/${PN}.app.src}"
>+
>+# @FUNCTION: get_erl_libs
>+# @RETURN: the path to Erlang lib directory
>+# @DESCRIPTION:
>+# Get the full path without EPREFIX to Erlang lib directory.
>+get_erl_libs() {
>+ echo "/usr/$(get_libdir)/erlang/lib"
>+}
>+
>+# @FUNCTION: _rebar_find_dep
>+# @INTERNAL
>+# @USAGE: <project_name>
>+# @RETURN: 0 success, 1 dependency not found, 2 multiple versions found
>+# @DESCRIPTION:
>+# Find a Erlang package/project by name in Erlang lib directory. Project
>+# directory is usually suffixed with version. It is matched to '<project_name>'
>+# or '<project_name>-*'.
>+_rebar_find_dep() {
>+ local pn="${1}"
>+ local p
>+ local result
>+
>+ pushd "${EPREFIX}$(get_erl_libs)" >/dev/null || return 1
>+ for p in ${pn} ${pn}-*; do
>+ if [[ -d ${p} ]]; then
>+ # Ensure there's at most one matching.
>+ [[ ${result} ]] && return 2
>+ result="${p}"
>+ fi
>+ done
>+ popd >/dev/null || die
>+
>+ [[ ${result} ]] || return 1
>+ echo "${result}"
>+}
>+
>+# @FUNCTION: erebar3
>+# @USAGE: <targets>
>+# @DESCRIPTION:
>+# Run rebar with verbose flag. Die on failure.
>+erebar3() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ (( $# > 0 )) || die "erebar: at least one target is required"
Oversight, should be ${FUNCNAME} instead of "erebar" (old name).
>+
>+ case ${1} in
>+ eunit|ct)
>+ local -x ERL_LIBS="." ;;
>+ *)
>+ local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)" ;;
>+ esac
>+
>+ edo rebar3 "$@"
>+}
>+
>+# @FUNCTION: rebar3_src_prepare
>+# @DESCRIPTION:
>+# Prevent rebar from fetching and compiling dependencies. Set version in
Ditto.
>+# project description file if it's not set.
>+#
>+# Existence of rebar.config is optional, but file description file must exist
>+# at 'src/${PN}.app.src'.
>+rebar3_src_prepare() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ default_src_prepare
>+ rebar_set_vsn
>+
>+ if [[ -f rebar.lock ]]; then
>+ rm rebar.lock || die
>+ fi
>+
>+ if [[ -f rebar.config ]]; then
>+ rebar_disable_coverage
>+ rebar_remove_deps
>+ fi
>+}
>+
>+# @FUNCTION: rebar3_src_configure
>+# @DESCRIPTION:
>+# Configure with ERL_LIBS set.
>+rebar3_src_configure() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ local -x ERL_LIBS="${EPREFIX}$(get_erl_libs)"
>+ default_src_configure
>+}
>+
>+# @FUNCTION: rebar3_src_compile
>+# @DESCRIPTION:
>+# Compile project with rebar.
Ditto.
>+rebar3_src_compile() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ erebar3 as "${REBAR_PROFILE}" release --all
>+}
>+
>+# @FUNCTION: rebar3_src_test
>+# @DESCRIPTION:
>+# Run unit tests.
>+rebar3_src_test() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ erebar3 eunit -v
>+}
>+
>+# @FUNCTION: rebar3_install_lib
>+# @USAGE: <dir>
>+# @DESCRIPTION:
>+# Install BEAM files, include headers and native libraries.
>+#
>+# Function expects that project conforms to Erlang/OTP structure.
>+rebar3_install_lib() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ local dest="$(get_erl_libs)/${P}"
>+
>+ pushd "${1?}" >/dev/null || die
>+ for dir in ebin include priv; do
>+ if [[ -d ${dir} && ! -L ${dir} ]]; then
>+ cp -pR "${dir}" "${ED%/}${dest}/" || die "failed to install ${dir}/"
>+ fi
>+ done
>+ popd >/dev/null || die
>+}
>+
>+# @FUNCTION: rebar3_src_install
>+# @DESCRIPTION:
>+# Install built release or library.
>+#
>+# Function expects that project conforms to Erlang/OTP structure.
>+rebar3_src_install() {
>+ debug-print-function ${FUNCNAME} "${@}"
>+
>+ pushd "_build/${REBAR_PROFILE}" >/dev/null || die
>+ if [[ -d rel/${PN} ]]; then
>+ if ! declare -f rebar3_install_release >/dev/null; then
>+ die "${FUNCNAME}: a custom function named 'rebar3_install_release' is required to install a release"
>+ fi
>+ pushd rel/${PN} >/dev/null || die
>+ rebar3_install_release || die
>+ popd >/dev/null || die
>+ elif [[ -d lib/${PN} ]]; then
>+ rebar3_install_lib lib/${PN}
>+ else
>+ die "No releases or libraries to install"
>+ fi
>+ popd >/dev/null || die
>+
>+ einstalldocs
>+}
>+
>+fi
>+
>+EXPORT_FUNCTIONS src_prepare src_compile src_test src_install
>--
>2.44.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] Re: [PATCH 2/2] rebar3.eclass: add new eclass
2024-07-11 3:38 ` [gentoo-dev] Re: [PATCH 2/2] rebar3.eclass: add new eclass Anna (cybertailor) Vyalkova
@ 2024-07-15 2:39 ` Eli Schwartz
2024-07-15 19:33 ` Florian Schmaus
0 siblings, 1 reply; 3+ messages in thread
From: Eli Schwartz @ 2024-07-15 2:39 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 811 bytes --]
On 7/10/24 11:38 PM, Anna (cybertailor) Vyalkova wrote:
> On 2024-07-10 09:19, Florian Schmaus wrote:
>> From: Florian Schmaus <flow@gentoo.org>
>>
>> Add a new eclass for dev-util/rebar:3, based on the work of Anna
>> Vyalkova in ::guru (thanks!).
>
> There's also rebar3.eclass in lanodanOverlay, hereby CC-ing Haelwenn on
> this.
>
>> The Erlang/OTP ecosystem is moving to Rebar3. Upstreams start to drop
>> support for Rebar2, or at least consider it.
Hello.
I can't find the first part of this email thread, including the actual
submission of the eclass for review to the mailing list. Was this a
private conversation?
I notice that it *has* been committed by Flow to ::gentoo already, and
your request for Haelwenn's feedback hasn't yet been answered.
--
Eli Schwartz
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [gentoo-dev] Re: [PATCH 2/2] rebar3.eclass: add new eclass
2024-07-15 2:39 ` Eli Schwartz
@ 2024-07-15 19:33 ` Florian Schmaus
0 siblings, 0 replies; 3+ messages in thread
From: Florian Schmaus @ 2024-07-15 19:33 UTC (permalink / raw
To: gentoo-dev, Eli Schwartz; +Cc: Anna (cybertailor) Vyalkova
[-- Attachment #1.1.1: Type: text/plain, Size: 1584 bytes --]
On 15/07/2024 04.39, Eli Schwartz wrote:
> On 7/10/24 11:38 PM, Anna (cybertailor) Vyalkova wrote:
>> On 2024-07-10 09:19, Florian Schmaus wrote:
>>> From: Florian Schmaus <flow@gentoo.org>
>>>
>>> Add a new eclass for dev-util/rebar:3, based on the work of Anna
>>> Vyalkova in ::guru (thanks!).
>>
>> There's also rebar3.eclass in lanodanOverlay, hereby CC-ing Haelwenn on
>> this.
>>
>>> The Erlang/OTP ecosystem is moving to Rebar3. Upstreams start to drop
>>> support for Rebar2, or at least consider it.
>
> I can't find the first part of this email thread, including the actual
> submission of the eclass for review to the mailing list. Was this a
> private conversation?
No it wasn't a private conversation. But unfortunately I've used the
wrong 'from' address, my personal one instead of the @gentoo.org
address, so the mails did not went through. However, I didn't notice it,
since the mails appeared in my inbox (due to me being CC'ed).
I'll resend the patchset again, probably the first thing I'll do
tomorrow. Sorry for the inconvenience.
> I notice that it *has* been committed by Flow to ::gentoo already, and
> your request for Haelwenn's feedback hasn't yet been answered.
I looked at the rebar3.eclass from the lanodanOverlay before pushing the
new eclass, there seem to be no relevant differences from the one in
::guru/::gentoo. Judging from the commit history of rebar3.eclass in
lanodanOverlay and in ::guru, it appears that the one in ::guru used
lanodanOverlay's rebar3.eclass as starting point.
- Flow
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 21567 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 618 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-07-15 19:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20240710071916.116114-1-flo@geekplace.eu>
[not found] ` <20240710071916.116114-3-flo@geekplace.eu>
2024-07-11 3:38 ` [gentoo-dev] Re: [PATCH 2/2] rebar3.eclass: add new eclass Anna (cybertailor) Vyalkova
2024-07-15 2:39 ` Eli Schwartz
2024-07-15 19:33 ` Florian Schmaus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox