From 9e7e7e66e0c4acdf9db8019d32f28f68c97b28f6 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Fri, 10 Sep 2021 12:17:53 +0200 Subject: llvm.org.eclass: Add LLVM_TARGETS decl API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the target declarations that are currently shared between multiple ebuilds (and there's more to come!) to the eclass to reduce duplication and ease maintenance. Add an API to add USE flags and dependencies on targets to packages. Signed-off-by: Michał Górny --- eclass/llvm.org.eclass | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) (limited to 'eclass') diff --git a/eclass/llvm.org.eclass b/eclass/llvm.org.eclass index fa426f91dff8..f33599c3bb58 100644 --- a/eclass/llvm.org.eclass +++ b/eclass/llvm.org.eclass @@ -95,6 +95,60 @@ inherit multiprocessing # @DESCRIPTION: # LLVM patchset version. No patchset is used if unset. +# @ECLASS-VARIABLE: LLVM_USE_TARGETS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Add LLVM_TARGETS flags. The following values are supported: +# +# - provide - this package provides LLVM targets. USE flags +# and REQUIRED_USE will be added but no dependencies. +# +# - llvm - this package uses targets from LLVM. RDEPEND+DEPEND +# on matching sys-devel/llvm versions with requested flags will +# be added. +# +# Note that you still need to pass enabled targets to the build system, +# usually grabbing them from ${LLVM_TARGETS} (via USE_EXPAND). + + +# == global data == + +# @ECLASS-VARIABLE: ALL_LLVM_EXPERIMENTAL_TARGETS +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# The complete list of LLVM experimental targets available in this LLVM +# version. The value depends on ${PV}. + +# @ECLASS-VARIABLE: ALL_LLVM_PRODUCTION_TARGETS +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# The complete list of LLVM production-ready targets available in this +# LLVM version. The value depends on ${PV}. + +# @ECLASS-VARIABLE: ALL_LLVM_TARGET_FLAGS +# @OUTPUT_VARIABLE +# @DESCRIPTION: +# The list of USE flags corresponding to all LLVM targets in this LLVM +# version. The value depends on ${PV}. + +case ${PV} in + 10*|11*|12*) + # this API is not present for old LLVM versions + ;; + *) + ALL_LLVM_EXPERIMENTAL_TARGETS=( ARC CSKY M68k VE ) + ALL_LLVM_PRODUCTION_TARGETS=( + AArch64 AMDGPU ARM AVR BPF Hexagon Lanai Mips MSP430 NVPTX + PowerPC RISCV Sparc SystemZ WebAssembly X86 XCore + ) + ;; +esac + +ALL_LLVM_TARGET_FLAGS=( + "${ALL_LLVM_PRODUCTION_TARGETS[@]/#/llvm_targets_}" + "${ALL_LLVM_EXPERIMENTAL_TARGETS[@]/#/llvm_targets_}" +) + # == global scope logic == @@ -156,6 +210,25 @@ llvm.org_set_globals() { https://dev.gentoo.org/~mgorny/dist/llvm/llvm-gentoo-patchset-${LLVM_PATCHSET}.tar.xz" fi + local x + case ${LLVM_USE_TARGETS:-__unset__} in + __unset__) + ;; + provide|llvm) + IUSE+=" ${ALL_LLVM_TARGET_FLAGS[*]}" + REQUIRED_USE+=" || ( ${ALL_LLVM_TARGET_FLAGS[*]} )" + ;;& + llvm) + local dep= + for x in "${ALL_LLVM_TARGET_FLAGS[@]}"; do + dep+=" + ${x}? ( ~sys-devel/llvm-${PV}[${x}] )" + done + RDEPEND+=" ${dep}" + DEPEND+=" ${dep}" + ;; + esac + # === useful defaults for cmake-based packages === # least intrusive of all -- cgit v1.2.3-65-gdbad