summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-09-10 12:17:53 +0200
committerMichał Górny <mgorny@gentoo.org>2021-09-20 15:41:20 +0200
commit9e7e7e66e0c4acdf9db8019d32f28f68c97b28f6 (patch)
tree1762b3ac22affc5668b2a32cb41e0db61e047384 /eclass
parentdev-python/zeep: Remove old (diff)
downloadgentoo-9e7e7e66e0c4acdf9db8019d32f28f68c97b28f6.tar.gz
gentoo-9e7e7e66e0c4acdf9db8019d32f28f68c97b28f6.tar.bz2
gentoo-9e7e7e66e0c4acdf9db8019d32f28f68c97b28f6.zip
llvm.org.eclass: Add LLVM_TARGETS decl API
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 <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r--eclass/llvm.org.eclass73
1 files changed, 73 insertions, 0 deletions
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