Skip to content

Commit

Permalink
ruby-ng.eclass: Indirect USE_RUBY into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
mgorny committed May 15, 2017
1 parent a23568a commit 29cc939
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eclass/ruby-fakegem.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ ruby_fakegem_binwrapper() {
# calling the script by default (see for instance the
# JRuby-specific commands).
local rubycmd=
for implementation in ${USE_RUBY}; do
for implementation in $(_ruby_get_all_impls); do
# ignore non-enabled implementations
use ruby_targets_${implementation} || continue
if [ -z $rubycmd ]; then
Expand Down
29 changes: 22 additions & 7 deletions eclass/ruby-ng.eclass
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ ruby_implementation_depend() {
_ruby_implementation_depend $1
}

# @FUNCTION: _ruby_get_all_impls
# @INTERNAL
# @RETURN: list of valid values in USE_RUBY
# Return a list of valid implementations in USE_RUBY, skipping the old
# implementations that are no longer supported.
_ruby_get_all_impls() {
local i
for i in ${USE_RUBY}; do
case ${i} in
*)
echo ${i};;
esac
done
}

# @FUNCTION: ruby_samelib
# @RETURN: use flag string with current ruby implementations
# @DESCRIPTION:
Expand All @@ -118,7 +133,7 @@ ruby_implementation_depend() {
# more complex dependencies.
ruby_samelib() {
local res=
for _ruby_implementation in $USE_RUBY; do
for _ruby_implementation in $(_ruby_get_all_impls); do
has -${_ruby_implementation} $@ || \
res="${res}ruby_targets_${_ruby_implementation}?,"
done
Expand Down Expand Up @@ -159,7 +174,7 @@ ruby_implementation_command() {
_ruby_atoms_samelib() {
local atoms=$(_ruby_atoms_samelib_generic "$*")

for _ruby_implementation in $USE_RUBY; do
for _ruby_implementation in $(_ruby_get_all_impls); do
echo "${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}"
done
}
Expand Down Expand Up @@ -243,7 +258,7 @@ ruby_add_bdepend() {
# Gets an array of ruby use targets enabled by the user
ruby_get_use_implementations() {
local i implementation
for implementation in ${USE_RUBY}; do
for implementation in $(_ruby_get_all_impls); do
use ruby_targets_${implementation} && i+=" ${implementation}"
done
echo $i
Expand All @@ -254,7 +269,7 @@ ruby_get_use_implementations() {
# Gets an array of ruby use targets that the ebuild sets
ruby_get_use_targets() {
local t implementation
for implementation in ${USE_RUBY}; do
for implementation in $(_ruby_get_all_impls); do
t+=" ruby_targets_${implementation}"
done
echo $t
Expand All @@ -278,7 +293,7 @@ ruby_get_use_targets() {
# RDEPEND="${DEPEND}"
ruby_implementations_depend() {
local depend
for _ruby_implementation in ${USE_RUBY}; do
for _ruby_implementation in $(_ruby_get_all_impls); do
depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )"
done
echo "${depend}"
Expand Down Expand Up @@ -358,7 +373,7 @@ _ruby_invoke_environment() {

_ruby_each_implementation() {
local invoked=no
for _ruby_implementation in ${USE_RUBY}; do
for _ruby_implementation in $(_ruby_get_all_impls); do
# only proceed if it's requested
use ruby_targets_${_ruby_implementation} || continue

Expand All @@ -374,7 +389,7 @@ _ruby_each_implementation() {

if [[ ${invoked} == "no" ]]; then
eerror "You need to select at least one compatible Ruby installation target via RUBY_TARGETS in make.conf."
eerror "Compatible targets for this package are: ${USE_RUBY}"
eerror "Compatible targets for this package are: $(_ruby_get_all_impls)"
eerror
eerror "See https://www.gentoo.org/proj/en/prog_lang/ruby/index.xml#doc_chap3 for more information."
eerror
Expand Down

0 comments on commit 29cc939

Please sign in to comment.