| 1 | # Copyright 1999-2009 Gentoo Foundation |
1 | # Copyright 1999-2011 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.38 2011/07/22 09:41:17 graaff Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.44 2011/12/18 21:33:50 flameeyes 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 |
| … | |
… | |
| 69 | # 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 |
| 70 | # 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 |
| 71 | # (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 |
| 72 | # passed to "grep -E" to remove reporting of these shared objects. |
70 | # passed to "grep -E" to remove reporting of these shared objects. |
| 73 | |
71 | |
| 74 | inherit eutils toolchain-funcs |
72 | inherit eutils java-utils-2 toolchain-funcs |
| 75 | |
73 | |
| 76 | 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 |
| 77 | |
75 | |
| 78 | case ${EAPI} in |
76 | case ${EAPI} in |
| 79 | 0|1) |
77 | 0|1) |
| … | |
… | |
| 114 | rubypn="dev-lang/ruby-enterprise" |
112 | rubypn="dev-lang/ruby-enterprise" |
| 115 | rubyslot=":1.8" |
113 | rubyslot=":1.8" |
| 116 | ;; |
114 | ;; |
| 117 | jruby) |
115 | jruby) |
| 118 | rubypn="dev-java/jruby" |
116 | rubypn="dev-java/jruby" |
|
|
117 | rubyslot="" |
|
|
118 | ;; |
|
|
119 | rbx) |
|
|
120 | rubypn="dev-lang/rubinius" |
| 119 | rubyslot="" |
121 | rubyslot="" |
| 120 | ;; |
122 | ;; |
| 121 | *) die "$1: unknown Ruby implementation" |
123 | *) die "$1: unknown Ruby implementation" |
| 122 | esac |
124 | esac |
| 123 | |
125 | |
| … | |
… | |
| 279 | t+=" ruby_targets_${implementation}" |
281 | t+=" ruby_targets_${implementation}" |
| 280 | done |
282 | done |
| 281 | echo $t |
283 | echo $t |
| 282 | } |
284 | } |
| 283 | |
285 | |
| 284 | if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then |
|
|
| 285 | REQUIRED_USE=" || ( $(ruby_get_use_targets) )" |
|
|
| 286 | fi |
|
|
| 287 | |
|
|
| 288 | # @FUNCTION: ruby_implementations_depend |
286 | # @FUNCTION: ruby_implementations_depend |
| 289 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
287 | # @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND. |
| 290 | # @DESCRIPTION: |
288 | # @DESCRIPTION: |
| 291 | # Produces the dependency string for the various implementations of ruby |
289 | # Produces the dependency string for the various implementations of ruby |
| 292 | # which the package is being built against. This should not be used when |
290 | # which the package is being built against. This should not be used when |
| … | |
… | |
| 307 | 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) )" |
| 308 | done |
306 | done |
| 309 | echo "${depend}" |
307 | echo "${depend}" |
| 310 | } |
308 | } |
| 311 | |
309 | |
| 312 | for _ruby_implementation in ${USE_RUBY}; do |
310 | IUSE+=" $(ruby_get_use_targets)" |
| 313 | IUSE="${IUSE} ruby_targets_${_ruby_implementation}" |
|
|
| 314 | done |
|
|
| 315 | # 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 |
| 316 | # ruby useflag and dependency. |
312 | # ruby useflag and dependency. |
| 317 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
313 | if [[ ${RUBY_OPTIONAL} != yes ]]; then |
| 318 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
314 | DEPEND="${DEPEND} $(ruby_implementations_depend)" |
| 319 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
315 | RDEPEND="${RDEPEND} $(ruby_implementations_depend)" |
|
|
316 | |
|
|
317 | [[ ${EAPI:-0} -ge 4 ]] && REQUIRED_USE+=" || ( $(ruby_get_use_targets) )" |
| 320 | fi |
318 | fi |
| 321 | |
319 | |
| 322 | _ruby_invoke_environment() { |
320 | _ruby_invoke_environment() { |
| 323 | old_S=${S} |
321 | old_S=${S} |
| 324 | case ${EAPI} in |
322 | case ${EAPI} in |
| … | |
… | |
| 395 | ruby-ng_pkg_setup() { |
393 | ruby-ng_pkg_setup() { |
| 396 | # This only checks that at least one implementation is present |
394 | # This only checks that at least one implementation is present |
| 397 | # before doing anything; by leaving the parameters empty we know |
395 | # before doing anything; by leaving the parameters empty we know |
| 398 | # it's a special case. |
396 | # it's a special case. |
| 399 | _ruby_each_implementation |
397 | _ruby_each_implementation |
|
|
398 | |
|
|
399 | has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm |
| 400 | } |
400 | } |
| 401 | |
401 | |
| 402 | # @FUNCTION: ruby-ng_src_unpack |
402 | # @FUNCTION: ruby-ng_src_unpack |
| 403 | # @DESCRIPTION: |
403 | # @DESCRIPTION: |
| 404 | # Unpack the source archive. |
404 | # Unpack the source archive. |
| … | |
… | |
| 501 | # we have a Mach-O object here |
501 | # we have a Mach-O object here |
| 502 | [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho |
502 | [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho |
| 503 | |
503 | |
| 504 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
504 | has "${EAPI}" 2 && ! use prefix && EPREFIX= |
| 505 | |
505 | |
| 506 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') |
506 | local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]') |
| 507 | local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) |
507 | local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) |
| 508 | local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') |
508 | local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]') |
| 509 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') |
509 | local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]') |
| 510 | |
510 | |
| 511 | # Look for wrong files in sitedir |
511 | # Look for wrong files in sitedir |
| 512 | # if [[ -d "${D}${sitedir}" ]]; then |
512 | # if [[ -d "${D}${sitedir}" ]]; then |
| 513 | # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
513 | # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") |
| 514 | # if [[ -n ${f} ]]; then |
514 | # if [[ -n ${f} ]]; then |
| … | |
… | |
| 554 | |
554 | |
| 555 | # @FUNCTION: ruby_rbconfig_value |
555 | # @FUNCTION: ruby_rbconfig_value |
| 556 | # @USAGE: rbconfig item |
556 | # @USAGE: rbconfig item |
| 557 | # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
557 | # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
| 558 | ruby_rbconfig_value() { |
558 | ruby_rbconfig_value() { |
| 559 | echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") |
559 | echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']") |
| 560 | } |
560 | } |
| 561 | |
561 | |
| 562 | # @FUNCTION: doruby |
562 | # @FUNCTION: doruby |
| 563 | # @USAGE: file [file...] |
563 | # @USAGE: file [file...] |
| 564 | # @DESCRIPTION: |
564 | # @DESCRIPTION: |
| … | |
… | |
| 575 | } |
575 | } |
| 576 | |
576 | |
| 577 | # @FUNCTION: ruby_get_libruby |
577 | # @FUNCTION: ruby_get_libruby |
| 578 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
578 | # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. |
| 579 | ruby_get_libruby() { |
579 | ruby_get_libruby() { |
| 580 | ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' |
580 | ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])' |
| 581 | } |
581 | } |
| 582 | |
582 | |
| 583 | # @FUNCTION: ruby_get_hdrdir |
583 | # @FUNCTION: ruby_get_hdrdir |
| 584 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
584 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
| 585 | ruby_get_hdrdir() { |
585 | ruby_get_hdrdir() { |
| … | |
… | |
| 610 | echo "ree" |
610 | echo "ree" |
| 611 | ;; |
611 | ;; |
| 612 | *jruby*) |
612 | *jruby*) |
| 613 | echo "jruby" |
613 | echo "jruby" |
| 614 | ;; |
614 | ;; |
|
|
615 | *rubinius*) |
|
|
616 | echo "rbx" |
|
|
617 | ;; |
| 615 | *) |
618 | *) |
| 616 | echo "mri" |
619 | echo "mri" |
| 617 | ;; |
620 | ;; |
| 618 | esac |
621 | esac |
| 619 | } |
622 | } |