ruby-ng.eclass: Indirect USE_RUBY into a function
authorMichał Górny <mgorny@gentoo.org>
Sat, 13 May 2017 10:18:38 +0000 (12:18 +0200)
committerMichał Górny <mgorny@gentoo.org>
Mon, 15 May 2017 13:28:00 +0000 (15:28 +0200)
eclass/ruby-fakegem.eclass
eclass/ruby-ng.eclass

index 230f55d7cfe225767d006cfcb508e32c4ea20c25..3c10e577a411660b9a7311451a90c6be441b409f 100644 (file)
@@ -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
index 13b00553c0b055c207310915696dd574d75cdef1..64f1b4f402f57c7b16488deb7ca7d6dfd333ae65 100644 (file)
@@ -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:
@@ -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
@@ -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
 }
@@ -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
@@ -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
@@ -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}"
@@ -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
 
@@ -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