diff options
author | 2024-12-16 11:24:07 +0100 | |
---|---|---|
committer | 2024-12-30 12:32:30 +0100 | |
commit | c774f99101c5c940c92fea36061e838ce7514c3e (patch) | |
tree | 1f9e0a92a4fffc2049b32c657922e697f354c6d9 /eclass | |
parent | llvm-r2.eclass: Readjust for BROOT, split to llvm_cbuild_setup (diff) | |
download | gentoo-c774f99101c5c940c92fea36061e838ce7514c3e.tar.gz gentoo-c774f99101c5c940c92fea36061e838ce7514c3e.tar.bz2 gentoo-c774f99101c5c940c92fea36061e838ce7514c3e.zip |
llvm-r2.eclass: Add llvm_chost_setup, set CMake path variables
Add a llvm_chost_setup function that handles CHOST-specific setup.
Initially, this means setting CMake variables that control
`find_package()` lookups.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/llvm-r2.eclass | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/eclass/llvm-r2.eclass b/eclass/llvm-r2.eclass index 93c16e75be83..91e841821331 100644 --- a/eclass/llvm-r2.eclass +++ b/eclass/llvm-r2.eclass @@ -248,16 +248,35 @@ llvm_cbuild_setup() { llvm_prepend_path -b "${LLVM_SLOT}" } -# @FUNCTION: llvm-r2_pkg_setup +# @FUNCTION: llvm_chost_setup # @DESCRIPTION: -# Prepend the appropriate executable directory for the selected LLVM -# slot to PATH. +# Set the environment for finding selected LLVM slot installed +# for CHOST. # -# The PATH manipulation is only done for source builds. The function -# is a no-op when installing a binary package. +# This function is meant to be used when the package in question uses +# LLVM compiles against and links to LLVM. It is called automatically +# by llvm-r2_pkg_setup if LLVM is found installed in ESYSROOT. +llvm_chost_setup() { + debug-print-function ${FUNCNAME} "$@" + + local esysroot_prefix=$(get_llvm_prefix -d) + einfo "Using ${esysroot_prefix} for CHOST LLVM ${LLVM_SLOT}" + [[ -d ${esysroot_prefix} ]] || + die "LLVM ${LLVM_SLOT} not found installed in ESYSROOT (expected: ${esysroot_prefix})" + + # satisfies find_package() in CMake + export LLVM_ROOT="${esysroot_prefix}" + export Clang_ROOT="${esysroot_prefix}" + export LLD_ROOT="${esysroot_prefix}" +} + +# @FUNCTION: llvm-r2_pkg_setup +# @DESCRIPTION: +# Handle all supported setup actions automatically. If LLVM is found +# installed for CBUILD, call llvm_cbuild_setup. If it is found +# installed for CHOST, call llvm_chost_setup. # -# If any other behavior is desired, the contents of the function -# should be inlined into the ebuild and modified as necessary. +# This function is a no-op when installing a binary package. # # Note that this function is not exported if LLVM_OPTIONAL is set. # In that case, it needs to be called manually. @@ -270,6 +289,10 @@ llvm-r2_pkg_setup() { if [[ -d $(get_llvm_prefix -b)/bin ]]; then llvm_cbuild_setup fi + + if [[ -d $(get_llvm_prefix -d) ]]; then + llvm_chost_setup + fi fi } |