1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: ruby-single.eclass
6 # Ruby team <ruby@gentoo.org>
8 # Author: Hans de Graaff <graaff@gentoo.org>
9 # Based on python-single-r1 by: Michał Górny <mgorny@gentoo.org>
10 # @BLURB: An eclass for Ruby packages not installed for multiple implementations.
12 # An eclass for packages which don't support being installed for
13 # multiple Ruby implementations. This mostly includes ruby-based
14 # scripts. Set USE_RUBY to include all the ruby targets that have been
15 # verified to work and include the eclass. RUBY_DEPS is now available to
16 # pull in the dependency on the requested ruby targets.
19 # USE_RUBY="ruby20 ruby21"
21 # RDEPEND="${RUBY_DEPS}"
26 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
31 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
35 if [[ ! ${_RUBY_SINGLE} ]]; then
39 # @ECLASS-VARIABLE: USE_RUBY
43 # This variable contains a space separated list of targets (see above) a package
44 # is compatible to. It must be set before the `inherit' call. There is no
45 # default. All ebuilds are expected to set this variable.
48 # @ECLASS-VARIABLE: RUBY_DEPS
52 # This is an eclass-generated Ruby dependency string for all
53 # implementations listed in USE_RUBY. Any one of the supported ruby
54 # targets will satisfy this dependency. A dependency on
55 # virtual/rubygems is also added to ensure that this is installed
56 # in time for the package to use it.
60 # RDEPEND="${RUBY_DEPS}
62 # BDEPEND="${RDEPEND}"
67 # || ( dev-lang/ruby:2.0 dev-lang/ruby:1.9 ) virtual/rubygems
70 # The order of dependencies will change over time to best match the
71 # current state of ruby targets, e.g. stable version first.
73 _ruby_single_implementations_depend() {
75 for _ruby_implementation in ${RUBY_TARGETS_PREFERENCE}; do
76 if [[ ${USE_RUBY} =~ ${_ruby_implementation} ]]; then
77 depend="${depend} $(_ruby_implementation_depend $_ruby_implementation)"
80 echo "|| ( ${depend} ) virtual/rubygems"
83 _ruby_single_set_globals() {
84 RUBY_DEPS=$(_ruby_single_implementations_depend)
86 _ruby_single_set_globals