/[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.36 Revision 1.43
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.36 2011/07/22 09:08:59 graaff Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.43 2011/10/24 18:20:05 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
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 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)
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
255 259
256 DEPEND="${DEPEND} $dependency" 260 DEPEND="${DEPEND} $dependency"
257 RDEPEND="${RDEPEND}" 261 RDEPEND="${RDEPEND}"
258} 262}
259 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
260# @FUNCTION: ruby_get_use_targets 275# @FUNCTION: ruby_get_use_targets
261# @DESCRIPTION: 276# @DESCRIPTION:
262# Gets an array of ruby use targets that the ebuild sets 277# Gets an array of ruby use targets that the ebuild sets
263ruby_get_use_targets() { 278ruby_get_use_targets() {
264 local t implementation 279 local t implementation
270 285
271if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then 286if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
272 REQUIRED_USE=" || ( $(ruby_get_use_targets) )" 287 REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
273fi 288fi
274 289
290# @FUNCTION: ruby_implementations_depend
291# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
292# @DESCRIPTION:
293# Produces the dependency string for the various implementations of ruby
294# which the package is being built against. This should not be used when
295# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
296# confuse this function with ruby_implementation_depend().
297#
298# @EXAMPLE:
299# EAPI=4
300# RUBY_OPTIONAL=yes
301#
302# inherit ruby-ng
303# ...
304# DEPEND="ruby? ( $(ruby_implementations_depend) )"
305# RDEPEND="${DEPEND}"
306ruby_implementations_depend() {
307 local depend
308 for _ruby_implementation in ${USE_RUBY}; do
309 depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
310 done
311 echo "${depend}"
312}
313
275for _ruby_implementation in $USE_RUBY; do 314for _ruby_implementation in ${USE_RUBY}; do
276 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 315 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
277
278 # If you specify RUBY_OPTIONAL you also need to take care of
279 # ruby useflag and dependency.
280 if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
281 DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
282 RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
283 fi
284done 316done
317# If you specify RUBY_OPTIONAL you also need to take care of
318# ruby useflag and dependency.
319if [[ ${RUBY_OPTIONAL} != yes ]]; then
320 DEPEND="${DEPEND} $(ruby_implementations_depend)"
321 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
322fi
285 323
286_ruby_invoke_environment() { 324_ruby_invoke_environment() {
287 old_S=${S} 325 old_S=${S}
288 case ${EAPI} in 326 case ${EAPI} in
289 4) 327 4)
359ruby-ng_pkg_setup() { 397ruby-ng_pkg_setup() {
360 # This only checks that at least one implementation is present 398 # This only checks that at least one implementation is present
361 # before doing anything; by leaving the parameters empty we know 399 # before doing anything; by leaving the parameters empty we know
362 # it's a special case. 400 # it's a special case.
363 _ruby_each_implementation 401 _ruby_each_implementation
402
403 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
364} 404}
365 405
366# @FUNCTION: ruby-ng_src_unpack 406# @FUNCTION: ruby-ng_src_unpack
367# @DESCRIPTION: 407# @DESCRIPTION:
368# Unpack the source archive. 408# Unpack the source archive.
465 # we have a Mach-O object here 505 # we have a Mach-O object here
466 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho 506 [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
467 507
468 has "${EAPI}" 2 && ! use prefix && EPREFIX= 508 has "${EAPI}" 2 && ! use prefix && EPREFIX=
469 509
470 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]') 510 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["LIBRUBY_SO"]')
471 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null) 511 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
472 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]') 512 local sitedir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitedir"]')
473 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') 513 local sitelibdir=$(${RUBY} -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
474 514
475 # Look for wrong files in sitedir 515 # Look for wrong files in sitedir
476 # if [[ -d "${D}${sitedir}" ]]; then 516 # if [[ -d "${D}${sitedir}" ]]; then
477 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}") 517 # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
478 # if [[ -n ${f} ]]; then 518 # if [[ -n ${f} ]]; then
518 558
519# @FUNCTION: ruby_rbconfig_value 559# @FUNCTION: ruby_rbconfig_value
520# @USAGE: rbconfig item 560# @USAGE: rbconfig item
521# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. 561# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
522ruby_rbconfig_value() { 562ruby_rbconfig_value() {
523 echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") 563 echo $(${RUBY} -rrbconfig -e "puts RbConfig::CONFIG['$1']")
524} 564}
525 565
526# @FUNCTION: doruby 566# @FUNCTION: doruby
527# @USAGE: file [file...] 567# @USAGE: file [file...]
528# @DESCRIPTION: 568# @DESCRIPTION:
539} 579}
540 580
541# @FUNCTION: ruby_get_libruby 581# @FUNCTION: ruby_get_libruby
542# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}. 582# @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
543ruby_get_libruby() { 583ruby_get_libruby() {
544 ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])' 584 ${RUBY} -rrbconfig -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY"])'
545} 585}
546 586
547# @FUNCTION: ruby_get_hdrdir 587# @FUNCTION: ruby_get_hdrdir
548# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 588# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
549ruby_get_hdrdir() { 589ruby_get_hdrdir() {
574 echo "ree" 614 echo "ree"
575 ;; 615 ;;
576 *jruby*) 616 *jruby*)
577 echo "jruby" 617 echo "jruby"
578 ;; 618 ;;
619 *rubinius*)
620 echo "rbx"
621 ;;
579 *) 622 *)
580 echo "mri" 623 echo "mri"
581 ;; 624 ;;
582 esac 625 esac
583} 626}

Legend:
Removed from v.1.36  
changed lines
  Added in v.1.43

  ViewVC Help
Powered by ViewVC 1.1.20