/[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.3 Revision 1.15
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.3 2009/12/05 11:32:19 flameeyes Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.15 2010/05/22 03:39: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#
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
143}
144
145_ruby_atoms_samelib() {
146 local samelib=$(ruby_samelib)
147
148 for token in $*; do
149 case "$token" in
150 "||" | "(" | ")" )
151 echo "${token}" ;;
152 *)
153 echo "${token}${samelib}" ;;
154 esac
155 done
141} 156}
142 157
143# @FUNCTION: ruby_add_rdepend 158# @FUNCTION: ruby_add_rdepend
144# @USAGE: [conditions] atom 159# @USAGE: [conditions] atom
145# @DESCRIPTION: 160# @DESCRIPTION:
163 *) 178 *)
164 die "bad number of arguments to $0" 179 die "bad number of arguments to $0"
165 ;; 180 ;;
166 esac 181 esac
167 182
168 for atom in $atoms; do
169 _ruby_add_rdepend "${atom}$(ruby_samelib)" "$conditions" 183 _ruby_add_rdepend "$(_ruby_atoms_samelib "${atoms}")" "$conditions"
170 done
171} 184}
172 185
173# @FUNCTION: ruby_add_bdepend 186# @FUNCTION: ruby_add_bdepend
174# @USAGE: [conditions] atom 187# @USAGE: [conditions] atom
175# @DESCRIPTION: 188# @DESCRIPTION:
194 *) 207 *)
195 die "bad number of arguments to $0" 208 die "bad number of arguments to $0"
196 ;; 209 ;;
197 esac 210 esac
198 211
199 for atom in $atoms; do
200 _ruby_add_bdepend "${atom}$(ruby_samelib)" "$conditions" 212 _ruby_add_bdepend "$(_ruby_atoms_samelib "${atoms}")" "$conditions"
201 done
202} 213}
203 214
204for _ruby_implementation in $USE_RUBY; do 215for _ruby_implementation in $USE_RUBY; do
205 IUSE="${IUSE} ruby_targets_${_ruby_implementation}" 216 IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
206 217
212 fi 223 fi
213done 224done
214 225
215_ruby_invoke_environment() { 226_ruby_invoke_environment() {
216 old_S=${S} 227 old_S=${S}
217 sub_S=${S#${WORKDIR}} 228 sub_S=${S#${WORKDIR}/}
229
230 # Special case, for the always-lovely GitHub fetches. With this,
231 # we allow the star glob to just expand to whatever directory it's
232 # called.
233 if [[ ${sub_S} = *"*" ]]; then
234 pushd "${WORKDIR}"/all &>/dev/null
235 sub_S=$(eval ls -d ${sub_S} 2>/dev/null)
236 popd &>/dev/null
237 fi
218 238
219 environment=$1; shift 239 environment=$1; shift
220 240
221 my_WORKDIR="${WORKDIR}"/${environment} 241 my_WORKDIR="${WORKDIR}"/${environment}
222 S="${my_WORKDIR}"/"${sub_S}" 242 S="${my_WORKDIR}"/"${sub_S}"
240 local invoked=no 260 local invoked=no
241 for _ruby_implementation in ${USE_RUBY}; do 261 for _ruby_implementation in ${USE_RUBY}; do
242 # only proceed if it's requested 262 # only proceed if it's requested
243 use ruby_targets_${_ruby_implementation} || continue 263 use ruby_targets_${_ruby_implementation} || continue
244 264
265 local _ruby_name=$_ruby_implementation
266
267 # Add all USE_RUBY values where the flag name diverts from the binary here
268 case $_ruby_implementation in
269 ree18)
270 _ruby_name=rubyee18
271 ;;
272 esac
273
245 RUBY=$(type -p $_ruby_implementation 2>/dev/null) 274 RUBY=$(type -p $_ruby_name 2>/dev/null)
246 invoked=yes 275 invoked=yes
247 276
248 if [[ -n "$1" ]]; then 277 if [[ -n "$1" ]]; then
249 _ruby_invoke_environment $_ruby_implementation "$@" 278 _ruby_invoke_environment $_ruby_implementation "$@"
250 fi 279 fi
265 _ruby_each_implementation 294 _ruby_each_implementation
266} 295}
267 296
268# @FUNCTION: ruby-ng_src_unpack 297# @FUNCTION: ruby-ng_src_unpack
269# @DESCRIPTION: 298# @DESCRIPTION:
270# Unpack the source archive, including gems. 299# Unpack the source archive.
271ruby-ng_src_unpack() { 300ruby-ng_src_unpack() {
272 mkdir "${WORKDIR}"/all 301 mkdir "${WORKDIR}"/all
273 pushd "${WORKDIR}"/all &>/dev/null 302 pushd "${WORKDIR}"/all &>/dev/null
274 303
275 # We don't support an each-unpack, it's either all or nothing! 304 # We don't support an each-unpack, it's either all or nothing!
316 # almost every other ebuild. 345 # almost every other ebuild.
317 find . -name '._*' -delete 346 find . -name '._*' -delete
318 347
319 _ruby_invoke_environment all _ruby_apply_patches 348 _ruby_invoke_environment all _ruby_apply_patches
320 349
350 _PHASE="source copy" \
321 _ruby_each_implementation _ruby_source_copy 351 _ruby_each_implementation _ruby_source_copy
322 352
323 if type each_ruby_prepare &>/dev/null; then 353 if type each_ruby_prepare &>/dev/null; then
324 _ruby_each_implementation each_ruby_prepare 354 _ruby_each_implementation each_ruby_prepare
325 fi 355 fi
326} 356}
383 scanelf -qnR "${D}${sitedir}" \ 413 scanelf -qnR "${D}${sitedir}" \
384 | fgrep -v "${libruby_soname}" \ 414 | fgrep -v "${libruby_soname}" \
385 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log 415 > "${T}"/ruby-ng-${_ruby_implementation}-mislink.log
386 416
387 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then 417 if [[ -s "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ]]; then
388 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby}" 418 ewarn "Extensions installed for ${_ruby_implementation} with missing links to ${libruby_soname}"
389 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log ) 419 ewarn $(< "${T}"/ruby-ng-${_ruby_implementation}-mislink.log )
390 die "Missing links to ${libruby}" 420 die "Missing links to ${libruby_soname}"
391 fi 421 fi
392} 422}
393 423
394# @FUNCTION: ruby-ng_src_install 424# @FUNCTION: ruby-ng_src_install
395# @DESCRIPTION: 425# @DESCRIPTION:
404 434
405 _PHASE="check install" \ 435 _PHASE="check install" \
406 _ruby_each_implementation _each_ruby_check_install 436 _ruby_each_implementation _each_ruby_check_install
407} 437}
408 438
439# @FUNCTION: ruby_rbconfig_value
440# @USAGE: rbconfig item
441# @RETURN: Returns the value of the given rbconfig item of the Ruby interpreter in ${RUBY}.
442ruby_rbconfig_value() {
443 echo $(${RUBY} -rrbconfig -e "puts Config::CONFIG['$1']")
444}
445
409# @FUNCTION: doruby 446# @FUNCTION: doruby
410# @USAGE: file [file...] 447# @USAGE: file [file...]
411# @DESCRIPTION: 448# @DESCRIPTION:
412# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}. 449# Installs the specified file(s) into the sitelibdir of the Ruby interpreter in ${RUBY}.
413doruby() { 450doruby() {
451 [[ -z ${RUBY} ]] && die "\$RUBY is not set"
414 ( # don't want to pollute calling env 452 ( # don't want to pollute calling env
415 insinto $(${RUBY} -r rbconfig -e 'print Config::CONFIG["sitelibdir"]') 453 insinto $(ruby_rbconfig_value 'sitelibdir')
416 insopts -m 0644 454 insopts -m 0644
417 doins "$@" 455 doins "$@"
418 ) || die "failed to install $@" 456 ) || die "failed to install $@"
419} 457}
420 458
425} 463}
426 464
427# @FUNCTION: ruby_get_hdrdir 465# @FUNCTION: ruby_get_hdrdir
428# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}. 466# @RETURN: The location of the header files belonging to the Ruby interpreter in ${RUBY}.
429ruby_get_hdrdir() { 467ruby_get_hdrdir() {
430 local rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["rubyhdrdir"]') 468 local rubyhdrdir=$(ruby_rbconfig_value 'rubyhdrdir')
431 469
432 if [[ "${rubyhdrdir}" = "nil" ]] ; then 470 if [[ "${rubyhdrdir}" = "nil" ]] ; then
433 rubyhdrdir=$(${RUBY} -rrbconfig -e 'puts Config::CONFIG["archdir"]') 471 rubyhdrdir=$(ruby_rbconfig_value 'archdir')
434 fi 472 fi
435 473
436 echo "${rubyhdrdir}" 474 echo "${rubyhdrdir}"
437} 475}
476
477# @FUNCTION: ruby_get_version
478# @RETURN: The version of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
479ruby_get_version() {
480 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
481
482 echo $(${ruby} -e 'puts RUBY_VERSION')
483}
484
485# @FUNCTION: ruby_get_implementation
486# @RETURN: The implementation of the Ruby interpreter in ${RUBY}, or what 'ruby' points to.
487ruby_get_implementation() {
488 local ruby=${RUBY:-$(type -p ruby 2>/dev/null)}
489
490 case $(${ruby} --version) in
491 *Enterprise*)
492 echo "ree"
493 ;;
494 *jruby*)
495 echo "jruby"
496 ;;
497 *)
498 echo "mri"
499 ;;
500 esac
501}

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.15

  ViewVC Help
Powered by ViewVC 1.1.20