| 1 | # Copyright 1999-2011 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.43 2011/10/24 18:20:05 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 | # @AUTHOR: |
8 | # @AUTHOR: |
| … | |
… | |
| 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 | |
| 72 | inherit eutils java-utils-2 toolchain-funcs |
72 | inherit eutils java-utils-2 multilib toolchain-funcs |
| 73 | |
73 | |
| 74 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
74 | EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup |
| 75 | |
75 | |
| 76 | case ${EAPI} in |
76 | case ${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" |
| … | |
… | |
| 280 | for implementation in ${USE_RUBY}; do |
280 | for implementation in ${USE_RUBY}; do |
| 281 | t+=" ruby_targets_${implementation}" |
281 | t+=" ruby_targets_${implementation}" |
| 282 | done |
282 | done |
| 283 | echo $t |
283 | echo $t |
| 284 | } |
284 | } |
| 285 | |
|
|
| 286 | if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
| 287 | REQUIRED_USE=" || ( $(ruby_get_use_targets) )" |
|
|
| 288 | fi |
|
|
| 289 | |
285 | |
| 290 | # @FUNCTION: ruby_implementations_depend |
286 | # @FUNCTION: ruby_implementations_depend |
| 291 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
287 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
| 292 | # @DESCRIPTION: |
288 | # @DESCRIPTION: |
| 293 | # Produces the dependency string for the various implementations of ruby |
289 | # Produces the dependency string for the various implementations of ruby |
| … | |
… | |
| 309 | depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
305 | depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" |
| 310 | done |
306 | done |
| 311 | echo "${depend}" |
307 | echo "${depend}" |
| 312 | } |
308 | } |
| 313 | |
309 | |
| 314 | for _ruby_implementation in ${USE_RUBY}; do |
310 | IUSE+=" $(ruby_get_use_targets)" |
| 315 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
|
|
| 316 | done |
|
|
| 317 | # 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 |
| 318 | # ruby useflag and dependency. |
312 | # ruby useflag and dependency. |
| 319 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
313 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
| 320 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
314 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
| 321 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
315 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
|
|
316 | |
|
|
317 | case ${EAPI:-0} in |
|
|
318 | 4|5) |
|
|
319 | REQUIRED_USE+=" || ( $(ruby_get_use_targets) )" |
|
|
320 | ;; |
|
|
321 | esac |
| 322 | fi |
322 | fi |
| 323 | |
323 | |
| 324 | _ruby_invoke_environment() { |
324 | _ruby_invoke_environment() { |
| 325 | old_S=${S} |
325 | old_S=${S} |
| 326 | case ${EAPI} in |
326 | case ${EAPI} in |
| 327 | 4) |
327 | 4|5) |
| 328 | if [ -z ${RUBY_S} ]; then |
328 | if [ -z ${RUBY_S} ]; then |
| 329 | sub_S=${P} |
329 | sub_S=${P} |
| 330 | else |
330 | else |
| 331 | sub_S=${RUBY_S} |
331 | sub_S=${RUBY_S} |
| 332 | fi |
332 | fi |
| … | |
… | |
| 386 | fi |
386 | fi |
| 387 | |
387 | |
| 388 | unset RUBY |
388 | unset RUBY |
| 389 | done |
389 | done |
| 390 | |
390 | |
| 391 | [[ ${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 |
| 392 | } |
399 | } |
| 393 | |
400 | |
| 394 | # @FUNCTION: ruby-ng_pkg_setup |
401 | # @FUNCTION: ruby-ng_pkg_setup |
| 395 | # @DESCRIPTION: |
402 | # @DESCRIPTION: |
| 396 | # Check whether at least one ruby target implementation is present. |
403 | # Check whether at least one ruby target implementation is present. |
| … | |
… | |
| 622 | *) |
629 | *) |
| 623 | echo "mri" |
630 | echo "mri" |
| 624 | ;; |
631 | ;; |
| 625 | esac |
632 | esac |
| 626 | } |
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. |
|
|
639 | ruby-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. |
|
|
670 | ruby-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. |
|
|
709 | ruby-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 | } |