From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 03/11] HACK! llvm-r1 -> llvm-r2 (to ease testing)
Date: Sat, 21 Dec 2024 16:48:36 +0100 [thread overview]
Message-ID: <20241221160053.780079-4-mgorny@gentoo.org> (raw)
In-Reply-To: <20241221160053.780079-1-mgorny@gentoo.org>
---
eclass/llvm-r1.eclass | 201 +-----------------------------------------
1 file changed, 2 insertions(+), 199 deletions(-)
diff --git a/eclass/llvm-r1.eclass b/eclass/llvm-r1.eclass
index e59bd9c317b9..79fe63df3f96 100644
--- a/eclass/llvm-r1.eclass
+++ b/eclass/llvm-r1.eclass
@@ -47,207 +47,10 @@ esac
if [[ -z ${_LLVM_R1_ECLASS} ]]; then
_LLVM_R1_ECLASS=1
-inherit llvm-utils
+inherit llvm-r2
-# == internal control knobs ==
-
-# @ECLASS_VARIABLE: _LLVM_OLDEST_SLOT
-# @INTERNAL
-# @DESCRIPTION:
-# Oldest supported LLVM slot. This is used to automatically filter out
-# unsupported LLVM_COMPAT values.
-_LLVM_OLDEST_SLOT=15
-
-# @ECLASS_VARIABLE: _LLVM_NEWEST_STABLE
-# @INTERNAL
-# @DESCRIPTION:
-# The newest stable LLVM version. Versions newer than that won't
-# be automatically enabled via USE defaults.
-_LLVM_NEWEST_STABLE=19
-
-# == control variables ==
-
-# @ECLASS_VARIABLE: LLVM_COMPAT
-# @PRE_INHERIT
-# @REQUIRED
-# @DESCRIPTION:
-# A list of LLVM slots supported by the package, oldest to newest.
-#
-# Example:
-# @CODE
-# LLVM_COMPAT=( {15..17} )
-# @CODE
-
-# @ECLASS_VARIABLE: LLVM_OPTIONAL
-# @PRE_INHERIT
-# @DEFAULT_UNSET
-# @DESCRIPTION:
-# If set to a non-empty value, disables setting REQUIRED_USE
-# and exporting pkg_setup. You have to add LLVM_REQUIRED_USE and call
-# pkg_setup manually, with appropriate USE conditions.
-
-# == global metadata ==
-
-# @ECLASS_VARIABLE: LLVM_REQUIRED_USE
-# @OUTPUT_VARIABLE
-# @DESCRIPTION:
-# An eclass-generated REQUIRED_USE string that enforces selecting
-# exactly one slot. It LLVM_OPTIONAL is set, it needs to be copied
-# into REQUIRED_USE, under appropriate USE conditions. Otherwise,
-# it is added automatically.
-
-# @ECLASS_VARIABLE: LLVM_USEDEP
-# @OUTPUT_VARIABLE
-# @DESCRIPTION:
-# An eclass-generated USE dependency string that can be applied to other
-# packages using the same eclass, to enforce a LLVM slot match.
-
-_llvm_set_globals() {
- debug-print-function ${FUNCNAME} "$@"
-
- if [[ ${LLVM_COMPAT@a} != *a* ]]; then
- die "LLVM_COMPAT must be set to an array before inheriting ${ECLASS}"
- fi
-
- local stable=() unstable=()
- local x
- for x in "${LLVM_COMPAT[@]}"; do
- if [[ ${x} -gt ${_LLVM_NEWEST_STABLE} ]]; then
- unstable+=( "${x}" )
- elif [[ ${x} -ge ${_LLVM_OLDEST_SLOT} ]]; then
- stable+=( "${x}" )
- fi
- done
-
- _LLVM_SLOTS=( "${stable[@]}" "${unstable[@]}" )
- if [[ ! ${_LLVM_SLOTS[@]} ]]; then
- die "LLVM_COMPAT does not contain any valid versions (all older than ${_LLVM_OLDEST_SLOT}?)"
- fi
-
- if [[ ${stable[@]} ]]; then
- # If there is at least one stable slot supported, then enable
- # the newest stable slot by default.
- IUSE="+llvm_slot_${stable[-1]}"
- unset 'stable[-1]'
- else
- # Otherwise, enable the "oldest" ~arch slot. We really only
- # expect a single ~arch version, so this primarily prevents
- # defaulting to non-keyworded slots.
- IUSE="+llvm_slot_${unstable[0]}"
- unset 'unstable[0]'
- fi
- local nondefault=( "${stable[@]}" "${unstable[@]}" )
- IUSE+=" ${nondefault[*]/#/llvm_slot_}"
-
- local flags=( "${_LLVM_SLOTS[@]/#/llvm_slot_}" )
- LLVM_REQUIRED_USE="^^ ( ${flags[*]} )"
- local usedep_flags=${flags[*]/%/(-)?}
- LLVM_USEDEP=${usedep_flags// /,}
- readonly LLVM_REQUIRED_USE LLVM_USEDEP
-
- if [[ ! ${LLVM_OPTIONAL} ]]; then
- REQUIRED_USE=${LLVM_REQUIRED_USE}
- fi
-}
-_llvm_set_globals
-unset -f _llvm_set_globals
-
-# == metadata helpers ==
-
-# @FUNCTION: llvm_gen_dep
-# @USAGE: <dependency>
-# @DESCRIPTION:
-# Output a dependency block, repeating "<dependency>" conditionally
-# to all llvm_slot_* USE flags. Any occurences of '${LLVM_SLOT}'
-# within the block will be substituted for the respective slot.
-#
-# Example:
-# @CODE
-# DEPEND="
-# $(llvm_gen_dep '
-# llvm-core/clang:${LLVM_SLOT}=
-# llvm-core/llvm:${LLVM_SLOT}=
-# ')
-# "
-# @CODE
-llvm_gen_dep() {
- debug-print-function ${FUNCNAME} "$@"
-
- [[ ${#} -ne 1 ]] && die "Usage: ${FUNCNAME} <dependency>"
-
- local dep=${1}
-
- local slot
- for slot in "${_LLVM_SLOTS[@]}"; do
- echo "llvm_slot_${slot}? ( ${dep//\$\{LLVM_SLOT\}/${slot}} )"
- done
-}
-
-# == ebuild helpers ==
-
-# @FUNCTION: get_llvm_prefix
-# @USAGE: [-b|-d]
-# @DESCRIPTION:
-# Output the path to the selected LLVM slot.
-#
-# With no option or "-d", the path is prefixed by ESYSROOT. LLVM
-# dependencies should be in DEPEND then.
-#
-# With "-b" option, the path is prefixed by BROOT. LLVM dependencies
-# should be in BDEPEND then.
-get_llvm_prefix() {
- debug-print-function ${FUNCNAME} "$@"
-
- [[ ${#} -gt 1 ]] && die "Usage: ${FUNCNAME} [-b|-d]"
-
- local prefix
- case ${1--d} in
- -d)
- prefix=${ESYSROOT}
- ;;
- -b)
- prefix=${BROOT}
- ;;
- *)
- die "${FUNCNAME}: invalid option: ${1}"
- ;;
- esac
-
- echo "${prefix}/usr/lib/llvm/${LLVM_SLOT}"
-}
-
-# @FUNCTION: llvm-r1_pkg_setup
-# @DESCRIPTION:
-# Prepend the appropriate executable directory for the selected LLVM
-# slot to PATH.
-#
-# The PATH manipulation is only done for source builds. The function
-# is a no-op when installing a binary package.
-#
-# If any other behavior is desired, the contents of the function
-# should be inlined into the ebuild and modified as necessary.
-#
-# Note that this function is not exported if LLVM_OPTIONAL is set.
-# In that case, it needs to be called manually.
llvm-r1_pkg_setup() {
- debug-print-function ${FUNCNAME} "$@"
-
- if [[ ${MERGE_TYPE} != binary ]]; then
- [[ -z ${LLVM_SLOT} ]] && die "LLVM_SLOT unset (broken USE_EXPAND?)"
-
- 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
-
- # Set LLVM_CONFIG to help Meson (bug #907965) but only do it
- # for empty ESYSROOT (as a proxy for "are we cross-compiling?").
- if [[ -z ${ESYSROOT} ]] ; then
- llvm_fix_tool_path LLVM_CONFIG
- fi
-
- llvm_prepend_path "${LLVM_SLOT}"
- fi
+ llvm-r2_pkg_setup
}
fi
--
2.47.1
next prev parent reply other threads:[~2024-12-21 16:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-21 15:48 [gentoo-dev] [PATCH 00/11] llvm-r2.eclass, to unmess pkg_setup and fix cross Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 01/11] llvm-r1.eclass: Fix list in eclassdoc Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 02/11] llvm-r2.eclass: Copy from llvm-r1.eclass Michał Górny
2024-12-21 15:48 ` Michał Górny [this message]
2024-12-21 15:48 ` [gentoo-dev] [PATCH 04/11] llvm-utils.eclass: Support -b/-d to llvm_prepend_path Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 05/11] llvm-r2.eclass: Readjust for BROOT, split to llvm_cbuild_setup Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 06/11] llvm-r2.eclass: Add llvm_chost_setup, set CMake path variables Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 07/11] llvm-r2.eclass: Generate a llvm-config script for CHOST Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 08/11] llvm-r2.eclass: Update top-level docs for CBUILD/CHOST support Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 09/11] llvm-r2.eclass: Remove obsolete Meson LLVM_CONFIG hack Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 10/11] eclass/tests: Copy llvm-r1 tests to llvm-r2.sh Michał Górny
2024-12-21 15:48 ` [gentoo-dev] [PATCH 11/11] eclass/tests/llvm-r2.sh: Add tests for llvm-config Michał Górny
2024-12-30 11:35 ` [gentoo-dev] [PATCH 00/11] llvm-r2.eclass, to unmess pkg_setup and fix cross Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241221160053.780079-4-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox