/[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.32 Revision 1.46
1# Copyright 1999-2009 Gentoo Foundation 1# Copyright 1999-2012 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.32 2011/04/25 08:37:26 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.46 2012/06/02 19:16:31 zmedico 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
23# * ree18 - Ruby Enterprise Edition 1.8.x 20# * ree18 - Ruby Enterprise Edition 1.8.x
24# * jruby - JRuby 21# * jruby - JRuby
22# * rbx - Rubinius
25# 23#
26# This eclass does not define the implementation of the configure, 24# This eclass does not define the implementation of the configure,
27# compile, test, or install phases. Instead, the default phases are 25# compile, test, or install phases. Instead, the default phases are
28# used. Specific implementations of these phases can be provided in 26# used. Specific implementations of these phases can be provided in
29# the ebuild either to be run for each Ruby implementation, or for all 27# the ebuild either to be run for each Ruby implementation, or for all
44# @DESCRIPTION: 42# @DESCRIPTION:
45# A String or Array of filenames of patches to apply to all implementations. 43# A String or Array of filenames of patches to apply to all implementations.
46 44
47# @ECLASS-VARIABLE: RUBY_OPTIONAL 45# @ECLASS-VARIABLE: RUBY_OPTIONAL
48# @DESCRIPTION: 46# @DESCRIPTION:
49# Set the value to "yes" to make the dependency on a Ruby interpreter optional. 47# Set the value to "yes" to make the dependency on a Ruby interpreter
48# optional and then ruby_implementations_depend() to help populate
49# DEPEND and RDEPEND.
50 50
51# @ECLASS-VARIABLE: RUBY_S 51# @ECLASS-VARIABLE: RUBY_S
52# @DEFAULT_UNSET 52# @DEFAULT_UNSET
53# @DESCRIPTION: 53# @DESCRIPTION:
54# If defined this variable determines the source directory name after 54# If defined this variable determines the source directory name after
55# unpacking. This defaults to the name of the package. Note that this 55# unpacking. This defaults to the name of the package. Note that this
56# variable supports a wildcard mechanism to help with github tarballs 56# variable supports a wildcard mechanism to help with github tarballs
57# that contain the commit hash as part of the directory name. 57# that contain the commit hash as part of the directory name.
58 58
59inherit eutils toolchain-funcs 59# @ECLASS-VARIABLE: RUBY_QA_ALLOWED_LIBS
60# @DEFAULT_UNSET
61# @DESCRIPTION:
62# If defined this variable contains a whitelist of shared objects that
63# are allowed to exist even if they don't link to libruby. This avoids
64# the QA check that makes this mandatory. This is most likely not what
65# you are looking for if you get the related "Missing links" QA warning,
66# since the proper fix is almost always to make sure the shared object
67# is linked against libruby. There are cases were this is not the case
68# and the shared object is generic code to be used in some other way
69# (e.g. selenium's firefox driver extension). When set this argument is
70# passed to "grep -E" to remove reporting of these shared objects.
71
72inherit eutils java-utils-2 multilib toolchain-funcs
60 73
61EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup 74EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
62 75
63case ${EAPI} in 76case ${EAPI} in
64 0|1) 77 0|1)
99 rubypn="dev-lang/ruby-enterprise" 112 rubypn="dev-lang/ruby-enterprise"
100 rubyslot=":1.8" 113 rubyslot=":1.8"
101 ;; 114 ;;
102 jruby) 115 jruby)
103 rubypn="dev-java/jruby" 116 rubypn="dev-java/jruby"
117 rubyslot=""
118 ;;
119 rbx)
120 rubypn="dev-lang/rubinius"
104 rubyslot="" 121 rubyslot=""
105 ;; 122 ;;
106 *) die "$1: unknown Ruby implementation" 123 *) die "$1: unknown Ruby implementation"
107 esac 124 esac
108 125
211 RDEPEND="${RDEPEND} $dependency" 228 RDEPEND="${RDEPEND} $dependency"
212 229
213 # Add the dependency as a test-dependency since we're going to 230 # Add the dependency as a test-dependency since we're going to
214 # execute the code during test phase. 231 # execute the code during test phase.
215 DEPEND="${DEPEND} test? ( ${dependency} )" 232 DEPEND="${DEPEND} test? ( ${dependency} )"
216 hasq test "$IUSE" || IUSE="${IUSE} test" 233 has test "$IUSE" || IUSE="${IUSE} test"
217} 234}
218 235
219# @FUNCTION: ruby_add_bdepend 236# @FUNCTION: ruby_add_bdepend
220# @USAGE: dependencies 237# @USAGE: dependencies
221# @DESCRIPTION: 238# @DESCRIPTION:
242 259
243 DEPEND="${DEPEND} $dependency" 260 DEPEND="${DEPEND} $dependency"
244 RDEPEND="${RDEPEND}" 261 RDEPEND="${RDEPEND}"
245} 262}
246 263
264# @FUNCTION: ruby_get_use_implementations
265# @DESCRIPTION:
266# Gets an array of ruby use targets enabled by the user
267ruby_get_use_implementations() {
268 local i implementation
269 for implementation in ${USE_RUBY}; do
270 use ruby_targets_${implementation} && i+=" ${implementation}"
271 done
272 echo $i
273}
274
275# @FUNCTION: ruby_get_use_targets
276# @DESCRIPTION:
277# Gets an array of ruby use targets that the ebuild sets
278ruby_get_use_targets() {
279 local t implementation
280 for implementation in ${USE_RUBY}; do
281 t+=" ruby_targets_${implementation}"
282 done
283 echo $t
284}
285
286# @FUNCTION: ruby_implementations_depend
287# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
288# @DESCRIPTION:
289# Produces the dependency string for the various implementations of ruby
290# which the package is being built against. This should not be used when
291# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
292# confuse this function with ruby_implementation_depend().
293#
294# @EXAMPLE:
295# EAPI=4
296# RUBY_OPTIONAL=yes
297#
298# inherit ruby-ng
299# ...
300# DEPEND="ruby? ( $(ruby_implementations_depend) )"
301# RDEPEND="${DEPEND}"
302ruby_implementations_depend() {
303 local depend
247for _ruby_implementation in $USE_RUBY; do 304 for _ruby_implementation in ${USE_RUBY}; do
248 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 305 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
306 done
307 echo "${depend}"
308}
249 309
310IUSE+=" $(ruby_get_use_targets)"
250 # If you specify RUBY_OPTIONAL you also need to take care of 311# If you specify RUBY_OPTIONAL you also need to take care of
251 # ruby useflag and dependency. 312# ruby useflag and dependency.
252 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then 313if [[ ${RUBY_OPTIONAL} != yes ]]; then
253 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 314 DEPEND="${DEPEND} $(ruby_implementations_depend)"
254 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" 315 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
316
317 [[ ${EAPI:-0} -ge 4 ]] && REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
255 fi 318fi
256done
257 319
258_ruby_invoke_environment() { 320_ruby_invoke_environment() {
259 old_S=${S} 321 old_S=${S}
260 case ${EAPI} in 322 case ${EAPI} in
261 4) 323 4)
272 334
273 # Special case, for the always-lovely GitHub fetches. With this, 335 # Special case, for the always-lovely GitHub fetches. With this,
274 # we allow the star glob to just expand to whatever directory it's 336 # we allow the star glob to just expand to whatever directory it's
275 # called. 337 # called.
276 if [[ ${sub_S} = *"*"* ]]; then 338 if [[ ${sub_S} = *"*"* ]]; then
339 case ${EAPI} in
340 2|3)
341 #The old method of setting S depends on undefined package
342 # manager behaviour, so encourage upgrading to EAPI=4.
343 eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
344 ;;
345 esac
277 pushd "${WORKDIR}"/all &>/dev/null 346 pushd "${WORKDIR}"/all &>/dev/null
278 sub_S=$(eval ls -d ${sub_S} 2>/dev/null) 347 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
279 popd &>/dev/null 348 popd &>/dev/null
280 fi 349 fi
281 350
313 fi 382 fi
314 383
315 unset RUBY 384 unset RUBY
316 done 385 done
317 386
318 [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." 387 if [[ ${invoked} == "no" ]]; then
388 eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
389 eerror "Compatible targets for this package are: ${USE_RUBY}"
390 eerror
391 eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
392 eerror
393 die "No compatible Ruby target selected."
394 fi
319} 395}
320 396
321# @FUNCTION: ruby-ng_pkg_setup 397# @FUNCTION: ruby-ng_pkg_setup
322# @DESCRIPTION: 398# @DESCRIPTION:
323# Check whether at least one ruby target implementation is present. 399# Check whether at least one ruby target implementation is present.
324ruby-ng_pkg_setup() { 400ruby-ng_pkg_setup() {
325 # This only checks that at least one implementation is present 401 # This only checks that at least one implementation is present
326 # before doing anything; by leaving the parameters empty we know 402 # before doing anything; by leaving the parameters empty we know
327 # it's a special case. 403 # it's a special case.
328 _ruby_each_implementation 404 _ruby_each_implementation
405
406 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
329} 407}
330 408
331# @FUNCTION: ruby-ng_src_unpack 409# @FUNCTION: ruby-ng_src_unpack
332# @DESCRIPTION: 410# @DESCRIPTION:
333# Unpack the source archive. 411# Unpack the source archive.
430 # we have a Mach-O object here 508 # we have a Mach-O object here
431 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho 509 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
432 510
433 has "${EAPI}" 2 && ! use prefix && EPREFIX= 511 has "${EAPI}" 2 && ! use prefix && EPREFIX=
434 512
435 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 513 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
436 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) 514 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
437 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') 515 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
438 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') 516 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
439 517
440 # Look for wrong files in sitedir 518 # Look for wrong files in sitedir
441 # if [[ -d "${D}${sitedir}" ]]; then 519 # if [[ -d "${D}${sitedir}" ]]; then
442 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") 520 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
443 # if [[ -n ${f} ]]; then 521 # if [[ -n ${f} ]]; then
454 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since 532 # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
455 # that's what changes between two implementations (otherwise you'd get false 533 # that's what changes between two implementations (otherwise you'd get false
456 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8) 534 # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
457 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \ 535 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
458 | fgrep -v "${libruby_soname}" \ 536 | fgrep -v "${libruby_soname}" \
537 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
459 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 538 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
460 539
461 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 540 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
462 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}" 541 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
463 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 542 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
482 561
483# @FUNCTION: ruby_rbconfig_value 562# @FUNCTION: ruby_rbconfig_value
484# @USAGE: rbconfig item 563# @USAGE: rbconfig item
485# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. 564# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
486ruby_rbconfig_value() { 565ruby_rbconfig_value() {
487 echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") 566 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
488} 567}
489 568
490# @FUNCTION: doruby 569# @FUNCTION: doruby
491# @USAGE: file [file...] 570# @USAGE: file [file...]
492# @DESCRIPTION: 571# @DESCRIPTION:
503} 582}
504 583
505# @FUNCTION: ruby_get_libruby 584# @FUNCTION: ruby_get_libruby
506# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. 585# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
507ruby_get_libruby() { 586ruby_get_libruby() {
508 ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' 587 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
509} 588}
510 589
511# @FUNCTION: ruby_get_hdrdir 590# @FUNCTION: ruby_get_hdrdir
512# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 591# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
513ruby_get_hdrdir() { 592ruby_get_hdrdir() {
538 echo "ree" 617 echo "ree"
539 ;; 618 ;;
540 *jruby*) 619 *jruby*)
541 echo "jruby" 620 echo "jruby"
542 ;; 621 ;;
622 *rubinius*)
623 echo "rbx"
624 ;;
543 *) 625 *)
544 echo "mri" 626 echo "mri"
545 ;; 627 ;;
546 esac 628 esac
547} 629}

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.46

  ViewVC Help
Powered by ViewVC 1.1.20