Gentoo Archives: gentoo-dev

From: graaff@g.o
To: gentoo-dev@l.g.o
Cc: Hans de Graaff <graaff@g.o>
Subject: [gentoo-dev] [PATCH 5/6] ruby-ng.eclass: handle BDEPEND for EAPI 7
Date: Sun, 21 Jul 2019 07:56:40
Message-Id: 20190721075510.31524-5-graaff@gentoo.org
In Reply to: [gentoo-dev] [PATCH 1/6] ruby-ng.eclass: add EAPI 7 support by graaff@gentoo.org
1 From: Hans de Graaff <graaff@g.o>
2
3 Add support for BDEPEND in EAPI 7.
4
5 It is not clear how to handle test dependencies since the test
6 framework will need to run on the CBUILD host but the code that needs
7 to run is already cross-compiled for the CHOST. Most likely tests
8 won't work at all in this case. Add test dependencies to BDEPEND in
9 EAPI 7 since this matches most closely to how the test will be
10 executed.
11
12 Adjust `ruby_add_bdepend` to add to BDEPEND on EAPI 7. This also
13 allows us to keep the name for this method. Add a new
14 `ruby_add_depend` to add to DEPEND in EAPI 7 and newer only. This
15 allows for the rare case where gems need to link to other gem
16 code (e.g. dev-ruby/nokogumbo).
17
18 Add ruby itself to RDEPEND, BDEPEND, and DEPEND since it is expected
19 to be present in all three cases.
20
21 Signed-off-by: Hans de Graaff <graaff@g.o>
22 ---
23 eclass/ruby-ng.eclass | 62 ++++++++++++++++++++++++++++++++-----------
24 1 file changed, 47 insertions(+), 15 deletions(-)
25
26 diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass
27 index 8663033a499c..9fb6965a0790 100644
28 --- a/eclass/ruby-ng.eclass
29 +++ b/eclass/ruby-ng.eclass
30 @@ -43,7 +43,7 @@
31 # @DESCRIPTION:
32 # Set the value to "yes" to make the dependency on a Ruby interpreter
33 # optional and then ruby_implementations_depend() to help populate
34 -# DEPEND and RDEPEND.
35 +# BDEPEND, DEPEND and RDEPEND.
36
37 # @ECLASS-VARIABLE: RUBY_S
38 # @DEFAULT_UNSET
39 @@ -223,19 +223,22 @@ ruby_add_rdepend() {
40
41 # Add the dependency as a test-dependency since we're going to
42 # execute the code during test phase.
43 - DEPEND="${DEPEND} test? ( ${dependency} )"
44 + case ${EAPI} in
45 + 4|5|6) DEPEND="${DEPEND} test? ( ${dependency} )" ;;
46 + *) BDEPEND="${BDEPEND} test? ( ${dependency} )" ;;
47 + esac
48 has test "$IUSE" || IUSE="${IUSE} test"
49 }
50
51 # @FUNCTION: ruby_add_bdepend
52 # @USAGE: dependencies
53 # @DESCRIPTION:
54 -# Adds the specified dependencies, with use condition(s) to DEPEND,
55 -# taking the current set of ruby targets into account. This makes sure
56 -# that all ruby dependencies of the package are installed for the same
57 -# ruby targets. Use this function for all ruby dependencies instead of
58 -# setting DEPEND yourself. The list of atoms uses the same syntax as
59 -# normal dependencies.
60 +# Adds the specified dependencies, with use condition(s) to DEPEND (or
61 +# BDEPEND in EAPI7), taking the current set of ruby targets into
62 +# account. This makes sure that all ruby dependencies of the package are
63 +# installed for the same ruby targets. Use this function for all ruby
64 +# dependencies instead of setting DEPEND or BDEPEND yourself. The list
65 +# of atoms uses the same syntax as normal dependencies.
66 ruby_add_bdepend() {
67 case $# in
68 1) ;;
69 @@ -251,10 +254,35 @@ ruby_add_bdepend() {
70
71 local dependency=$(_ruby_atoms_samelib "$1")
72
73 - DEPEND="${DEPEND} $dependency"
74 + case ${EAPI} in
75 + 4|5|6) DEPEND="${DEPEND} $dependency" ;;
76 + *) BDEPEND="${BDEPEND} $dependency" ;;
77 + esac
78 RDEPEND="${RDEPEND}"
79 }
80
81 +# @FUNCTION: ruby_add_depend
82 +# @USAGE: dependencies
83 +# @DESCRIPTION:
84 +
85 +# Adds the specified dependencies to DEPEND in EAPI7, similar to
86 +# ruby_add_bdepend.
87 +ruby_add_depend() {
88 + case ${EAPI} in
89 + 4|5|6) die "only available in EAPI 7 and newer" ;;
90 + *) ;;
91 + esac
92 +
93 + case $# in
94 + 1) ;;
95 + *) die "bad number of arguments to $0" ;;
96 + esac
97 +
98 + local dependency=$(_ruby_atoms_samelib "$1")
99 +
100 + DEPEND="${DEPEND} $dependency"
101 +}
102 +
103 # @FUNCTION: ruby_get_use_implementations
104 # @DESCRIPTION:
105 # Gets an array of ruby use targets enabled by the user
106 @@ -308,6 +336,10 @@ if [[ ${RUBY_OPTIONAL} != yes ]]; then
107 DEPEND="${DEPEND} $(ruby_implementations_depend)"
108 RDEPEND="${RDEPEND} $(ruby_implementations_depend)"
109 REQUIRED_USE+=" || ( $(ruby_get_use_targets) )"
110 + case ${EAPI} in
111 + 4|5|6) ;;
112 + *) BDEPEND="${BDEPEND} $(ruby_implementations_depend)" ;;
113 + esac
114 fi
115
116 _ruby_invoke_environment() {
117 @@ -634,8 +666,8 @@ ruby-ng_rspec() {
118 files="spec"
119 fi
120
121 - if [[ ${DEPEND} != *"dev-ruby/rspec"* ]]; then
122 - ewarn "Missing dev-ruby/rspec in \${DEPEND}"
123 + if [[ "${DEPEND}${BDEPEND}" != *"dev-ruby/rspec"* ]]; then
124 + ewarn "Missing test dependency dev-ruby/rspec"
125 fi
126
127 local rspec_params=
128 @@ -665,8 +697,8 @@ ruby-ng_rspec() {
129 # This is simply a wrapper around the cucumber command (executed by $RUBY})
130 # which also respects TEST_VERBOSE and NOCOLOR environment variables.
131 ruby-ng_cucumber() {
132 - if [[ ${DEPEND} != *"dev-util/cucumber"* ]]; then
133 - ewarn "Missing dev-util/cucumber in \${DEPEND}"
134 + if [[ "${DEPEND}${BDEPEND}" != *"dev-util/cucumber"* ]]; then
135 + ewarn "Missing test dependency dev-util/cucumber"
136 fi
137
138 local cucumber_params=
139 @@ -699,8 +731,8 @@ ruby-ng_cucumber() {
140 # their script and we installed a broken wrapper for a while.
141 # This also respects TEST_VERBOSE and NOCOLOR environment variables.
142 ruby-ng_testrb-2() {
143 - if [[ ${DEPEND} != *"dev-ruby/test-unit"* ]]; then
144 - ewarn "Missing dev-ruby/test-unit in \${DEPEND}"
145 + if [[ "${DEPEND}${BDEPEND}" != *"dev-ruby/test-unit"* ]]; then
146 + ewarn "Missing test dependency dev-ruby/test-unit"
147 fi
148
149 local testrb_params=
150 --
151 2.21.0