diff options
author | 2024-12-20 21:55:50 +0100 | |
---|---|---|
committer | 2024-12-30 12:32:34 +0100 | |
commit | 732340d13de61dd50e53c6f6b01b0303265c2e2c (patch) | |
tree | 09763d875b8fa3a6148afdaae444c8352d3e7be9 /eclass | |
parent | eclass/tests: Copy llvm-r1 tests to llvm-r2.sh (diff) | |
download | gentoo-732340d13de61dd50e53c6f6b01b0303265c2e2c.tar.gz gentoo-732340d13de61dd50e53c6f6b01b0303265c2e2c.tar.bz2 gentoo-732340d13de61dd50e53c6f6b01b0303265c2e2c.zip |
eclass/tests/llvm-r2.sh: Add tests for llvm-config
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rwxr-xr-x | eclass/tests/llvm-r2.sh | 87 |
1 files changed, 87 insertions, 0 deletions
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 |