Gentoo Archives: gentoo-commits

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