/[gentoo-x86]/eclass/ruby-ng.eclass
Gentoo

Contents of /eclass/ruby-ng.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.42 - (hide annotations) (download)
Sat Oct 22 10:08:44 2011 UTC (2 years, 10 months ago) by scarabeus
Branch: MAIN
Changes since 1.41: +2 -2 lines
Check if the jruby is also in IUSE before checking if it is enabled.

1 vapier 1.39 # Copyright 1999-2011 Gentoo Foundation
2 graaff 1.1 # Distributed under the terms of the GNU General Public License v2
3 scarabeus 1.42 # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.41 2011/10/21 06:48:24 graaff Exp $
4 vapier 1.39
5 graaff 1.1 # @ECLASS: ruby-ng.eclass
6     # @MAINTAINER:
7     # Ruby herd <ruby@gentoo.org>
8 vapier 1.39 # @AUTHOR:
9 graaff 1.1 # Author: Diego E. Pettenò <flameeyes@gentoo.org>
10     # Author: Alex Legler <a3li@gentoo.org>
11     # Author: Hans de Graaff <graaff@gentoo.org>
12     # @BLURB: An eclass for installing Ruby packages with proper support for multiple Ruby slots.
13     # @DESCRIPTION:
14     # The Ruby eclass is designed to allow an easier installation of Ruby packages
15     # and their incorporation into the Gentoo Linux system.
16     #
17     # Currently available targets are:
18     # * ruby18 - Ruby (MRI) 1.8.x
19     # * ruby19 - Ruby (MRI) 1.9.x
20     # * ree18 - Ruby Enterprise Edition 1.8.x
21     # * jruby - JRuby
22 graaff 1.41 # * rbx - Rubinius
23 graaff 1.1 #
24     # This eclass does not define the implementation of the configure,
25     # compile, test, or install phases. Instead, the default phases are
26     # used. Specific implementations of these phases can be provided in
27     # the ebuild either to be run for each Ruby implementation, or for all
28     # Ruby implementations, as follows:
29     #
30     # * each_ruby_configure
31     # * all_ruby_configure
32    
33     # @ECLASS-VARIABLE: USE_RUBY
34 graaff 1.26 # @REQUIRED
35 graaff 1.1 # @DESCRIPTION:
36     # This variable contains a space separated list of targets (see above) a package
37     # is compatible to. It must be set before the `inherit' call. There is no
38     # default. All ebuilds are expected to set this variable.
39    
40     # @ECLASS-VARIABLE: RUBY_PATCHES
41 graaff 1.26 # @DEFAULT_UNSET
42 graaff 1.1 # @DESCRIPTION:
43     # A String or Array of filenames of patches to apply to all implementations.
44    
45     # @ECLASS-VARIABLE: RUBY_OPTIONAL
46     # @DESCRIPTION:
47 graaff 1.38 # 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 graaff 1.1
51 graaff 1.31 # @ECLASS-VARIABLE: RUBY_S
52     # @DEFAULT_UNSET
53     # @DESCRIPTION:
54     # If defined this variable determines the source directory name after
55     # unpacking. This defaults to the name of the package. Note that this
56     # variable supports a wildcard mechanism to help with github tarballs
57     # that contain the commit hash as part of the directory name.
58    
59 graaff 1.34 # @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    
72 graaff 1.40 inherit eutils java-utils-2 toolchain-funcs
73 graaff 1.1
74     EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install pkg_setup
75    
76     case ${EAPI} in
77     0|1)
78     die "Unsupported EAPI=${EAPI} (too old) for ruby-ng.eclass" ;;
79 flameeyes 1.24 2|3) ;;
80 graaff 1.31 4)
81     # S is no longer automatically assigned when it doesn't exist.
82     S="${WORKDIR}"
83     ;;
84 graaff 1.1 *)
85     die "Unknown EAPI=${EAPI} for ruby-ng.eclass"
86     esac
87    
88     # @FUNCTION: ruby_implementation_depend
89     # @USAGE: target [comparator [version]]
90     # @RETURN: Package atom of a Ruby implementation to be used in dependencies.
91     # @DESCRIPTION:
92     # This function returns the formal package atom for a Ruby implementation.
93     #
94     # `target' has to be one of the valid values for USE_RUBY (see above)
95     #
96     # Set `comparator' and `version' to include a comparator (=, >=, etc.) and a
97     # version string to the returned string
98     ruby_implementation_depend() {
99     local rubypn=
100     local rubyslot=
101    
102     case $1 in
103     ruby18)
104     rubypn="dev-lang/ruby"
105     rubyslot=":1.8"
106     ;;
107     ruby19)
108     rubypn="dev-lang/ruby"
109     rubyslot=":1.9"
110     ;;
111     ree18)
112     rubypn="dev-lang/ruby-enterprise"
113     rubyslot=":1.8"
114     ;;
115     jruby)
116     rubypn="dev-java/jruby"
117     rubyslot=""
118     ;;
119 graaff 1.41 rbx)
120     rubypn="dev-lang/rubinius"
121     rubyslot=""
122     ;;
123 graaff 1.1 *) die "$1: unknown Ruby implementation"
124     esac
125    
126     echo "$2${rubypn}$3${rubyslot}"
127     }
128    
129     # @FUNCTION: ruby_samelib
130     # @RETURN: use flag string with current ruby implementations
131     # @DESCRIPTION:
132     # Convenience function to output the use dependency part of a
133     # dependency. Used as a building block for ruby_add_rdepend() and
134     # ruby_add_bdepend(), but may also be useful in an ebuild to specify
135     # more complex dependencies.
136     ruby_samelib() {
137     local res=
138     for _ruby_implementation in $USE_RUBY; do
139     has -${_ruby_implementation} $@ || \
140     res="${res}ruby_targets_${_ruby_implementation}?,"
141     done
142    
143     echo "[${res%,}]"
144     }
145    
146 flameeyes 1.17 _ruby_atoms_samelib_generic() {
147 flameeyes 1.18 eshopts_push -o noglob
148 flameeyes 1.17 echo "RUBYTARGET? ("
149 flameeyes 1.14 for token in $*; do
150     case "$token" in
151 flameeyes 1.16 "||" | "(" | ")" | *"?")
152 flameeyes 1.14 echo "${token}" ;;
153 flameeyes 1.21 *])
154     echo "${token%[*}[RUBYTARGET,${token/*[}" ;;
155 flameeyes 1.14 *)
156 flameeyes 1.17 echo "${token}[RUBYTARGET]" ;;
157 flameeyes 1.14 esac
158     done
159 flameeyes 1.17 echo ")"
160 flameeyes 1.18 eshopts_pop
161 flameeyes 1.17 }
162    
163 flameeyes 1.27 # @FUNCTION: ruby_implementation_command
164     # @RETURN: the path to the given ruby implementation
165     # @DESCRIPTION:
166     # Not all implementations have the same command basename as the
167     # target; namely Ruby Enterprise 1.8 uses ree18 and rubyee18
168     # respectively. This function translate between the two
169     ruby_implementation_command() {
170     local _ruby_name=$1
171    
172     # Add all USE_RUBY values where the flag name diverts from the binary here
173     case $1 in
174     ree18)
175     _ruby_name=rubyee18
176     ;;
177     esac
178    
179     echo $(type -p ${_ruby_name} 2>/dev/null)
180     }
181    
182 flameeyes 1.17 _ruby_atoms_samelib() {
183     local atoms=$(_ruby_atoms_samelib_generic "$*")
184    
185     for _ruby_implementation in $USE_RUBY; do
186     echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
187     done
188 flameeyes 1.14 }
189    
190 flameeyes 1.16 _ruby_wrap_conditions() {
191     local conditions="$1"
192     local atoms="$2"
193    
194     for condition in $conditions; do
195     atoms="${condition}? ( ${atoms} )"
196     done
197    
198     echo "$atoms"
199     }
200    
201 graaff 1.1 # @FUNCTION: ruby_add_rdepend
202 flameeyes 1.16 # @USAGE: dependencies
203 graaff 1.1 # @DESCRIPTION:
204 flameeyes 1.16 # Adds the specified dependencies, with use condition(s) to RDEPEND,
205     # taking the current set of ruby targets into account. This makes sure
206     # that all ruby dependencies of the package are installed for the same
207     # ruby targets. Use this function for all ruby dependencies instead of
208     # setting RDEPEND yourself. The list of atoms uses the same syntax as
209     # normal dependencies.
210     #
211     # Note: runtime dependencies are also added as build-time test
212     # dependencies.
213 graaff 1.1 ruby_add_rdepend() {
214     case $# in
215 flameeyes 1.16 1) ;;
216 graaff 1.1 2)
217 flameeyes 1.16 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_rdepend for $CATEGORY/$PF"
218     ruby_add_rdepend "$(_ruby_wrap_conditions "$1" "$2")"
219     return
220 graaff 1.1 ;;
221     *)
222     die "bad number of arguments to $0"
223     ;;
224     esac
225    
226 flameeyes 1.16 local dependency=$(_ruby_atoms_samelib "$1")
227    
228     RDEPEND="${RDEPEND} $dependency"
229    
230     # Add the dependency as a test-dependency since we're going to
231     # execute the code during test phase.
232 flameeyes 1.20 DEPEND="${DEPEND} test? ( ${dependency} )"
233 ssuominen 1.33 has test "$IUSE" || IUSE="${IUSE} test"
234 graaff 1.1 }
235    
236     # @FUNCTION: ruby_add_bdepend
237 flameeyes 1.16 # @USAGE: dependencies
238 graaff 1.1 # @DESCRIPTION:
239 flameeyes 1.16 # Adds the specified dependencies, with use condition(s) to DEPEND,
240     # taking the current set of ruby targets into account. This makes sure
241     # that all ruby dependencies of the package are installed for the same
242     # ruby targets. Use this function for all ruby dependencies instead of
243     # setting DEPEND yourself. The list of atoms uses the same syntax as
244     # normal dependencies.
245 graaff 1.1 ruby_add_bdepend() {
246     case $# in
247 flameeyes 1.16 1) ;;
248 graaff 1.1 2)
249 flameeyes 1.16 [[ "${GENTOO_DEV}" == "yes" ]] && eqawarn "You can now use the usual syntax in ruby_add_bdepend for $CATEGORY/$PF"
250     ruby_add_bdepend "$(_ruby_wrap_conditions "$1" "$2")"
251     return
252 graaff 1.1 ;;
253     *)
254     die "bad number of arguments to $0"
255     ;;
256     esac
257    
258 flameeyes 1.16 local dependency=$(_ruby_atoms_samelib "$1")
259    
260     DEPEND="${DEPEND} $dependency"
261 flameeyes 1.19 RDEPEND="${RDEPEND}"
262 graaff 1.1 }
263    
264 graaff 1.37 # @FUNCTION: ruby_get_use_implementations
265     # @DESCRIPTION:
266     # Gets an array of ruby use targets enabled by the user
267     ruby_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 graaff 1.36 # @FUNCTION: ruby_get_use_targets
276     # @DESCRIPTION:
277     # Gets an array of ruby use targets that the ebuild sets
278     ruby_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     if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
287     REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
288     fi
289    
290 graaff 1.38 # @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}"
306     ruby_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    
314     for _ruby_implementation in ${USE_RUBY}; do
315 graaff 1.1 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
316     done
317 graaff 1.38 # If you specify RUBY_OPTIONAL you also need to take care of
318     # ruby useflag and dependency.
319     if [[ ${RUBY_OPTIONAL} != yes ]]; then
320     DEPEND="${DEPEND} $(ruby_implementations_depend)"
321     RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
322     fi
323 graaff 1.1
324     _ruby_invoke_environment() {
325     old_S=${S}
326 graaff 1.31 case ${EAPI} in
327     4)
328 graaff 1.32 if [ -z ${RUBY_S} ]; then
329     sub_S=${P}
330     else
331     sub_S=${RUBY_S}
332     fi
333 graaff 1.31 ;;
334     *)
335     sub_S=${S#${WORKDIR}/}
336     ;;
337     esac
338 flameeyes 1.12
339     # Special case, for the always-lovely GitHub fetches. With this,
340     # we allow the star glob to just expand to whatever directory it's
341     # called.
342 flameeyes 1.28 if [[ ${sub_S} = *"*"* ]]; then
343 graaff 1.35 case ${EAPI} in
344     2|3)
345     #The old method of setting S depends on undefined package
346     # manager behaviour, so encourage upgrading to EAPI=4.
347     eqawarn "Using * expansion of S is deprecated. Use EAPI and RUBY_S instead."
348     ;;
349     esac
350 flameeyes 1.12 pushd "${WORKDIR}"/all &>/dev/null
351 flameeyes 1.13 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
352 flameeyes 1.12 popd &>/dev/null
353     fi
354 graaff 1.1
355     environment=$1; shift
356    
357     my_WORKDIR="${WORKDIR}"/${environment}
358     S="${my_WORKDIR}"/"${sub_S}"
359    
360     if [[ -d "${S}" ]]; then
361     pushd "$S" &>/dev/null
362     elif [[ -d "${my_WORKDIR}" ]]; then
363     pushd "${my_WORKDIR}" &>/dev/null
364     else
365     pushd "${WORKDIR}" &>/dev/null
366     fi
367    
368     ebegin "Running ${_PHASE:-${EBUILD_PHASE}} phase for $environment"
369     "$@"
370     popd &>/dev/null
371    
372     S=${old_S}
373     }
374    
375     _ruby_each_implementation() {
376     local invoked=no
377     for _ruby_implementation in ${USE_RUBY}; do
378     # only proceed if it's requested
379     use ruby_targets_${_ruby_implementation} || continue
380    
381 flameeyes 1.27 RUBY=$(ruby_implementation_command ${_ruby_implementation})
382 graaff 1.1 invoked=yes
383    
384     if [[ -n "$1" ]]; then
385 flameeyes 1.27 _ruby_invoke_environment ${_ruby_implementation} "$@"
386 graaff 1.1 fi
387    
388     unset RUBY
389     done
390    
391     [[ ${invoked} == "no" ]] && die "You need to select at least one Ruby implementation by setting RUBY_TARGETS in /etc/make.conf."
392     }
393    
394     # @FUNCTION: ruby-ng_pkg_setup
395     # @DESCRIPTION:
396     # Check whether at least one ruby target implementation is present.
397     ruby-ng_pkg_setup() {
398     # This only checks that at least one implementation is present
399     # before doing anything; by leaving the parameters empty we know
400     # it's a special case.
401     _ruby_each_implementation
402 graaff 1.40
403 scarabeus 1.42 has ruby_targets_jruby ${IUSE} && use ruby_targets_jruby && java-pkg_setup-vm
404 graaff 1.1 }
405    
406     # @FUNCTION: ruby-ng_src_unpack
407     # @DESCRIPTION:
408 graaff 1.5 # Unpack the source archive.
409 graaff 1.1 ruby-ng_src_unpack() {
410     mkdir "${WORKDIR}"/all
411     pushd "${WORKDIR}"/all &>/dev/null
412    
413     # We don't support an each-unpack, it's either all or nothing!
414     if type all_ruby_unpack &>/dev/null; then
415     _ruby_invoke_environment all all_ruby_unpack
416     else
417     [[ -n ${A} ]] && unpack ${A}
418     fi
419    
420     popd &>/dev/null
421     }
422    
423     _ruby_apply_patches() {
424     for patch in "${RUBY_PATCHES[@]}"; do
425     if [ -f "${patch}" ]; then
426     epatch "${patch}"
427     elif [ -f "${FILESDIR}/${patch}" ]; then
428     epatch "${FILESDIR}/${patch}"
429     else
430     die "Cannot find patch ${patch}"
431     fi
432     done
433    
434     # This is a special case: instead of executing just in the special
435     # "all" environment, this will actually copy the effects on _all_
436     # the other environments, and is thus executed before the copy
437     type all_ruby_prepare &>/dev/null && all_ruby_prepare
438     }
439    
440     _ruby_source_copy() {
441     # Until we actually find a reason not to, we use hardlinks, this
442     # should reduce the amount of disk space that is wasted by this.
443 fauli 1.30 cp -prl all ${_ruby_implementation} \
444 graaff 1.1 || die "Unable to copy ${_ruby_implementation} environment"
445     }
446    
447     # @FUNCTION: ruby-ng_src_prepare
448     # @DESCRIPTION:
449     # Apply patches and prepare versions for each ruby target
450     # implementation. Also carry out common clean up tasks.
451     ruby-ng_src_prepare() {
452     # Way too many Ruby packages are prepared on OSX without removing
453     # the extra data forks, we do it here to avoid repeating it for
454     # almost every other ebuild.
455     find . -name '._*' -delete
456    
457     _ruby_invoke_environment all _ruby_apply_patches
458    
459 flameeyes 1.7 _PHASE="source copy" \
460     _ruby_each_implementation _ruby_source_copy
461 graaff 1.1
462     if type each_ruby_prepare &>/dev/null; then
463     _ruby_each_implementation each_ruby_prepare
464     fi
465     }
466    
467     # @FUNCTION: ruby-ng_src_configure
468     # @DESCRIPTION:
469     # Configure the package.
470     ruby-ng_src_configure() {
471     if type each_ruby_configure &>/dev/null; then
472     _ruby_each_implementation each_ruby_configure
473     fi
474    
475     type all_ruby_configure &>/dev/null && \
476     _ruby_invoke_environment all all_ruby_configure
477     }
478    
479     # @FUNCTION: ruby-ng_src_compile
480     # @DESCRIPTION:
481     # Compile the package.
482     ruby-ng_src_compile() {
483     if type each_ruby_compile &>/dev/null; then
484     _ruby_each_implementation each_ruby_compile
485     fi
486    
487     type all_ruby_compile &>/dev/null && \
488     _ruby_invoke_environment all all_ruby_compile
489     }
490    
491     # @FUNCTION: ruby-ng_src_test
492     # @DESCRIPTION:
493     # Run tests for the package.
494     ruby-ng_src_test() {
495     if type each_ruby_test &>/dev/null; then
496     _ruby_each_implementation each_ruby_test
497     fi
498    
499     type all_ruby_test &>/dev/null && \
500     _ruby_invoke_environment all all_ruby_test
501     }
502    
503     _each_ruby_check_install() {
504 flameeyes 1.24 local scancmd=scanelf
505     # we have a Mach-O object here
506     [[ ${CHOST} == *-darwin ]] && scancmd=scanmacho
507    
508     has "${EAPI}" 2 && ! use prefix && EPREFIX=
509    
510 graaff 1.1 local libruby_basename=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["LIBRUBY_SO"]')
511 flameeyes 1.25 local libruby_soname=$(basename $(${scancmd} -F "%S#F" -qS "${EPREFIX}/usr/$(get_libdir)/${libruby_basename}") 2>/dev/null)
512 flameeyes 1.2 local sitedir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitedir"]')
513     local sitelibdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')
514    
515     # Look for wrong files in sitedir
516 flameeyes 1.22 # if [[ -d "${D}${sitedir}" ]]; then
517     # local f=$(find "${D}${sitedir}" -mindepth 1 -maxdepth 1 -not -wholename "${D}${sitelibdir}")
518     # if [[ -n ${f} ]]; then
519     # eerror "Found files in sitedir, outsite sitelibdir:"
520     # eerror "${f}"
521     # die "Misplaced files in sitedir"
522     # fi
523     # fi
524 graaff 1.1
525     # The current implementation lacks libruby (i.e.: jruby)
526     [[ -z ${libruby_soname} ]] && return 0
527    
528 flameeyes 1.23 # Check also the gems directory, since we could be installing compiled
529     # extensions via ruby-fakegem; make sure to check only in sitelibdir, since
530     # that's what changes between two implementations (otherwise you'd get false
531     # positives now that Ruby 1.9.2 installs with the same sitedir as 1.8)
532 flameeyes 1.24 ${scancmd} -qnR "${D}${sitelibdir}" "${D}${sitelibdir/site_ruby/gems}" \
533 graaff 1.1 | fgrep -v "${libruby_soname}" \
534 graaff 1.34 | grep -E -v "${RUBY_QA_ALLOWED_LIBS}" \
535 graaff 1.1 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
536    
537     if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
538 flameeyes 1.15 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
539 graaff 1.1 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
540 flameeyes 1.15 die "Missing links to ${libruby_soname}"
541 graaff 1.1 fi
542     }
543    
544     # @FUNCTION: ruby-ng_src_install
545     # @DESCRIPTION:
546     # Install the package for each ruby target implementation.
547     ruby-ng_src_install() {
548     if type each_ruby_install &>/dev/null; then
549     _ruby_each_implementation each_ruby_install
550     fi
551    
552     type all_ruby_install &>/dev/null && \
553     _ruby_invoke_environment all all_ruby_install
554    
555     _PHASE="check install" \
556     _ruby_each_implementation _each_ruby_check_install
557     }
558    
559 a3li 1.11 # @FUNCTION: ruby_rbconfig_value
560     # @USAGE: rbconfig item
561     # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
562     ruby_rbconfig_value() {
563     echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']")
564     }
565    
566 graaff 1.1 # @FUNCTION: doruby
567     # @USAGE: file [file...]
568     # @DESCRIPTION:
569     # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
570     doruby() {
571 flameeyes 1.4 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
572 flameeyes 1.24 has "${EAPI}" 2 && ! use prefix && EPREFIX=
573 graaff 1.1 ( # don't want to pollute calling env
574 flameeyes 1.24 sitelibdir=$(ruby_rbconfig_value 'sitelibdir')
575     insinto ${sitelibdir#${EPREFIX}}
576 graaff 1.1 insopts -m 0644
577     doins "$@"
578     ) || die "failed to install $@"
579     }
580    
581     # @FUNCTION: ruby_get_libruby
582     # @RETURN: The location of libruby*.so belonging to the Ruby interpreter in ${RUBY}.
583     ruby_get_libruby() {
584     ${RUBY} -rrbconfig -e 'puts File.join(Config::CONFIG["libdir"], Config::CONFIG["LIBRUBY"])'
585     }
586    
587     # @FUNCTION: ruby_get_hdrdir
588     # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
589     ruby_get_hdrdir() {
590 a3li 1.11 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
591 graaff 1.1
592     if [[ "${rubyhdrdir}" = "nil" ]] ; then
593 a3li 1.11 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
594 graaff 1.1 fi
595    
596     echo "${rubyhdrdir}"
597     }
598 a3li 1.10
599     # @FUNCTION: ruby_get_version
600     # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
601     ruby_get_version() {
602     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
603    
604     echo $(${ruby} -e 'puts RUBY_VERSION')
605     }
606    
607     # @FUNCTION: ruby_get_implementation
608     # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
609     ruby_get_implementation() {
610     local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
611    
612     case $(${ruby} --version) in
613     *Enterprise*)
614     echo "ree"
615     ;;
616     *jruby*)
617     echo "jruby"
618     ;;
619 graaff 1.41 *rubinius*)
620     echo "rbx"
621     ;;
622 a3li 1.10 *)
623     echo "mri"
624     ;;
625     esac
626     }

  ViewVC Help
Powered by ViewVC 1.1.20