From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 11/11] eclass/tests/llvm-r2.sh: Add tests for llvm-config
Date: Sat, 21 Dec 2024 16:48:44 +0100 [thread overview]
Message-ID: <20241221160053.780079-12-mgorny@gentoo.org> (raw)
In-Reply-To: <20241221160053.780079-1-mgorny@gentoo.org>
Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
eclass/tests/llvm-r2.sh | 87 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/eclass/tests/llvm-r2.sh b/eclass/tests/llvm-r2.sh
index e715f7e34e82..fde76d2d682e 100755
--- a/eclass/tests/llvm-r2.sh
+++ b/eclass/tests/llvm-r2.sh
@@ -63,6 +63,80 @@ test_gen_dep() {
tend ${?}
}
+LLVM_CONFIG_OPTIONS=(
+ --assertion-mode
+ --bindir
+ --build-mode
+ --build-system
+ --cflags
+ --cmakedir
+ --components
+ --cppflags
+ --cxxflags
+ --has-rtti
+ --host-target
+ --ignore-libllvm
+ --includedir
+ --ldflags
+ --libdir
+ --libfiles
+ --libnames
+ --libs
+ --link-shared
+ --link-static
+ --obj-root
+ --prefix
+ --shared-mode
+ --system-libs
+ --targets-built
+ --version
+)
+
+normalize_list() {
+ "${@}" |
+ sed -e 's:\s\+:\n:g' |
+ sed -e '/^$/d' |
+ sort
+ local ps=${PIPESTATUS[*]}
+ [[ ${ps} == '0 0 0 0' ]] || die "normalize_list pipe failed: ${ps}"
+}
+
+test_llvm_config() {
+ einfo "llvm-config for slot ${LLVM_SLOT}, libdir ${LLVM_LIBDIR}"
+ eindent
+
+ generate_llvm_config > "${TMP}/llvm-config" || die
+ local triple=$(sh "${TMP}/llvm-config" --host-target || die)
+ local llvm_config=/usr/lib/llvm/${LLVM_SLOT}/bin/${triple}-llvm-config
+
+ local option res
+ for option in "${LLVM_CONFIG_OPTIONS[@]}"; do
+ tbegin "${option}"
+
+ normalize_list sh "${TMP}/llvm-config" "${option}" > "${TMP}/our"
+ normalize_list "${llvm_config}" "${option}" > "${TMP}/upstream"
+ case ${option} in
+ --components)
+ # our components are a superset of what llvm-config yields
+ res=$(comm -13 "${TMP}/our" "${TMP}/upstream")
+ ;;
+ *)
+ # expect all elements to match
+ res=$(comm -3 "${TMP}/our" "${TMP}/upstream")
+ ;;
+ esac
+
+ if [[ -z ${res} ]]; then
+ tend 0
+ else
+ eerror "$(diff -u "${TMP}/our" "${TMP}/upstream")"
+ tend 1
+ fi
+ done
+
+ eoutdent
+}
+
# full range
test_globals '14 15 16 17 18 19' \
"+llvm_slot_19 llvm_slot_15 llvm_slot_16 llvm_slot_17 llvm_slot_18" \
@@ -98,4 +172,17 @@ test_gen_dep 'llvm-core/llvm:${LLVM_SLOT} llvm-core/clang:${LLVM_SLOT}' <<-EOF
llvm_slot_18? ( llvm-core/llvm:18 llvm-core/clang:18 )
EOF
+TMP=$(mktemp -d || die)
+trap 'rm -rf \"${TMP}\"' EXIT
+get_libdir() { echo "${LLVM_LIBDIR}"; }
+
+for installed_llvm_cmake in /usr/lib/llvm/*/lib*/cmake; do
+ installed_llvm_libdir=${installed_llvm_cmake%/*}
+ LLVM_LIBDIR=${installed_llvm_libdir##*/}
+ installed_llvm=${installed_llvm_libdir%/*}
+ LLVM_SLOT=${installed_llvm##*/}
+
+ test_llvm_config
+done
+
texit
--
2.47.1
next prev parent reply other threads:[~2024-12-21 16:04 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 ` [gentoo-dev] [PATCH 03/11] HACK! llvm-r1 -> llvm-r2 (to ease testing) Michał Górny
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 ` Michał Górny [this message]
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-12-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