Gentoo Archives: gentoo-dev

From: Hans de Graaff <graaff@g.o>
To: gentoo-dev <gentoo-dev@l.g.o>
Subject: [gentoo-dev] [PATCH] ruby-fakegem.eclass: add support for compiled extensions
Date: Sun, 31 Jan 2021 09:00:45
Message-Id: b6f351718500a411f22ec5ae5b103b4c50040f14.camel@gentoo.org
1 Up to now handling of extensions was done in each ebuild that
2 contained them. This means that handling is often
3 inconsistent (e.g. not taking multilib's get_modname into account) and
4 there is a lot of duplicated code in ebuilds.
5
6 Furthermore, this also does not install extensions into the special
7 extensions directory. rubygems itself has been doing this for some
8 time, and now bundler 2.2.x has started to explicitly check for the
9 extensions in this directory, making it incompatibly with our previous
10 way of installing gems.
11
12 The new RUBY_FAKEGEM_EXTENSIONS array and
13 RUBY_FAKEGEM_EXTENSION_LIBDIR options provide support for installing
14 extensions automatically based on these settings, taking into account
15 that the extensions also must be part of testing and that it must be
16 installed properly.
17
18 diff --git a/eclass/ruby-fakegem.eclass b/eclass/ruby-fakegem.eclass
19 index 8ab448765946..f3b3ee02085c 100644
20 --- a/eclass/ruby-fakegem.eclass
21 +++ b/eclass/ruby-fakegem.eclass
22 @@ -1,4 +1,4 @@
23 -# Copyright 1999-2020 Gentoo Authors
24 +# Copyright 1999-2021 Gentoo Authors
25 # Distributed under the terms of the GNU General Public License v2
26
27 # @ECLASS: ruby-fakegem.eclass
28 @@ -113,6 +113,20 @@ RUBY_FAKEGEM_BINDIR="${RUBY_FAKEGEM_BINDIR-bin}"
29 # get installed. Some gems provide extra files such as version
30 information,
31 # Rails generators, or data that needs to be installed as well.
32
33 +# @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTENSIONS
34 +# @DEFAULT_UNSET
35 +# @DESCRIPTION
36 +# List of extensions supported by this gem. Each extension is listed
37 as
38 +# the configuration script that needs to be run to generate the
39 +# extension.
40 +
41 +# @ECLASS-VARIABLE: RUBY_FAKEGEM_EXTENSION_LIBDIR
42 +# @DESCRIPTION:
43 +# The lib directory where extensions are copied directly after they
44 have
45 +# been compiled. This is needed to run tests on the code and was the
46 +# legacy way to install extensions for a long time.
47 +RUBY_FAKEGEM_EXTENSION_LIBDIR="${RUBY_FAKEGEM_EXTENSION_LIBDIR-lib}"
48 +
49 case "${EAPI:-0}" in
50 0|1|2|3)
51 die "Unsupported EAPI=${EAPI} (too old) for ruby-
52 fakegem.eclass" ;;
53 @@ -387,6 +401,22 @@ EOF
54 ) || die "Unable to create fakegem wrapper"
55 }
56
57 +# @FUNCTION: each_fakegem_configure
58 +# @DESCRIPTION:
59 +# Configure extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
60 +each_fakegem_configure() {
61 + for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
62 + ${RUBY} -C ${extension%/*} ${extension##*/} || die
63 + done
64 +}
65 +
66 +# @FUNCTION: each_ruby_configure
67 +# @DESCRIPTION:
68 +# Run each_fakegem_configure for each ruby target
69 +each_ruby_configure() {
70 + each_fakegem_configure
71 +}
72 +
73 # @FUNCTION: all_fakegem_compile
74 # @DESCRIPTION:
75 # Build documentation for the package if indicated by the doc USE flag
76 @@ -408,6 +438,23 @@ all_fakegem_compile() {
77 fi
78 }
79
80 +# @FUNCTION: each_fakegem_compile
81 +# @DESCRIPTION:
82 +# Compile extensions defined in RUBY_FAKEGEM_EXTENSIONS, if any.
83 +each_fakegem_compile() {
84 + for extension in "${RUBY_FAKEGEM_EXTENSIONS[@]}" ; do
85 + emake V=1 -C ${extension%/*}
86 + cp "${extension%/*}"/*$(get_modname)
87 "${RUBY_FAKEGEM_EXTENSION_LIBDIR}" || die "Copy of extension into
88 ${RUBY_FAKEGEM_EXTENSION_LIBDIR} failed"
89 + done
90 +}
91 +
92 +# @FUNCTION: each_ruby_compile
93 +# @DESCRIPTION:
94 +# Run each_fakegem_compile for each ruby target
95 +each_ruby_compile() {
96 + each_fakegem_compile
97 +}
98 +
99 # @FUNCTION: all_ruby_unpack
100 # @DESCRIPTION:
101 # Unpack the source archive, including support for unpacking gems.
102 @@ -506,6 +553,18 @@ each_fakegem_install() {
103
104 [[ -n ${_gemlibdirs} ]] && \
105 ruby_fakegem_doins -r ${_gemlibdirs}
106 +
107 + if [[ -n ${RUBY_FAKEGEM_EXTENSIONS} ]] && [
108 ${#RUBY_FAKEGEM_EXTENSIONS[@]} -ge 0 ]; then
109 + einfo "installing extensions"
110 + local
111 _extensionsdir="$(ruby_fakegem_gemsdir)/extensions/$(ruby_rbconfig_valu
112 e 'arch')/$(ruby_rbconfig_value 'ruby_version')/${RUBY_FAKEGEM_NAME}-
113 ${RUBY_FAKEGEM_VERSION}"
114 +
115 + for extension in ${RUBY_FAKEGEM_EXTENSIONS[@]} ; do
116 + emake V=1 sitearchdir="${D}/${_extensionsdir}"
117 -C ${extension%/*} install
118 + done
119 +
120 + # Add the marker to indicate that the extensions are
121 installed
122 + touch "${D}${_extensionsdir}/gem.build_complete" || die
123 + fi
124 }
125
126 # @FUNCTION: each_ruby_install

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
[gentoo-dev] [PATCH] dev-ruby/msgpack: use new extension support Hans de Graaff <graaff@g.o>