toolchain.eclass: fix ada build with lto
[gentoo.git] / eclass / ruby-single.eclass
1 # Copyright 1999-2018 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 # @SUPPORTED_EAPIS: 4 5 6 7
11 # @BLURB: An eclass for Ruby packages not installed for multiple implementations.
12 # @DESCRIPTION:
13 # An eclass for packages which don't support being installed for
14 # multiple Ruby implementations. This mostly includes ruby-based
15 # scripts. Set USE_RUBY to include all the ruby targets that have been
16 # verified to work and include the eclass. RUBY_DEPS is now available to
17 # pull in the dependency on the requested ruby targets.
18 #
19 # @CODE
20 # USE_RUBY="ruby20 ruby21"
21 # inherit ruby-single
22 # RDEPEND="${RUBY_DEPS}"
23 # @CODE
24
25 case "${EAPI:-0}" in
26         0|1|2|3)
27                 die "Unsupported EAPI=${EAPI:-0} (too old) for ${ECLASS}"
28                 ;;
29         4|5|6|7)
30                 ;;
31         *)
32                 die "Unsupported EAPI=${EAPI} (unknown) for ${ECLASS}"
33                 ;;
34 esac
35
36 if [[ ! ${_RUBY_SINGLE} ]]; then
37
38 inherit ruby-utils
39
40 # @ECLASS-VARIABLE: USE_RUBY
41 # @DEFAULT_UNSET
42 # @REQUIRED
43 # @DESCRIPTION:
44 # This variable contains a space separated list of targets (see above) a package
45 # is compatible to. It must be set before the `inherit' call. There is no
46 # default. All ebuilds are expected to set this variable.
47
48
49 # @ECLASS-VARIABLE: RUBY_DEPS
50 # @DEFAULT_UNSET
51 # @DESCRIPTION:
52 #
53 # This is an eclass-generated Ruby dependency string for all
54 # implementations listed in USE_RUBY. Any one of the supported ruby
55 # targets will satisfy this dependency. A dependency on
56 # virtual/rubygems is also added to ensure that this is installed
57 # in time for the package to use it.
58 #
59 # Example use:
60 # @CODE
61 # RDEPEND="${RUBY_DEPS}
62 #   dev-foo/mydep"
63 # BDEPEND="${RDEPEND}"
64 # @CODE
65 #
66 # Example value:
67 # @CODE
68 # || ( dev-lang/ruby:2.0 dev-lang/ruby:1.9 ) virtual/rubygems
69 # @CODE
70 #
71 # The order of dependencies will change over time to best match the
72 # current state of ruby targets, e.g. stable version first.
73
74 _ruby_single_implementations_depend() {
75         local depend
76         for _ruby_implementation in ${RUBY_TARGETS_PREFERENCE}; do
77                 if [[ ${USE_RUBY} =~ ${_ruby_implementation} ]]; then
78                         depend="${depend} $(_ruby_implementation_depend $_ruby_implementation)"
79                 fi
80         done
81         echo "|| ( ${depend} ) virtual/rubygems"
82 }
83
84 _ruby_single_set_globals() {
85         RUBY_DEPS=$(_ruby_single_implementations_depend)
86 }
87 _ruby_single_set_globals
88
89
90 _RUBY_SINGLE=1
91 fi