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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3BECD138239 for ; Fri, 24 May 2019 04:59:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0185BE0935; Fri, 24 May 2019 04:59:30 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C8A89E0935 for ; Fri, 24 May 2019 04:59:29 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 943F6344F43 for ; Fri, 24 May 2019 04:59:28 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 202A35F2 for ; Fri, 24 May 2019 04:59:26 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1558673954.6e4c784895f5a57e7b3a0891557a72346201f5d6.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/llvm.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 6e4c784895f5a57e7b3a0891557a72346201f5d6 X-VCS-Branch: master Date: Fri, 24 May 2019 04:59:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: bae7c049-64a3-4609-9be5-150f6844edc6 X-Archives-Hash: a3964c0ddf564c09223f329b46c49e82 commit: 6e4c784895f5a57e7b3a0891557a72346201f5d6 Author: Michał Górny gentoo org> AuthorDate: Tue Apr 30 05:31:02 2019 +0000 Commit: Michał Górny gentoo org> CommitDate: Fri May 24 04:59:14 2019 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6e4c7848 llvm.eclass: Add EAPI 7 API to get_llvm_prefix Add two switches to get_llvm_prefix(), '-b' and '-d' to enable use of LLVM API cross support. '-b' is intended to be used whenever prefix to CBUILD llvm-config is needed, and '-d' (the default) is intended to be used whenever prefix to CHOST bindir is needed (to find CMake modules). Signed-off-by: Michał Górny gentoo.org> eclass/llvm.eclass | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass index 6ca2f1737ba..e4ebb937371 100644 --- a/eclass/llvm.eclass +++ b/eclass/llvm.eclass @@ -52,7 +52,7 @@ # DEPEND=${RDEPEND} # # llvm_check_deps() { -# has_version "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]" +# has_version -d "sys-devel/clang:${LLVM_SLOT}[llvm_targets_AMDGPU(+)]" # } # @CODE @@ -84,11 +84,19 @@ if [[ ! ${_LLVM_ECLASS} ]]; then declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 ) # @FUNCTION: get_llvm_prefix -# @USAGE: [] +# @USAGE: [-b|-d] [] # @DESCRIPTION: # Find the newest LLVM install that is acceptable for the package, # and print an absolute path to it. # +# If -b is specified, the checks are performed relative to BROOT, +# and BROOT-path is returned. This is appropriate when your package +# calls llvm-config executable. -b is supported since EAPI 7. +# +# If -d is specified, the checks are performed relative to ESYSROOT, +# and ESYSROOT-path is returned. This is appropriate when your package +# uses CMake find_package(LLVM). -d is the default. +# # If is specified, then only LLVM versions that are not newer # than will be considered. Otherwise, all LLVM versions would # be considered acceptable. The function does not support specifying @@ -105,6 +113,37 @@ declare -g -r _LLVM_KNOWN_SLOTS=( 9 8 7 6 5 4 ) get_llvm_prefix() { debug-print-function ${FUNCNAME} "${@}" + local hv_switch=-d + while [[ ${1} == -* ]]; do + case ${1} in + -b|-d) hv_switch=${1};; + *) break;; + esac + shift + done + + local prefix= + if [[ ${EAPI} != 6 ]]; then + case ${hv_switch} in + -b) + prefix=${BROOT} + ;; + -d) + prefix=${ESYSROOT} + ;; + esac + else + case ${hv_switch} in + -b) + die "${FUNCNAME} -b is not supported in EAPI ${EAPI}" + ;; + -d) + prefix=${EPREFIX} + hv_switch= + ;; + esac + fi + local max_slot=${1} local slot for slot in "${_LLVM_KNOWN_SLOTS[@]}"; do @@ -122,10 +161,10 @@ get_llvm_prefix() { llvm_check_deps || continue else # check if LLVM package is installed - has_version "sys-devel/llvm:${slot}" || continue + has_version ${hv_switch} "sys-devel/llvm:${slot}" || continue fi - echo "${EPREFIX}/usr/lib/llvm/${slot}" + echo "${prefix}/usr/lib/llvm/${slot}" return done @@ -136,8 +175,8 @@ get_llvm_prefix() { # fallback to :0 # assume it's always <= 4 (the lower max_slot allowed) - if has_version "sys-devel/llvm:0"; then - echo "${EPREFIX}/usr" + if has_version ${hv_switch} "sys-devel/llvm:0"; then + echo "${prefix}/usr" return fi