summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Graaff <graaff@gentoo.org>2021-01-03 07:58:51 +0100
committerHans de Graaff <graaff@gentoo.org>2021-02-07 07:28:43 +0100
commitca7284468286d72f5bf9e2349a0661584bbc59c4 (patch)
tree36c0a6c0b928cb134b36008b09d63d9aa61795f4 /eclass/ruby-fakegem.eclass
parentwww-servers/puma: add 5.2.1 (diff)
downloadgentoo-ca7284468286d72f5bf9e2349a0661584bbc59c4.tar.gz
gentoo-ca7284468286d72f5bf9e2349a0661584bbc59c4.tar.bz2
gentoo-ca7284468286d72f5bf9e2349a0661584bbc59c4.zip
ruby-fakegem.eclass: support for extensions
Up to now handling of extensions was done in each ebuild that contained them. This means that handling is often inconsistent (e.g. not taking multilib's get_modname into account) and there is a lot of duplicated code in ebuilds. Furthermore, this also does not install extensions into the special extensions directory. rubygems itself has been doing this for some time, and now bundler 2.2.x has started to explicitly check for the extensions in this directory, making it incompatibly with our previous way of installing gems. The new RUBY_FAKEGEM_EXTENSIONS array and RUBY_FAKEGEM_EXTENSION_LIBDIR options provide support for installing extensions automatically based on these settings, taking into account that the extensions also must be part of testing and that it must be installed properly. Signed-off-by: Hans de Graaff <graaff@gentoo.org>
Diffstat (limited to 'eclass/ruby-fakegem.eclass')
-rw-r--r--eclass/ruby-fakegem.eclass61
1 files changed, 60 insertions, 1 deletions
diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
index 8ab448765946..f3b3ee02085c 100644
--- a/eclass/ruby-fakegem.eclass
+++ b/eclass/ruby-fakegem.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2020 Gentoo Authors
+# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: ruby-fakegem.eclass
@@ -113,6 +113,20 @@ RUBY_FAKEGEM_BINDIR="${RUBY_FAKEGEM_BINDIR-bin}"
# get installed. Some gems provide extra files such as version information,
# Rails generators, or data that needs to be installed as well.
+# @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTENSIONS
+# @DEFAULT_UNSET
+# @DESCRIPTION
+# List of extensions supported by this gem. Each extension is listed as
+# the configuration script that needs to be run to generate the
+# extension.
+
+# @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTENSION_LIBDIR
+# @DESCRIPTION:
+# The lib directory where extensions are copied directly after they have
+# been compiled. This is needed to run tests on the code and was the
+# legacy way to install extensions for a long time.
+RUBY_FAKEGEM_EXTENSION_LIBDIR="${RUBY_FAKEGEM_EXTENSION_LIBDIR-lib}"
+
case "${EAPI:-0}" in
0|1|2|3)
die "Unsupported EAPI=${EAPI} (too old) for ruby-fakegem.eclass" ;;
@@ -387,6 +401,22 @@ EOF
) || die "Unable to create fakegem wrapper"
}
+# @FUNCTION: each_fakegem_configure
+# @DESCRIPTION:
+# Configure extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
+each_fakegem_configure() {
+ for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
+ ${RUBY} -C ${extension%/*} ${extension##*/} || die
+ done
+}
+
+# @FUNCTION: each_ruby_configure
+# @DESCRIPTION:
+# Run each_fakegem_configure for each ruby target
+each_ruby_configure() {
+ each_fakegem_configure
+}
+
# @FUNCTION: all_fakegem_compile
# @DESCRIPTION:
# Build documentation for the package if indicated by the doc USE flag
@@ -408,6 +438,23 @@ all_fakegem_compile() {
fi
}
+# @FUNCTION: each_fakegem_compile
+# @DESCRIPTION:
+# Compile extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
+each_fakegem_compile() {
+ for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
+ emake V=1 -C ${extension%/*}
+ cp "${extension%/*}"/*$(get_modname) "${RUBY_FAKEGEM_EXTENSION_LIBDIR}" || die "Copy of extension into ${RUBY_FAKEGEM_EXTENSION_LIBDIR} failed"
+ done
+}
+
+# @FUNCTION: each_ruby_compile
+# @DESCRIPTION:
+# Run each_fakegem_compile for each ruby target
+each_ruby_compile() {
+ each_fakegem_compile
+}
+
# @FUNCTION: all_ruby_unpack
# @DESCRIPTION:
# Unpack the source archive, including support for unpacking gems.
@@ -506,6 +553,18 @@ each_fakegem_install() {
[[ -n ${_gemlibdirs} ]] && \
ruby_fakegem_doins -r ${_gemlibdirs}
+
+ if [[ -n ${RUBY_FAKEGEM_EXTENSIONS} ]] && [ ${#RUBY_FAKEGEM_EXTENSIONS[@]} -ge 0 ]; then
+ einfo "installing extensions"
+ local _extensionsdir="$(ruby_fakegem_gemsdir)/extensions/$(ruby_rbconfig_value 'arch')/$(ruby_rbconfig_value 'ruby_version')/${RUBY_FAKEGEM_NAME}-${RUBY_FAKEGEM_VERSION}"
+
+ for extension in ${RUBY_FAKEGEM_EXTENSIONS[@]} ; do
+ emake V=1 sitearchdir="${D}/${_extensionsdir}" -C ${extension%/*} install
+ done
+
+ # Add the marker to indicate that the extensions are installed
+ touch "${D}${_extensionsdir}/gem.build_complete" || die
+ fi
}
# @FUNCTION: each_ruby_install