From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9F78D158008 for ; Thu, 15 Jun 2023 15:55:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8E065E0A60; Thu, 15 Jun 2023 15:53:01 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 53440E0A5C for ; Thu, 15 Jun 2023 15:53:01 +0000 (UTC) From: Sam James To: gentoo-dev@lists.gentoo.org Cc: ruby@gentoo.org, Sam James Subject: [gentoo-dev] [PATCH 09/11] ruby-ng.eclass: cater to USE_RUBY conditional calls Date: Thu, 15 Jun 2023 16:52:36 +0100 Message-ID: <20230615155240.589982-9-sam@gentoo.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230615155240.589982-1-sam@gentoo.org> References: <20230615155240.589982-1-sam@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 6691baf2-0b30-45bd-9b1c-4daf62a1f705 X-Archives-Hash: 4c2e7b5a19f8a1599175b48c26e82082 Packages may try to restrict their test dependencies to ease bootstrapping/porting if they're not yet available for a newer Ruby implementation by setting USE_RUBY="" ruby_add_bdepend ... For example, dev-ruby/parallel does: ``` # Rails isn't yet ruby32-ready in Gentoo USE_RUBY="ruby27 ruby30 ruby31" ruby_add_bdepend " test? ( dev-ruby/activerecord[sqlite] ) ``` This isn't ideal, but we don't have a ruby_gen_cond_dep right now, so cater to this usecase by invalidating the caches we've previously added if we've detected USE_RUBY changed. Signed-off-by: Sam James --- eclass/ruby-ng.eclass | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/eclass/ruby-ng.eclass b/eclass/ruby-ng.eclass index 3269ed52cafe0..14f4414337d6f 100644 --- a/eclass/ruby-ng.eclass +++ b/eclass/ruby-ng.eclass @@ -102,8 +102,9 @@ ruby_implementation_depend() { # @DESCRIPTION: # Return a list of valid implementations in USE_RUBY, skipping the old # implementations that are no longer supported. -_RUBY_GET_ALL_IMPLS=() _ruby_get_all_impls() { + _RUBY_GET_ALL_IMPLS=() + local i found_valid_impl for i in ${USE_RUBY}; do case ${i} in @@ -132,6 +133,8 @@ _ruby_get_all_impls() { ruby_samelib() { debug-print-function ${FUNCNAME} "${@}" + _ruby_set_globals_invalidate_if_stale + local res= for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do has -${_ruby_implementation} $@ || \ @@ -176,6 +179,7 @@ _ruby_atoms_samelib() { atoms+=" ) " eshopts_pop + _ruby_set_globals_invalidate_if_stale local _ruby_implementation for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do _RUBY_ATOMS_SAMELIB_RESULT+="${atoms//RUBYTARGET/ruby_targets_${_ruby_implementation}}" @@ -227,6 +231,7 @@ ruby_add_rdepend() { ;; esac + _ruby_set_globals_invalidate_if_stale _ruby_atoms_samelib "$1" RDEPEND+=" ${_RUBY_ATOMS_SAMELIB_RESULT}" @@ -274,6 +279,7 @@ ruby_add_bdepend() { ;; esac + _ruby_set_globals_invalidate_if_stale _ruby_atoms_samelib "$1" case ${EAPI} in @@ -300,6 +306,7 @@ ruby_add_depend() { *) die "bad number of arguments to $0" ;; esac + _ruby_set_globals_invalidate_if_stale _ruby_atoms_samelib "$1" DEPEND+=" ${_RUBY_ATOMS_SAMELIB_RESULT}" @@ -311,6 +318,8 @@ ruby_add_depend() { ruby_get_use_implementations() { debug-print-function ${FUNCNAME} "${@}" + _ruby_set_globals_invalidate_if_stale + local i implementation for implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do use ruby_targets_${implementation} && i+=" ${implementation}" @@ -324,6 +333,7 @@ ruby_get_use_implementations() { ruby_get_use_targets() { debug-print-function ${FUNCNAME} "${@}" + _ruby_set_globals_invalidate_if_stale _ruby_get_use_targets echo "${_RUBY_GET_USE_TARGETS}" } @@ -336,6 +346,8 @@ _RUBY_GET_USE_TARGETS="" _ruby_get_use_targets() { debug-print-function ${FUNCNAME} "${@}" + _ruby_set_globals_invalidate_if_stale + local impls="${_RUBY_GET_ALL_IMPLS[@]}" _RUBY_GET_USE_TARGETS="${impls//ruby/ruby_targets_ruby}" } @@ -360,11 +372,14 @@ _RUBY_IMPLEMENTATIONS_DEPEND="" ruby_implementations_depend() { debug-print-function ${FUNCNAME} "${@}" + _ruby_set_globals_invalidate_if_stale _ruby_implementations_depend echo "${_RUBY_IMPLEMENTATIONS_DEPEND}" } _ruby_implementations_depend() { + _ruby_set_globals_invalidate_if_stale + local depend _ruby_implementation for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do depend="${depend}${depend+ }ruby_targets_${_ruby_implementation}? ( $(ruby_implementation_depend $_ruby_implementation) )" @@ -372,9 +387,24 @@ _ruby_implementations_depend() { _RUBY_IMPLEMENTATIONS_DEPEND="${depend}" } -_ruby_get_all_impls -_ruby_get_use_targets -_ruby_implementations_depend +_ruby_set_globals() { + _RUBY_SET_GLOBALS_USE_RUBY="${USE_RUBY}" + _ruby_get_all_impls + _ruby_get_use_targets + _ruby_implementations_depend +} + +_ruby_set_globals_invalidate_if_stale() { + # Packages may try to restrict their test dependencies to ease bootstrapping/porting + # if they're not yet available for a newer Ruby implementation by setting + # USE_RUBY="" ruby_add_bdepend ... + if [[ ${_RUBY_SET_GLOBALS_USE_RUBY} != ${USE_RUBY} && -z ${_RUBY_SET_GLOBALS_INVALIDATING} ]] ; then + local _RUBY_SET_GLOBALS_INVALIDATING=1 + _ruby_set_globals + fi +} + +_ruby_set_globals IUSE+=" ${_RUBY_GET_USE_TARGETS}" # If you specify RUBY_OPTIONAL you also need to take care of @@ -434,6 +464,8 @@ _ruby_invoke_environment() { } _ruby_each_implementation() { + _ruby_set_globals_invalidate_if_stale + local invoked=no for _ruby_implementation in "${_RUBY_GET_ALL_IMPLS[@]}"; do # only proceed if it's requested -- 2.41.0