Provide ruby_implementations_depend() to facilitate ebuilds with RUBY_OPTIONAL=yes...
authorHans de Graaff <graaff@gentoo.org>
Fri, 22 Jul 2011 09:41:17 +0000 (09:41 +0000)
committerHans de Graaff <graaff@gentoo.org>
Fri, 22 Jul 2011 09:41:17 +0000 (09:41 +0000)
eclass/ruby-ng.eclass

index 6a0d1419f81066341f06a474dd148f4024ca00eb..b64a0e870882c5a236f5a804c9b9ccd225d726ee 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.37 2011/07/22 09:10:22 graaff Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ruby-ng.eclass,v 1.38 2011/07/22 09:41:17 graaff Exp $
 #
 # @ECLASS: ruby-ng.eclass
 # @MAINTAINER:
@@ -46,7 +46,9 @@
 
 # @ECLASS-VARIABLE: RUBY_OPTIONAL
 # @DESCRIPTION:
-# Set the value to "yes" to make the dependency on a Ruby interpreter optional.
+# Set the value to "yes" to make the dependency on a Ruby interpreter
+# optional and then ruby_implementations_depend() to help populate
+# DEPEND and RDEPEND.
 
 # @ECLASS-VARIABLE: RUBY_S
 # @DEFAULT_UNSET
@@ -283,16 +285,39 @@ if [[ ${EAPI:-0} -ge 4 && ${RUBY_OPTIONAL} != "yes" ]]; then
        REQUIRED_USE=" || ( $(ruby_get_use_targets) )"
 fi
 
-for _ruby_implementation in $USE_RUBY; do
-       IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
+# @FUNCTION: ruby_implementations_depend
+# @RETURN: Dependencies suitable for injection into DEPEND and RDEPEND.
+# @DESCRIPTION:
+# Produces the dependency string for the various implementations of ruby
+# which the package is being built against. This should not be used when
+# RUBY_OPTIONAL is unset but must be used if RUBY_OPTIONAL=yes. Do not
+# confuse this function with ruby_implementation_depend().
+#
+# @EXAMPLE:
+# EAPI=4
+# RUBY_OPTIONAL=yes
+#
+# inherit ruby-ng
+# ...
+# DEPEND="ruby? ( $(ruby_implementations_depend) )"
+# RDEPEND="${DEPEND}"
+ruby_implementations_depend() {
+       local depend
+       for _ruby_implementation in ${USE_RUBY}; do
+               depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
+       done
+       echo "${depend}"
+}
 
-       # If you specify RUBY_OPTIONAL you also need to take care of
-       # ruby useflag and dependency.
-       if [[ ${RUBY_OPTIONAL} != "yes" ]]; then
-               DEPEND="${DEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
-               RDEPEND="${RDEPEND} ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
-       fi
+for _ruby_implementation in ${USE_RUBY}; do
+       IUSE="${IUSE} ruby_targets_${_ruby_implementation}"
 done
+# If you specify RUBY_OPTIONAL you also need to take care of
+# ruby useflag and dependency.
+if [[ ${RUBY_OPTIONAL} != yes ]]; then
+       DEPEND="${DEPEND} $(ruby_implementations_depend)"
+       RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
+fi
 
 _ruby_invoke_environment() {
        old_S=${S}