diff options
-rw-r--r-- | eclass/ruby-fakegem.eclass | 61 |
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 |