1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2009 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.4 2009/12/05 11:33:10 flameeyes Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.13 2010/05/01 16:05:45 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 | # |
… | |
… | |
119 | _ruby_add_bdepend() { |
119 | _ruby_add_bdepend() { |
120 | local atom=$1 |
120 | local atom=$1 |
121 | local conditions=$2 |
121 | local conditions=$2 |
122 | |
122 | |
123 | for condition in $conditions; do |
123 | for condition in $conditions; do |
|
|
124 | hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
124 | atom="${condition}? ( ${atom} )" |
125 | atom="${condition}? ( ${atom} )" |
125 | done |
126 | done |
126 | |
127 | |
127 | DEPEND="${DEPEND} ${atom}" |
128 | DEPEND="${DEPEND} ${atom}" |
128 | RDEPEND="${RDEPEND}" |
129 | RDEPEND="${RDEPEND}" |
… | |
… | |
131 | _ruby_add_rdepend() { |
132 | _ruby_add_rdepend() { |
132 | local atom=$1 |
133 | local atom=$1 |
133 | local conditions=$2 |
134 | local conditions=$2 |
134 | |
135 | |
135 | for condition in $conditions; do |
136 | for condition in $conditions; do |
|
|
137 | hasq $condition "$IUSE" || IUSE="${IUSE} $condition" |
136 | atom="${condition}? ( ${atom} )" |
138 | atom="${condition}? ( ${atom} )" |
137 | done |
139 | done |
138 | |
140 | |
139 | RDEPEND="${RDEPEND} ${atom}" |
141 | RDEPEND="${RDEPEND} ${atom}" |
140 | _ruby_add_bdepend "$atom" test |
142 | _ruby_add_bdepend "$atom" test |
… | |
… | |
212 | fi |
214 | fi |
213 | done |
215 | done |
214 | |
216 | |
215 | _ruby_invoke_environment() { |
217 | _ruby_invoke_environment() { |
216 | old_S=${S} |
218 | old_S=${S} |
217 | sub_S=${S#${WORKDIR}} |
219 | sub_S=${S#${WORKDIR}/} |
|
|
220 | |
|
|
221 | # Special case, for the always-lovely GitHub fetches. With this, |
|
|
222 | # we allow the star glob to just expand to whatever directory it's |
|
|
223 | # called. |
|
|
224 | if [[ ${sub_S} = *"*" ]]; then |
|
|
225 | pushd "${WORKDIR}"/all &>/dev/null |
|
|
226 | sub_S=$(eval ls -d ${sub_S} 2>/dev/null) |
|
|
227 | popd &>/dev/null |
|
|
228 | fi |
218 | |
229 | |
219 | environment=$1; shift |
230 | environment=$1; shift |
220 | |
231 | |
221 | my_WORKDIR="${WORKDIR}"/${environment} |
232 | my_WORKDIR="${WORKDIR}"/${environment} |
222 | S="${my_WORKDIR}"/"${sub_S}" |
233 | S="${my_WORKDIR}"/"${sub_S}" |
… | |
… | |
240 | local invoked=no |
251 | local invoked=no |
241 | for _ruby_implementation in ${USE_RUBY}; do |
252 | for _ruby_implementation in ${USE_RUBY}; do |
242 | # only proceed if it's requested |
253 | # only proceed if it's requested |
243 | use ruby_targets_${_ruby_implementation} || continue |
254 | use ruby_targets_${_ruby_implementation} || continue |
244 | |
255 | |
|
|
256 | local _ruby_name=$_ruby_implementation |
|
|
257 | |
|
|
258 | # Add all USE_RUBY values where the flag name diverts from the binary here |
|
|
259 | case $_ruby_implementation in |
|
|
260 | ree18) |
|
|
261 | _ruby_name=rubyee18 |
|
|
262 | ;; |
|
|
263 | esac |
|
|
264 | |
245 | RUBY=$(type -p $_ruby_implementation 2>/dev/null) |
265 | RUBY=$(type -p $_ruby_name 2>/dev/null) |
246 | invoked=yes |
266 | invoked=yes |
247 | |
267 | |
248 | if [[ -n "$1" ]]; then |
268 | if [[ -n "$1" ]]; then |
249 | _ruby_invoke_environment $_ruby_implementation "$@" |
269 | _ruby_invoke_environment $_ruby_implementation "$@" |
250 | fi |
270 | fi |
… | |
… | |
265 | _ruby_each_implementation |
285 | _ruby_each_implementation |
266 | } |
286 | } |
267 | |
287 | |
268 | # @FUNCTION: ruby-ng_src_unpack |
288 | # @FUNCTION: ruby-ng_src_unpack |
269 | # @DESCRIPTION: |
289 | # @DESCRIPTION: |
270 | # Unpack the source archive, including gems. |
290 | # Unpack the source archive. |
271 | ruby-ng_src_unpack() { |
291 | ruby-ng_src_unpack() { |
272 | mkdir "${WORKDIR}"/all |
292 | mkdir "${WORKDIR}"/all |
273 | pushd "${WORKDIR}"/all &>/dev/null |
293 | pushd "${WORKDIR}"/all &>/dev/null |
274 | |
294 | |
275 | # We don't support an each-unpack, it's either all or nothing! |
295 | # We don't support an each-unpack, it's either all or nothing! |
… | |
… | |
316 | # almost every other ebuild. |
336 | # almost every other ebuild. |
317 | find . -name '._*' -delete |
337 | find . -name '._*' -delete |
318 | |
338 | |
319 | _ruby_invoke_environment all _ruby_apply_patches |
339 | _ruby_invoke_environment all _ruby_apply_patches |
320 | |
340 | |
|
|
341 | _PHASE="source copy" \ |
321 | _ruby_each_implementation _ruby_source_copy |
342 | _ruby_each_implementation _ruby_source_copy |
322 | |
343 | |
323 | if type each_ruby_prepare &>/dev/null; then |
344 | if type each_ruby_prepare &>/dev/null; then |
324 | _ruby_each_implementation each_ruby_prepare |
345 | _ruby_each_implementation each_ruby_prepare |
325 | fi |
346 | fi |
326 | } |
347 | } |
… | |
… | |
404 | |
425 | |
405 | _PHASE="check install" \ |
426 | _PHASE="check install" \ |
406 | _ruby_each_implementation _each_ruby_check_install |
427 | _ruby_each_implementation _each_ruby_check_install |
407 | } |
428 | } |
408 | |
429 | |
|
|
430 | # @FUNCTION: ruby_rbconfig_value |
|
|
431 | # @USAGE: rbconfig item |
|
|
432 | # @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}. |
|
|
433 | ruby_rbconfig_value() { |
|
|
434 | echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']") |
|
|
435 | } |
|
|
436 | |
409 | # @FUNCTION: doruby |
437 | # @FUNCTION: doruby |
410 | # @USAGE: file [file...] |
438 | # @USAGE: file [file...] |
411 | # @DESCRIPTION: |
439 | # @DESCRIPTION: |
412 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
440 | # Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. |
413 | doruby() { |
441 | doruby() { |
414 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
442 | [[ -z ${RUBY} ]] && die "\$RUBY is not set" |
415 | ( # don't want to pollute calling env |
443 | ( # don't want to pollute calling env |
416 | insinto $(${RUBY} -rrbconfig -e 'print Config::CONFIG["sitelibdir"]') |
444 | insinto $(ruby_rbconfig_value 'sitelibdir') |
417 | insopts -m 0644 |
445 | insopts -m 0644 |
418 | doins "$@" |
446 | doins "$@" |
419 | ) || die "failed to install $@" |
447 | ) || die "failed to install $@" |
420 | } |
448 | } |
421 | |
449 | |
… | |
… | |
426 | } |
454 | } |
427 | |
455 | |
428 | # @FUNCTION: ruby_get_hdrdir |
456 | # @FUNCTION: ruby_get_hdrdir |
429 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
457 | # @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. |
430 | ruby_get_hdrdir() { |
458 | ruby_get_hdrdir() { |
431 | local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') |
459 | local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir') |
432 | |
460 | |
433 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
461 | if [[ "${rubyhdrdir}" = "nil" ]] ; then |
434 | rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') |
462 | rubyhdrdir=$(ruby_rbconfig_value 'archdir') |
435 | fi |
463 | fi |
436 | |
464 | |
437 | echo "${rubyhdrdir}" |
465 | echo "${rubyhdrdir}" |
438 | } |
466 | } |
|
|
467 | |
|
|
468 | # @FUNCTION: ruby_get_version |
|
|
469 | # @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
470 | ruby_get_version() { |
|
|
471 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
472 | |
|
|
473 | echo $(${ruby} -e 'puts RUBY_VERSION') |
|
|
474 | } |
|
|
475 | |
|
|
476 | # @FUNCTION: ruby_get_implementation |
|
|
477 | # @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to. |
|
|
478 | ruby_get_implementation() { |
|
|
479 | local ruby=${RUBY:-$(type -p ruby 2>/dev/null)} |
|
|
480 | |
|
|
481 | case $(${ruby} --version) in |
|
|
482 | *Enterprise*) |
|
|
483 | echo "ree" |
|
|
484 | ;; |
|
|
485 | *jruby*) |
|
|
486 | echo "jruby" |
|
|
487 | ;; |
|
|
488 | *) |
|
|
489 | echo "mri" |
|
|
490 | ;; |
|
|
491 | esac |
|
|
492 | } |