Drop $Id$ per council decision in bug #611234.
[gentoo.git] / eclass / ruby-single.eclass
1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 # @ECLASS: ruby-single.eclass
5 # @MAINTAINER:
6 # Ruby team <ruby@gentoo.org>
7 # @AUTHOR:
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.
11 # @DESCRIPTION:
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.
17 #
18 # @CODE
19 # USE_RUBY="ruby20 ruby21"
20 # inherit ruby-single
21 # RDEPEND="${RUBY_DEPS}"
22 # @CODE
23
24 case "${EAPI:-0}" in
25         0|1|2|3)
26                 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
27                 ;;
28         4|5|6)
29                 ;;
30         *)
31                 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
32                 ;;
33 esac
34
35 if [[ ! ${_RUBY_SINGLE} ]]; then
36
37 inherit ruby-utils
38
39 # @ECLASS-VARIABLE: USE_RUBY
40 # @DEFAULT_UNSET
41 # @REQUIRED
42 # @DESCRIPTION:
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.
46
47
48 # @ECLASS-VARIABLE: RUBY_DEPS
49 # @DESCRIPTION:
50 #
51 # This is an eclass-generated Ruby dependency string for all
52 # implementations listed in USE_RUBY. Any one of the supported ruby
53 # targets will satisfy this dependency. A dependency on
54 # virtual/rubygems is also added to ensure that this is installed
55 # in time for the package to use it.
56 #
57 # Example use:
58 # @CODE
59 # RDEPEND="${RUBY_DEPS}
60 #   dev-foo/mydep"
61 # BDEPEND="${RDEPEND}"
62 # @CODE
63 #
64 # Example value:
65 # @CODE
66 # || ( dev-lang/ruby:2.0 dev-lang/ruby:1.9 ) virtual/rubygems
67 # @CODE
68 #
69 # The order of dependencies will change over time to best match the
70 # current state of ruby targets, e.g. stable version first.
71
72 _ruby_single_implementations_depend() {
73         local depend
74         for _ruby_implementation in ${RUBY_TARGETS_PREFERENCE}; do
75                 if [[ ${USE_RUBY} =~ ${_ruby_implementation} ]]; then
76                         depend="${depend} $(_ruby_implementation_depend $_ruby_implementation)"
77                 fi
78         done
79         echo "|| ( ${depend} ) virtual/rubygems"
80 }
81
82 _ruby_single_set_globals() {
83         RUBY_DEPS=$(_ruby_single_implementations_depend)
84 }
85 _ruby_single_set_globals
86
87
88 _RUBY_SINGLE=1
89 fi