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 104AC158020 for ; Mon, 5 Dec 2022 12:28:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5119EE0858; Mon, 5 Dec 2022 12:28:22 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 175CDE0839 for ; Mon, 5 Dec 2022 12:28:22 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH] llvm.eclass: Set LLVM_SLOT in pkg_setup() Date: Mon, 5 Dec 2022 13:28:14 +0100 Message-Id: <20221205122814.426895-1-mgorny@gentoo.org> X-Mailer: git-send-email 2.38.1 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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: c9ceb19e-b79e-470b-880b-d80e23034ae6 X-Archives-Hash: 9ff8028c14144f2ac8bed183430b6b00 Set LLVM_SLOT in pkg_setup() to the selected LLVM slot, for inspection from the package. For example, it can be used to easily compare the version number. Split get_llvm_slot() out of get_llvm_prefix() to factor out the common code. Signed-off-by: Michał Górny --- eclass/llvm.eclass | 53 ++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index 16596ec2ea66..92c05c308f91 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -87,11 +87,10 @@ DEPEND="!!sys-devel/llvm:0" # Correct values of LLVM slots, newest first. declare -g -r _LLVM_KNOWN_SLOTS=( {16..8} ) -# @FUNCTION: get_llvm_prefix +# @FUNCTION: get_llvm_slot # @USAGE: [-b|-d] [] -# @DESCRIPTION: # Find the newest LLVM install that is acceptable for the package, -# and print an absolute path to it. +# and print its major version number (i.e. slot). # # If -b is specified, the checks are performed relative to BROOT, # and BROOT-path is returned. This is appropriate when your package @@ -114,7 +113,7 @@ declare -g -r _LLVM_KNOWN_SLOTS=( {16..8} ) # is acceptable, false otherwise. If llvm_check_deps() is not defined, # the function defaults to checking whether sys-devel/llvm:${LLVM_SLOT} # is installed. -get_llvm_prefix() { +get_llvm_slot() { debug-print-function ${FUNCNAME} "${@}" local hv_switch=-d @@ -126,23 +125,12 @@ get_llvm_prefix() { shift done - local prefix= - if [[ ${EAPI} != 6 ]]; then - case ${hv_switch} in - -b) - prefix=${BROOT} - ;; - -d) - prefix=${ESYSROOT} - ;; - esac - else + if [[ ${EAPI} == 6 ]]; then case ${hv_switch} in -b) die "${FUNCNAME} -b is not supported in EAPI ${EAPI}" ;; -d) - prefix=${EPREFIX} hv_switch= ;; esac @@ -168,7 +156,7 @@ get_llvm_prefix() { has_version ${hv_switch} "sys-devel/llvm:${slot}" || continue fi - echo "${prefix}/usr/lib/llvm/${slot}" + echo "${slot}" return done @@ -180,6 +168,31 @@ get_llvm_prefix() { die "No LLVM slot${1:+ <= ${1}} satisfying the package's dependencies found installed!" } +# @FUNCTION: get_llvm_prefix +# @USAGE: [-b|-d] [] +# @DESCRIPTION: +# Find the newest LLVM install that is acceptable for the package, +# and print an absolute path to it. +# +# The options and behavior is the same as for get_llvm_slot. +get_llvm_prefix() { + debug-print-function ${FUNCNAME} "${@}" + + local prefix=${EPREFIX} + if [[ ${EAPI} != 6 ]]; then + case ${1} in + -b) + prefix=${BROOT} + ;; + *) + prefix=${ESYSROOT} + ;; + esac + fi + + echo "${prefix}/usr/lib/llvm/$(get_llvm_slot "${@}")" +} + # @FUNCTION: llvm_fix_clang_version # @USAGE: ... # @DESCRIPTION: @@ -256,12 +269,16 @@ llvm_pkg_setup() { debug-print-function ${FUNCNAME} "${@}" if [[ ${MERGE_TYPE} != binary ]]; then + LLVM_SLOT=$(get_llvm_slot "${LLVM_MAX_SLOT}") + llvm_fix_clang_version CC CPP CXX # keep in sync with profiles/features/llvm/make.defaults! llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB llvm_fix_tool_path READELF STRINGS STRIP - local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin + local prefix=${EPREFIX} + [[ ${EAPI} != 6 ]] && prefix=${ESYSROOT} + local llvm_path=${prefix}/usr/lib/llvm/${LLVM_SLOT}/bin local IFS=: local split_path=( ${PATH} ) local new_path=() -- 2.38.1