/[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.37 Revision 1.51
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.37 2011/07/22 09:10:22 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.51 2012/09/27 16:35:41 axs 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
67# is linked against libruby. There are cases were this is not the case 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 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 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. 70# passed to "grep -E" to remove reporting of these shared objects.
71 71
72inherit eutils toolchain-funcs 72inherit eutils java-utils-2 multilib toolchain-funcs
73 73
74EXPORT_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
75 75
76case ${EAPI} in 76case ${EAPI} in
77 0|1) 77 0|1)
78 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;; 78 die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
79 2|3) ;; 79 2|3) ;;
80 4) 80 4|5)
81 # S is no longer automatically assigned when it doesn't exist. 81 # S is no longer automatically assigned when it doesn't exist.
82 S="${WORKDIR}" 82 S="${WORKDIR}"
83 ;; 83 ;;
84 *) 84 *)
85 die "Unknown EAPI=${EAPI} for ruby-ng.eclass" 85 die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
112 rubypn="dev-lang/ruby-enterprise" 112 rubypn="dev-lang/ruby-enterprise"
113 rubyslot=":1.8" 113 rubyslot=":1.8"
114 ;; 114 ;;
115 jruby) 115 jruby)
116 rubypn="dev-java/jruby" 116 rubypn="dev-java/jruby"
117 rubyslot=""
118 ;;
119 rbx)
120 rubypn="dev-lang/rubinius"
117 rubyslot="" 121 rubyslot=""
118 ;; 122 ;;
119 *) die "$1: unknown Ruby implementation" 123 *) die "$1: unknown Ruby implementation"
120 esac 124 esac
121 125
277 t+=" ruby_targets_${implementation}" 281 t+=" ruby_targets_${implementation}"
278 done 282 done
279 echo $t 283 echo $t
280} 284}
281 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
304 for _ruby_implementation in ${USE_RUBY}; do
305 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
306 done
307 echo "${depend}"
308}
309
310IUSE+=" $(ruby_get_use_targets)"
311# If you specify RUBY_OPTIONAL you also need to take care of
312# ruby useflag and dependency.
282if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then 313if [[ ${RUBY_OPTIONAL} != yes ]]; then
314 DEPEND="${DEPEND} $(ruby_implementations_depend)"
315 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
316
317 case ${EAPI:-0} in
318 4|5)
283 REQUIRED_USE=" || ( $(ruby_get_use_targets) )" 319 REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
320 ;;
321 esac
284fi 322fi
285
286for _ruby_implementation in $USE_RUBY; do
287 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
288
289 # If you specify RUBY_OPTIONAL you also need to take care of
290 # ruby useflag and dependency.
291 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
292 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
293 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
294 fi
295done
296 323
297_ruby_invoke_environment() { 324_ruby_invoke_environment() {
298 old_S=${S} 325 old_S=${S}
299 case ${EAPI} in 326 case ${EAPI} in
300 4) 327 4|5)
301 if [ -z ${RUBY_S} ]; then 328 if [ -z ${RUBY_S} ]; then
302 sub_S=${P} 329 sub_S=${P}
303 else 330 else
304 sub_S=${RUBY_S} 331 sub_S=${RUBY_S}
305 fi 332 fi
359 fi 386 fi
360 387
361 unset RUBY 388 unset RUBY
362 done 389 done
363 390
364 [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf." 391 if [[ ${invoked} == "no" ]]; then
392 eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
393 eerror "Compatible targets for this package are: ${USE_RUBY}"
394 eerror
395 eerror "See http://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
396 eerror
397 die "No compatible Ruby target selected."
398 fi
365} 399}
366 400
367# @FUNCTION: ruby-ng_pkg_setup 401# @FUNCTION: ruby-ng_pkg_setup
368# @DESCRIPTION: 402# @DESCRIPTION:
369# Check whether at least one ruby target implementation is present. 403# Check whether at least one ruby target implementation is present.
370ruby-ng_pkg_setup() { 404ruby-ng_pkg_setup() {
371 # This only checks that at least one implementation is present 405 # This only checks that at least one implementation is present
372 # before doing anything; by leaving the parameters empty we know 406 # before doing anything; by leaving the parameters empty we know
373 # it's a special case. 407 # it's a special case.
374 _ruby_each_implementation 408 _ruby_each_implementation
409
410 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
375} 411}
376 412
377# @FUNCTION: ruby-ng_src_unpack 413# @FUNCTION: ruby-ng_src_unpack
378# @DESCRIPTION: 414# @DESCRIPTION:
379# Unpack the source archive. 415# Unpack the source archive.
476 # we have a Mach-O object here 512 # we have a Mach-O object here
477 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho 513 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
478 514
479 has "${EAPI}" 2 && ! use prefix && EPREFIX= 515 has "${EAPI}" 2 && ! use prefix && EPREFIX=
480 516
481 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 517 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
482 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) 518 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
483 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') 519 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
484 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') 520 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
485 521
486 # Look for wrong files in sitedir 522 # Look for wrong files in sitedir
487 # if [[ -d "${D}${sitedir}" ]]; then 523 # if [[ -d "${D}${sitedir}" ]]; then
488 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") 524 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
489 # if [[ -n ${f} ]]; then 525 # if [[ -n ${f} ]]; then
529 565
530# @FUNCTION: ruby_rbconfig_value 566# @FUNCTION: ruby_rbconfig_value
531# @USAGE: rbconfig item 567# @USAGE: rbconfig item
532# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. 568# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
533ruby_rbconfig_value() { 569ruby_rbconfig_value() {
534 echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") 570 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
535} 571}
536 572
537# @FUNCTION: doruby 573# @FUNCTION: doruby
538# @USAGE: file [file...] 574# @USAGE: file [file...]
539# @DESCRIPTION: 575# @DESCRIPTION:
550} 586}
551 587
552# @FUNCTION: ruby_get_libruby 588# @FUNCTION: ruby_get_libruby
553# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. 589# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
554ruby_get_libruby() { 590ruby_get_libruby() {
555 ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' 591 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
556} 592}
557 593
558# @FUNCTION: ruby_get_hdrdir 594# @FUNCTION: ruby_get_hdrdir
559# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 595# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
560ruby_get_hdrdir() { 596ruby_get_hdrdir() {
585 echo "ree" 621 echo "ree"
586 ;; 622 ;;
587 *jruby*) 623 *jruby*)
588 echo "jruby" 624 echo "jruby"
589 ;; 625 ;;
626 *rubinius*)
627 echo "rbx"
628 ;;
590 *) 629 *)
591 echo "mri" 630 echo "mri"
592 ;; 631 ;;
593 esac 632 esac
594} 633}
634
635# @FUNCTION: ruby-ng_rspec
636# @DESCRIPTION:
637# This is simply a wrapper around the rspec command (executed by $RUBY})
638# which also respects TEST_VERBOSE and NOCOLOR environment variables.
639ruby-ng_rspec() {
640 if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
641 ewarn "Missing dev-ruby/rspec in \${DEPEND}"
642 fi
643
644 local rspec_params=
645 case ${NOCOLOR} in
646 1|yes|true)
647 rspec_params+=" --no-color"
648 ;;
649 *)
650 rspec_params+=" --color"
651 ;;
652 esac
653
654 case ${TEST_VERBOSE} in
655 1|yes|true)
656 rspec_params+=" --format documentation"
657 ;;
658 *)
659 rspec_params+=" --format progress"
660 ;;
661 esac
662
663 ${RUBY} -S rspec ${rspec_params} "$@" || die "rspec failed"
664}
665
666# @FUNCTION: ruby-ng_cucumber
667# @DESCRIPTION:
668# This is simply a wrapper around the cucumber command (executed by $RUBY})
669# which also respects TEST_VERBOSE and NOCOLOR environment variables.
670ruby-ng_cucumber() {
671 if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
672 ewarn "Missing dev-util/cucumber in \${DEPEND}"
673 fi
674
675 local cucumber_params=
676 case ${NOCOLOR} in
677 1|yes|true)
678 cucumber_params+=" --no-color"
679 ;;
680 *)
681 cucumber_params+=" --color"
682 ;;
683 esac
684
685 case ${TEST_VERBOSE} in
686 1|yes|true)
687 cucumber_params+=" --format pretty"
688 ;;
689 *)
690 cucumber_params+=" --format progress"
691 ;;
692 esac
693
694 if [[ ${RUBY} == *jruby ]]; then
695 ewarn "Skipping cucumber tests on JRuby (unsupported)."
696 return 0
697 fi
698
699 ${RUBY} -S cucumber ${cucumber_params} "$@" || die "cucumber failed"
700}
701
702# @FUNCTION: ruby-ng_testrb-2
703# @DESCRIPTION:
704# This is simply a replacement for the testrb command that load the test
705# files and execute them, with test-unit 2.x. This actually requires
706# either an old test-unit-2 version or 2.5.1-r1 or later, as they remove
707# their script and we installed a broken wrapper for a while.
708# This also respects TEST_VERBOSE and NOCOLOR environment variables.
709ruby-ng_testrb-2() {
710 if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
711 ewarn "Missing dev-ruby/test-unit in \${DEPEND}"
712 fi
713
714 local testrb_params=
715 case ${NOCOLOR} in
716 1|yes|true)
717 testrb_params+=" --no-use-color"
718 ;;
719 *)
720 testrb_params+=" --use-color=auto"
721 ;;
722 esac
723
724 case ${TEST_VERBOSE} in
725 1|yes|true)
726 testrb_params+=" --verbose=verbose"
727 ;;
728 *)
729 testrb_params+=" --verbose=normal"
730 ;;
731 esac
732
733 ${RUBY} -S testrb-2 ${testrb_params} "$@" || die "testrb-2 failed"
734}

Legend:
Removed from v.1.37  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.20