/[gentoo-x86]/eclass/ruby-ng.eclass
Gentoo

Diff of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 Revision 1.53
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2013 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.1 2009/12/05 09:35:48 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.53 2013/12/26 07:11:48 graaff Exp $
4# 4
5# @ECLASS: ruby-ng.eclass 5# @ECLASS: ruby-ng.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ruby herd <ruby@gentoo.org> 7# Ruby herd <ruby@gentoo.org>
8# 8# @AUTHOR:
9# Author: Diego E. Pettenò <flameeyes@gentoo.org> 9# Author: Diego E. Pettenò <flameeyes@gentoo.org>
10#
11# Author: Alex Legler <a3li@gentoo.org> 10# Author: Alex Legler <a3li@gentoo.org>
12#
13# Author: Hans de Graaff <graaff@gentoo.org> 11# Author: Hans de Graaff <graaff@gentoo.org>
14#
15# @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots. 12# @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots.
16# @DESCRIPTION: 13# @DESCRIPTION:
17# The Ruby eclass is designed to allow an easier installation of Ruby packages 14# The Ruby eclass is designed to allow an easier installation of Ruby packages
18# and their incorporation into the Gentoo Linux system. 15# and their incorporation into the Gentoo Linux system.
19# 16#
20# Currently available targets are: 17# Currently available targets are:
21# * ruby18 - Ruby (MRI) 1.8.x 18# * ruby18 - Ruby (MRI) 1.8.x
22# * ruby19 - Ruby (MRI) 1.9.x 19# * ruby19 - Ruby (MRI) 1.9.x
20# * ruby20 - Ruby (MRI) 2.0.x
21# * ruby21 - Ruby (MRI) 2.1.x
23# * ree18 - Ruby Enterprise Edition 1.8.x 22# * ree18 - Ruby Enterprise Edition 1.8.x
24# * jruby - JRuby 23# * jruby - JRuby
24# * rbx - Rubinius
25# 25#
26# This eclass does not define the implementation of the configure, 26# This eclass does not define the implementation of the configure,
27# compile, test, or install phases. Instead, the default phases are 27# compile, test, or install phases. Instead, the default phases are
28# used. Specific implementations of these phases can be provided in 28# used. Specific implementations of these phases can be provided in
29# the ebuild either to be run for each Ruby implementation, or for all 29# the ebuild either to be run for each Ruby implementation, or for all
31# 31#
32# * each_ruby_configure 32# * each_ruby_configure
33# * all_ruby_configure 33# * all_ruby_configure
34 34
35# @ECLASS-VARIABLE: USE_RUBY 35# @ECLASS-VARIABLE: USE_RUBY
36# @REQUIRED
36# @DESCRIPTION: 37# @DESCRIPTION:
37# This variable contains a space separated list of targets (see above) a package 38# This variable contains a space separated list of targets (see above) a package
38# is compatible to. It must be set before the `inherit' call. There is no 39# is compatible to. It must be set before the `inherit' call. There is no
39# default. All ebuilds are expected to set this variable. 40# default. All ebuilds are expected to set this variable.
40 41
41# @ECLASS-VARIABLE: RUBY_PATCHES 42# @ECLASS-VARIABLE: RUBY_PATCHES
43# @DEFAULT_UNSET
42# @DESCRIPTION: 44# @DESCRIPTION:
43# A String or Array of filenames of patches to apply to all implementations. 45# A String or Array of filenames of patches to apply to all implementations.
44 46
45# @ECLASS-VARIABLE: RUBY_OPTIONAL 47# @ECLASS-VARIABLE: RUBY_OPTIONAL
46# @DESCRIPTION: 48# @DESCRIPTION:
47# Set the value to "yes" to make the dependency on a Ruby interpreter optional. 49# Set the value to "yes" to make the dependency on a Ruby interpreter
50# optional and then ruby_implementations_depend() to help populate
51# DEPEND and RDEPEND.
48 52
49inherit eutils toolchain-funcs 53# @ECLASS-VARIABLE: RUBY_S
54# @DEFAULT_UNSET
55# @DESCRIPTION:
56# If defined this variable determines the source directory name after
57# unpacking. This defaults to the name of the package. Note that this
58# variable supports a wildcard mechanism to help with github tarballs
59# that contain the commit hash as part of the directory name.
60
61# @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
62# @DEFAULT_UNSET
63# @DESCRIPTION:
64# If defined this variable contains a whitelist of shared objects that
65# are allowed to exist even if they don't link to libruby. This avoids
66# the QA check that makes this mandatory. This is most likely not what
67# you are looking for if you get the related "Missing links" QA warning,
68# since the proper fix is almost always to make sure the shared object
69# is linked against libruby. There are cases were this is not the case
70# and the shared object is generic code to be used in some other way
71# (e.g. selenium's firefox driver extension). When set this argument is
72# passed to "grep -E" to remove reporting of these shared objects.
73
74inherit eutils java-utils-2 multilib toolchain-funcs
50 75
51EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup 76EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
52 77
53case ${EAPI} in 78case ${EAPI} in
54 0|1) 79 0|1)
55 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; 80 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
56 2) ;; 81 2|3) ;;
82 4|5)
83 # S is no longer automatically assigned when it doesn't exist.
84 S="${WORKDIR}"
85 ;;
57 *) 86 *)
58 die "Unknown EAPI=${EAPI} for ruby-ng.eclass" 87 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
59esac 88esac
60 89
61# @FUNCTION: ruby_implementation_depend 90# @FUNCTION: ruby_implementation_depend
79 ;; 108 ;;
80 ruby19) 109 ruby19)
81 rubypn="dev-lang/ruby" 110 rubypn="dev-lang/ruby"
82 rubyslot=":1.9" 111 rubyslot=":1.9"
83 ;; 112 ;;
113 ruby20)
114 rubypn="dev-lang/ruby"
115 rubyslot=":2.0"
116 ;;
117 ruby21)
118 rubypn="dev-lang/ruby"
119 rubyslot=":2.1"
120 ;;
84 ree18) 121 ree18)
85 rubypn="dev-lang/ruby-enterprise" 122 rubypn="dev-lang/ruby-enterprise"
86 rubyslot=":1.8" 123 rubyslot=":1.8"
87 ;; 124 ;;
88 jruby) 125 jruby)
89 rubypn="dev-java/jruby" 126 rubypn="dev-java/jruby"
127 rubyslot=""
128 ;;
129 rbx)
130 rubypn="dev-lang/rubinius"
90 rubyslot="" 131 rubyslot=""
91 ;; 132 ;;
92 *) die "$1: unknown Ruby implementation" 133 *) die "$1: unknown Ruby implementation"
93 esac 134 esac
94 135
110 done 151 done
111 152
112 echo "[${res%,}]" 153 echo "[${res%,}]"
113} 154}
114 155
156_ruby_atoms_samelib_generic() {
157 eshopts_push -o noglob
158 echo "RUBYTARGET? ("
159 for token in $*; do
160 case "$token" in
161 "||" | "(" | ")" | *"?")
162 echo "${token}" ;;
163 *])
164 echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
165 *)
166 echo "${token}[RUBYTARGET]" ;;
167 esac
168 done
169 echo ")"
170 eshopts_pop
171}
172
173# @FUNCTION: ruby_implementation_command
174# @RETURN: the path to the given ruby implementation
175# @DESCRIPTION:
176# Not all implementations have the same command basename as the
177# target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
178# respectively. This function translate between the two
115_ruby_implementation_depend() { 179ruby_implementation_command() {
116 echo "ruby_targets_${1}? ( ${2}[ruby_targets_${1}] )" 180 local _ruby_name=$1
117}
118 181
119_ruby_add_bdepend() { 182 # Add all USE_RUBY values where the flag name diverts from the binary here
120 local atom=$1 183 case $1 in
184 ree18)
185 _ruby_name=rubyee18
186 ;;
187 esac
188
189 echo $(type -p ${_ruby_name} 2>/dev/null)
190}
191
192_ruby_atoms_samelib() {
193 local atoms=$(_ruby_atoms_samelib_generic "$*")
194
195 for _ruby_implementation in $USE_RUBY; do
196 echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
197 done
198}
199
200_ruby_wrap_conditions() {
121 local conditions=$2 201 local conditions="$1"
202 local atoms="$2"
122 203
123 for condition in $conditions; do 204 for condition in $conditions; do
124 atom="${condition}? ( ${atom} )" 205 atoms="${condition}? ( ${atoms} )"
125 done 206 done
126 207
127 DEPEND="${DEPEND} ${atom}" 208 echo "$atoms"
209}
210
211# @FUNCTION: ruby_add_rdepend
212# @USAGE: dependencies
213# @DESCRIPTION:
214# Adds the specified dependencies, with use condition(s) to RDEPEND,
215# taking the current set of ruby targets into account. This makes sure
216# that all ruby dependencies of the package are installed for the same
217# ruby targets. Use this function for all ruby dependencies instead of
218# setting RDEPEND yourself. The list of atoms uses the same syntax as
219# normal dependencies.
220#
221# Note: runtime dependencies are also added as build-time test
222# dependencies.
223ruby_add_rdepend() {
224 case $# in
225 1) ;;
226 2)
227 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF"
228 ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")"
229 return
230 ;;
231 *)
232 die "bad number of arguments to $0"
233 ;;
234 esac
235
236 local dependency=$(_ruby_atoms_samelib "$1")
237
238 RDEPEND="${RDEPEND} $dependency"
239
240 # Add the dependency as a test-dependency since we're going to
241 # execute the code during test phase.
242 DEPEND="${DEPEND} test? ( ${dependency} )"
243 has test "$IUSE" || IUSE="${IUSE} test"
244}
245
246# @FUNCTION: ruby_add_bdepend
247# @USAGE: dependencies
248# @DESCRIPTION:
249# Adds the specified dependencies, with use condition(s) to DEPEND,
250# taking the current set of ruby targets into account. This makes sure
251# that all ruby dependencies of the package are installed for the same
252# ruby targets. Use this function for all ruby dependencies instead of
253# setting DEPEND yourself. The list of atoms uses the same syntax as
254# normal dependencies.
255ruby_add_bdepend() {
256 case $# in
257 1) ;;
258 2)
259 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF"
260 ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")"
261 return
262 ;;
263 *)
264 die "bad number of arguments to $0"
265 ;;
266 esac
267
268 local dependency=$(_ruby_atoms_samelib "$1")
269
270 DEPEND="${DEPEND} $dependency"
128 RDEPEND="${RDEPEND}" 271 RDEPEND="${RDEPEND}"
129} 272}
130 273
131_ruby_add_rdepend() { 274# @FUNCTION: ruby_get_use_implementations
132 local atom=$1 275# @DESCRIPTION:
133 local conditions=$2 276# Gets an array of ruby use targets enabled by the user
134 277ruby_get_use_implementations() {
135 for condition in $conditions; do 278 local i implementation
136 atom="${condition}? ( ${atom} )" 279 for implementation in ${USE_RUBY}; do
280 use ruby_targets_${implementation} && i+=" ${implementation}"
137 done 281 done
282 echo $i
283}
138 284
285# @FUNCTION: ruby_get_use_targets
286# @DESCRIPTION:
287# Gets an array of ruby use targets that the ebuild sets
288ruby_get_use_targets() {
289 local t implementation
290 for implementation in ${USE_RUBY}; do
291 t+=" ruby_targets_${implementation}"
292 done
293 echo $t
294}
295
296# @FUNCTION: ruby_implementations_depend
297# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
298# @DESCRIPTION:
299# Produces the dependency string for the various implementations of ruby
300# which the package is being built against. This should not be used when
301# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
302# confuse this function with ruby_implementation_depend().
303#
304# @EXAMPLE:
305# EAPI=4
306# RUBY_OPTIONAL=yes
307#
308# inherit ruby-ng
309# ...
310# DEPEND="ruby? ( $(ruby_implementations_depend) )"
139 RDEPEND="${RDEPEND} ${atom}" 311# RDEPEND="${DEPEND}"
140 _ruby_add_bdepend "$atom" test 312ruby_implementations_depend() {
141} 313 local depend
142
143# @FUNCTION: ruby_add_rdepend
144# @USAGE: [conditions] atom
145# @DESCRIPTION:
146# Adds the specified atom(s) with optional use condition(s) to
147# RDEPEND, taking the current set of ruby targets into account. This
148# makes sure that all ruby dependencies of the package are installed
149# for the same ruby targets. Use this function for all ruby
150# dependencies instead of setting RDEPEND yourself. Both atom and
151# conditions can be a space-separated list of atoms or conditions.
152ruby_add_rdepend() {
153 local atoms=
154 local conditions=
155 case $# in
156 1)
157 atoms=$1
158 ;;
159 2)
160 conditions=$1
161 atoms=$2
162 ;;
163 *)
164 die "bad number of arguments to $0"
165 ;;
166 esac
167
168 for atom in $atoms; do
169 _ruby_add_rdepend "${atom}$(ruby_samelib)" "$conditions"
170 done
171}
172
173# @FUNCTION: ruby_add_bdepend
174# @USAGE: [conditions] atom
175# @DESCRIPTION:
176# Adds the specified atom(s) with optional use condition(s) to both
177# DEPEND and RDEPEND, taking the current set of ruby targets into
178# account. This makes sure that all ruby dependencies of the package
179# are installed for the same ruby targets. Use this function for all
180# ruby dependencies instead of setting DEPEND and RDEPEND
181# yourself. Both atom and conditions can be a space-separated list of
182# atoms or conditions.
183ruby_add_bdepend() {
184 local atoms=
185 local conditions=
186 case $# in
187 1)
188 atoms=$1
189 ;;
190 2)
191 conditions=$1
192 atoms=$2
193 ;;
194 *)
195 die "bad number of arguments to $0"
196 ;;
197 esac
198
199 for atom in $atoms; do
200 _ruby_add_bdepend "${atom}$(ruby_samelib)" "$conditions"
201 done
202}
203
204for _ruby_implementation in $USE_RUBY; do 314 for _ruby_implementation in ${USE_RUBY}; do
205 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 315 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
316 done
317 echo "${depend}"
318}
206 319
320IUSE+=" $(ruby_get_use_targets)"
207 # If you specify RUBY_OPTIONAL you also need to take care of 321# If you specify RUBY_OPTIONAL you also need to take care of
208 # ruby useflag and dependency. 322# ruby useflag and dependency.
209 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then 323if [[ ${RUBY_OPTIONAL} != yes ]]; then
210 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 324 DEPEND="${DEPEND} $(ruby_implementations_depend)"
211 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 325 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
326
327 case ${EAPI:-0} in
328 4|5)
329 REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
330 ;;
331 esac
212 fi 332fi
213done
214 333
215_ruby_invoke_environment() { 334_ruby_invoke_environment() {
216 old_S=${S} 335 old_S=${S}
336 case ${EAPI} in
337 4|5)
338 if [ -z ${RUBY_S} ]; then
339 sub_S=${P}
340 else
341 sub_S=${RUBY_S}
342 fi
343 ;;
344 *)
217 sub_S=${S#${WORKDIR}} 345 sub_S=${S#${WORKDIR}/}
346 ;;
347 esac
348
349 # Special case, for the always-lovely GitHub fetches. With this,
350 # we allow the star glob to just expand to whatever directory it's
351 # called.
352 if [[ ${sub_S} = *"*"* ]]; then
353 case ${EAPI} in
354 2|3)
355 #The old method of setting S depends on undefined package
356 # manager behaviour, so encourage upgrading to EAPI=4.
357 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
358 ;;
359 esac
360 pushd "${WORKDIR}"/all &>/dev/null
361 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
362 popd &>/dev/null
363 fi
218 364
219 environment=$1; shift 365 environment=$1; shift
220 366
221 my_WORKDIR="${WORKDIR}"/${environment} 367 my_WORKDIR="${WORKDIR}"/${environment}
222 S="${my_WORKDIR}"/"${sub_S}" 368 S="${my_WORKDIR}"/"${sub_S}"
240 local invoked=no 386 local invoked=no
241 for _ruby_implementation in ${USE_RUBY}; do 387 for _ruby_implementation in ${USE_RUBY}; do
242 # only proceed if it's requested 388 # only proceed if it's requested
243 use ruby_targets_${_ruby_implementation} || continue 389 use ruby_targets_${_ruby_implementation} || continue
244 390
245 RUBY=$(type -p $_ruby_implementation 2>/dev/null) 391 RUBY=$(ruby_implementation_command ${_ruby_implementation})
246 invoked=yes 392 invoked=yes
247 393
248 if [[ -n "$1" ]]; then 394 if [[ -n "$1" ]]; then
249 _ruby_invoke_environment $_ruby_implementation "$@" 395 _ruby_invoke_environment ${_ruby_implementation} "$@"
250 fi 396 fi
251 397
252 unset RUBY 398 unset RUBY
253 done 399 done
254 400
255 [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." 401 if [[ ${invoked} == "no" ]]; then
402 eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
403 eerror "Compatible targets for this package are: ${USE_RUBY}"
404 eerror
405 eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
406 eerror
407 die "No compatible Ruby target selected."
408 fi
256} 409}
257 410
258# @FUNCTION: ruby-ng_pkg_setup 411# @FUNCTION: ruby-ng_pkg_setup
259# @DESCRIPTION: 412# @DESCRIPTION:
260# Check whether at least one ruby target implementation is present. 413# Check whether at least one ruby target implementation is present.
261ruby-ng_pkg_setup() { 414ruby-ng_pkg_setup() {
262 # This only checks that at least one implementation is present 415 # This only checks that at least one implementation is present
263 # before doing anything; by leaving the parameters empty we know 416 # before doing anything; by leaving the parameters empty we know
264 # it's a special case. 417 # it's a special case.
265 _ruby_each_implementation 418 _ruby_each_implementation
419
420 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
266} 421}
267 422
268# @FUNCTION: ruby-ng_src_unpack 423# @FUNCTION: ruby-ng_src_unpack
269# @DESCRIPTION: 424# @DESCRIPTION:
270# Unpack the source archive, including gems. 425# Unpack the source archive.
271ruby-ng_src_unpack() { 426ruby-ng_src_unpack() {
272 mkdir "${WORKDIR}"/all 427 mkdir "${WORKDIR}"/all
273 pushd "${WORKDIR}"/all &>/dev/null 428 pushd "${WORKDIR}"/all &>/dev/null
274 429
275 # We don't support an each-unpack, it's either all or nothing! 430 # We don't support an each-unpack, it's either all or nothing!
316 # almost every other ebuild. 471 # almost every other ebuild.
317 find . -name '._*' -delete 472 find . -name '._*' -delete
318 473
319 _ruby_invoke_environment all _ruby_apply_patches 474 _ruby_invoke_environment all _ruby_apply_patches
320 475
476 _PHASE="source copy" \
321 _ruby_each_implementation _ruby_source_copy 477 _ruby_each_implementation _ruby_source_copy
322 478
323 if type each_ruby_prepare &>/dev/null; then 479 if type each_ruby_prepare &>/dev/null; then
324 _ruby_each_implementation each_ruby_prepare 480 _ruby_each_implementation each_ruby_prepare
325 fi 481 fi
326} 482}
360 type all_ruby_test &>/dev/null && \ 516 type all_ruby_test &>/dev/null && \
361 _ruby_invoke_environment all all_ruby_test 517 _ruby_invoke_environment all all_ruby_test
362} 518}
363 519
364_each_ruby_check_install() { 520_each_ruby_check_install() {
521 local scancmd=scanelf
522 # we have a Mach-O object here
523 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
524
525 has "${EAPI}" 2 && ! use prefix && EPREFIX=
526
365 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 527 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
366 local libruby_soname=$(scanelf -qS "/usr/$(get_libdir)/${libruby_basename}" | awk '{ print $1 }') 528 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
529 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
530 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
531
532 # Look for wrong files in sitedir
533 # if [[ -d "${D}${sitedir}" ]]; then
534 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
535 # if [[ -n ${f} ]]; then
536 # eerror "Found files in sitedir, outsite sitelibdir:"
537 # eerror "${f}"
538 # die "Misplaced files in sitedir"
539 # fi
540 # fi
367 541
368 # The current implementation lacks libruby (i.e.: jruby) 542 # The current implementation lacks libruby (i.e.: jruby)
369 [[ -z ${libruby_soname} ]] && return 0 543 [[ -z ${libruby_soname} ]] && return 0
370 544
371 scanelf -qnR "${D}"/$(dirname $(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')) \ 545 # Check also the gems directory, since we could be installing compiled
546 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
547 # that's what changes between two implementations (otherwise you'd get false
548 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
549 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
372 | fgrep -v "${libruby_soname}" \ 550 | fgrep -v "${libruby_soname}" \
551 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
373 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 552 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
374 553
375 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 554 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
376 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" 555 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
377 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 556 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
378 die "Missing links to ${libruby}" 557 die "Missing links to ${libruby_soname}"
379 fi 558 fi
380} 559}
381 560
382# @FUNCTION: ruby-ng_src_install 561# @FUNCTION: ruby-ng_src_install
383# @DESCRIPTION: 562# @DESCRIPTION:
392 571
393 _PHASE="check install" \ 572 _PHASE="check install" \
394 _ruby_each_implementation _each_ruby_check_install 573 _ruby_each_implementation _each_ruby_check_install
395} 574}
396 575
576# @FUNCTION: ruby_rbconfig_value
577# @USAGE: rbconfig item
578# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
579ruby_rbconfig_value() {
580 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
581}
582
397# @FUNCTION: doruby 583# @FUNCTION: doruby
398# @USAGE: file [file...] 584# @USAGE: file [file...]
399# @DESCRIPTION: 585# @DESCRIPTION:
400# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. 586# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
401doruby() { 587doruby() {
588 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
589 has "${EAPI}" 2 && ! use prefix && EPREFIX=
402 ( # don't want to pollute calling env 590 ( # don't want to pollute calling env
403 insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') 591 sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
592 insinto ${sitelibdir#${EPREFIX}}
404 insopts -m 0644 593 insopts -m 0644
405 doins "$@" 594 doins "$@"
406 ) || die "failed to install $@" 595 ) || die "failed to install $@"
407} 596}
408 597
409# @FUNCTION: ruby_get_libruby 598# @FUNCTION: ruby_get_libruby
410# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. 599# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
411ruby_get_libruby() { 600ruby_get_libruby() {
412 ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' 601 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
413} 602}
414 603
415# @FUNCTION: ruby_get_hdrdir 604# @FUNCTION: ruby_get_hdrdir
416# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 605# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
417ruby_get_hdrdir() { 606ruby_get_hdrdir() {
418 local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') 607 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
419 608
420 if [[ "${rubyhdrdir}" = "nil" ]] ; then 609 if [[ "${rubyhdrdir}" = "nil" ]] ; then
421 rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') 610 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
422 fi 611 fi
423 612
424 echo "${rubyhdrdir}" 613 echo "${rubyhdrdir}"
425} 614}
615
616# @FUNCTION: ruby_get_version
617# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
618ruby_get_version() {
619 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
620
621 echo $(${ruby} -e 'puts RUBY_VERSION')
622}
623
624# @FUNCTION: ruby_get_implementation
625# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
626ruby_get_implementation() {
627 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
628
629 case $(${ruby} --version) in
630 *Enterprise*)
631 echo "ree"
632 ;;
633 *jruby*)
634 echo "jruby"
635 ;;
636 *rubinius*)
637 echo "rbx"
638 ;;
639 *)
640 echo "mri"
641 ;;
642 esac
643}
644
645# @FUNCTION: ruby-ng_rspec
646# @DESCRIPTION:
647# This is simply a wrapper around the rspec command (executed by $RUBY})
648# which also respects TEST_VERBOSE and NOCOLOR environment variables.
649ruby-ng_rspec() {
650 if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
651 ewarn "Missing dev-ruby/rspec in \${DEPEND}"
652 fi
653
654 local rspec_params=
655 case ${NOCOLOR} in
656 1|yes|true)
657 rspec_params+=" --no-color"
658 ;;
659 *)
660 rspec_params+=" --color"
661 ;;
662 esac
663
664 case ${TEST_VERBOSE} in
665 1|yes|true)
666 rspec_params+=" --format documentation"
667 ;;
668 *)
669 rspec_params+=" --format progress"
670 ;;
671 esac
672
673 ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed"
674}
675
676# @FUNCTION: ruby-ng_cucumber
677# @DESCRIPTION:
678# This is simply a wrapper around the cucumber command (executed by $RUBY})
679# which also respects TEST_VERBOSE and NOCOLOR environment variables.
680ruby-ng_cucumber() {
681 if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
682 ewarn "Missing dev-util/cucumber in \${DEPEND}"
683 fi
684
685 local cucumber_params=
686 case ${NOCOLOR} in
687 1|yes|true)
688 cucumber_params+=" --no-color"
689 ;;
690 *)
691 cucumber_params+=" --color"
692 ;;
693 esac
694
695 case ${TEST_VERBOSE} in
696 1|yes|true)
697 cucumber_params+=" --format pretty"
698 ;;
699 *)
700 cucumber_params+=" --format progress"
701 ;;
702 esac
703
704 if [[ ${RUBY} == *jruby ]]; then
705 ewarn "Skipping cucumber tests on JRuby (unsupported)."
706 return 0
707 fi
708
709 ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed"
710}
711
712# @FUNCTION: ruby-ng_testrb-2
713# @DESCRIPTION:
714# This is simply a replacement for the testrb command that load the test
715# files and execute them, with test-unit 2.x. This actually requires
716# either an old test-unit-2 version or 2.5.1-r1 or later, as they remove
717# their script and we installed a broken wrapper for a while.
718# This also respects TEST_VERBOSE and NOCOLOR environment variables.
719ruby-ng_testrb-2() {
720 if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
721 ewarn "Missing dev-ruby/test-unit in \${DEPEND}"
722 fi
723
724 local testrb_params=
725 case ${NOCOLOR} in
726 1|yes|true)
727 testrb_params+=" --no-use-color"
728 ;;
729 *)
730 testrb_params+=" --use-color=auto"
731 ;;
732 esac
733
734 case ${TEST_VERBOSE} in
735 1|yes|true)
736 testrb_params+=" --verbose=verbose"
737 ;;
738 *)
739 testrb_params+=" --verbose=normal"
740 ;;
741 esac
742
743 ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed"
744}

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.53

  ViewVC Help
Powered by ViewVC 1.1.20