public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] ruby-fakegem.eclass: add support for compiled extensions
@ 2021-01-31  9:00 Hans de Graaff
  2021-01-31  9:02 ` [gentoo-dev] [PATCH] dev-ruby/msgpack: use new extension support Hans de Graaff
  0 siblings, 1 reply; 2+ messages in thread
From: Hans de Graaff @ 2021-01-31  9:00 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 4263 bytes --]

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.

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_valu
e '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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-dev] [PATCH] dev-ruby/msgpack: use new extension support
  2021-01-31  9:00 [gentoo-dev] [PATCH] ruby-fakegem.eclass: add support for compiled extensions Hans de Graaff
@ 2021-01-31  9:02 ` Hans de Graaff
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Graaff @ 2021-01-31  9:02 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1178 bytes --]

--- msgpack-1.3.3.ebuild	2020-06-13 08:28:00.023541920 +0200
+++ msgpack-1.3.3-r1.ebuild	2021-01-31 09:51:25.856505887 +0100
@@ -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
 
 EAPI=7
@@ -8,7 +8,10 @@
 RUBY_FAKEGEM_RECIPE_TEST="rspec3"
 RUBY_FAKEGEM_EXTRADOC="README.rdoc"
 
-inherit multilib ruby-fakegem
+RUBY_FAKEGEM_EXTENSIONS=(ext/msgpack/extconf.rb)
+RUBY_FAKEGEM_EXTENSION_LIBDIR="lib/msgpack"
+
+inherit ruby-fakegem
 
 DESCRIPTION="Binary-based efficient data interchange format for ruby
binding"
 HOMEPAGE="https://msgpack.org/"
@@ -26,16 +29,3 @@
 
 	sed -i -e '/git ls-files/d' msgpack.gemspec || die
 }
-
-each_ruby_configure() {
-	${RUBY} -Cext/${PN} extconf.rb || die "Configuration of
extension failed."
-
-	# rb_num2int is not inlined on 32 bit arches but also not
explicitly
-	# defined, bug 582968
-	sed -i -e 's:-Wl,--no-undefined::' ext/${PN}/Makefile || die
-}
-
-each_ruby_compile() {
-	emake V=1 -Cext/${PN}
-	cp ext/${PN}/msgpack$(get_modname) lib/${PN} || die "Unable to
install msgpack library."
-}

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-31  9:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-31  9:00 [gentoo-dev] [PATCH] ruby-fakegem.eclass: add support for compiled extensions Hans de Graaff
2021-01-31  9:02 ` [gentoo-dev] [PATCH] dev-ruby/msgpack: use new extension support Hans de Graaff

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox