summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Zander <negril.nx+gentoo@gmail.com>2024-11-10 18:31:12 +0100
committerSam James <sam@gentoo.org>2024-11-10 17:43:37 +0000
commit8a50bc5c4107f462921239170c3ff535a8f0a83d (patch)
tree0bef5a07f6961f95b3a3685454e1fd4ba825a8ef /dev-util
parentsys-libs/compiler-rt: Provide `atomic-builtins` IUSE flag (diff)
downloadgentoo-8a50bc5c4107f462921239170c3ff535a8f0a83d.tar.gz
gentoo-8a50bc5c4107f462921239170c3ff535a8f0a83d.tar.bz2
gentoo-8a50bc5c4107f462921239170c3ff535a8f0a83d.zip
dev-util/clazy: fix tests
Fiddle with the code to allow testing under gentoo. - Fix logic that incorrectly adds paths that only work with not installed builds. - Use `CMAKE_INSTALL_LIBDIR` from `GNUInstallDirs` to avoid looking up libs with wrong ABI. - Install `clazy-standalone` in to the same directory as the corresponding `clang` binary so it can find headers. - Skip tests if their dependencies are not satifsfied. - Don't test qt5, even if installed, so we can ignore the dependencies. Closes: https://bugs.gentoo.org/811723 Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-util')
-rw-r--r--dev-util/clazy/clazy-1.12.ebuild44
-rw-r--r--dev-util/clazy/files/clazy-1.12-INCLUDE_DIRS.patch42
-rw-r--r--dev-util/clazy/files/clazy-1.12-LIBRARY_DIRS.patch33
-rw-r--r--dev-util/clazy/files/clazy-1.12-standalone-install-location.patch50
4 files changed, 166 insertions, 3 deletions
diff --git a/dev-util/clazy/clazy-1.12.ebuild b/dev-util/clazy/clazy-1.12.ebuild
index b5e819706f76..33919d1d9024 100644
--- a/dev-util/clazy/clazy-1.12.ebuild
+++ b/dev-util/clazy/clazy-1.12.ebuild
@@ -3,7 +3,7 @@
EAPI=8
-LLVM_COMPAT=( 15 16 17 18 )
+LLVM_COMPAT=( {15..18} )
PYTHON_COMPAT=( python3_{10..13} )
inherit cmake llvm-r1 python-any-r1
@@ -30,6 +30,10 @@ PATCHES=(
"${FILESDIR}"/${P}-llvm-18.patch
# Pending: https://invent.kde.org/sdk/clazy/-/merge_requests/131
"${FILESDIR}"/${P}-clang-16-no-src-root.patch
+
+ "${FILESDIR}"/${P}-LIBRARY_DIRS.patch
+ "${FILESDIR}"/${P}-INCLUDE_DIRS.patch
+ "${FILESDIR}"/${P}-standalone-install-location.patch
)
pkg_setup() {
@@ -45,13 +49,47 @@ src_prepare() {
}
src_configure() {
- export LLVM_ROOT="$(get_llvm_prefix -d)"
+ local -x LLVM_ROOT="$(get_llvm_prefix -d)"
+
+ export CI_JOB_NAME_SLUG="qt6"
cmake_src_configure
}
src_test() {
+ # clazy-standalone wants to be installed in the directory of the clang binary,
+ # so it can find the llvm/clang via relative paths.
+ # Requires the standalone-install-location.patch.
+ # Setup the directories and symlink the system include dir for that.
+ local -x LLVM_ROOT="$(get_llvm_prefix -d)"
+ local -x CLANG_ROOT="${LLVM_ROOT//llvm/clang}"
+ mkdir -p "${BUILD_DIR}${CLANG_ROOT}" || die
+
+ ln -s "${CLANG_ROOT}/include" "${BUILD_DIR}${CLANG_ROOT}/include" || die
+
# Run tests against built copy, not installed
# bug #811723
- PATH="${BUILD_DIR}/bin:${PATH}" LD_LIBRARY_PATH="${BUILD_DIR}/lib" cmake_src_test
+ local -x PATH="${BUILD_DIR}/${LLVM_ROOT}/bin:${BUILD_DIR}/bin:${PATH}"
+ local -x LD_LIBRARY_PATH="${BUILD_DIR}/lib"
+
+ # NOTE or DEPEND on "test? ( dev-qt/qtscxml:6[qml] )"
+ local -x CMAKE_SKIP_TESTS=()
+
+ if ! has_version dev-qt/qtscxml:6; then
+ CMAKE_SKIP_TESTS+=(
+ # cannot find -lQt6StateMachine: No such file or directory
+ "old-style-connect"
+ )
+ fi
+
+ if ! has_version dev-qt/qtdeclarative:6; then
+ CMAKE_SKIP_TESTS+=(
+ # lowercase-qml-type-name/main.cpp:3:10: fatal error: 'QtQml/QQmlEngine' file not found
+ "lowercase-qml-type-name"
+ # no-module-include/main.cpp:5:10: fatal error: 'QtQml/QtQml' file not found
+ "no-module-include"
+ )
+ fi
+
+ cmake_src_test
}
diff --git a/dev-util/clazy/files/clazy-1.12-INCLUDE_DIRS.patch b/dev-util/clazy/files/clazy-1.12-INCLUDE_DIRS.patch
new file mode 100644
index 000000000000..23641828804f
--- /dev/null
+++ b/dev-util/clazy/files/clazy-1.12-INCLUDE_DIRS.patch
@@ -0,0 +1,42 @@
+From 6e17217d7b77a27bdf77da2c20044e89f112e9b1 Mon Sep 17 00:00:00 2001
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+Date: Sun, 10 Nov 2024 17:19:56 +0100
+Subject: do not inject include dirs with installed llvm
+
+`string(FIND returns` returns `-1` on failure not `FALSE`.
+If `_llvmSourceRoot` is equal to to first directory in `LLVM_INCLUDE_DIRS`
+this would include non-existant directories.
+
+Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
+
+diff --git a/cmake/FindClang.cmake b/cmake/FindClang.cmake
+index b4f0b0a..eda8bb5 100644
+--- a/cmake/FindClang.cmake
++++ b/cmake/FindClang.cmake
+@@ -95,8 +95,7 @@ if(CLANG_FOUND)
+ OUTPUT_VARIABLE _llvmSourceRoot
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+- string(FIND "${LLVM_INCLUDE_DIRS}" "${_llvmSourceRoot}" _llvmIsInstalled)
+- if (NOT _llvmIsInstalled)
++ if(NOT "${_llvmSourceRoot}" IN_LIST LLVM_INCLUDE_DIRS)
+ message(STATUS "Detected that llvm-config comes from a build-tree, adding more include directories for Clang")
+ list(APPEND CLANG_INCLUDE_DIRS
+ "${LLVM_INSTALL_PREFIX}/tools/clang/include" # build dir
+diff --git a/cmake/FindLLVM.cmake b/cmake/FindLLVM.cmake
+index c625eeb..1e1e902 100644
+--- a/cmake/FindLLVM.cmake
++++ b/cmake/FindLLVM.cmake
+@@ -140,8 +140,7 @@ if (LLVM_FOUND)
+ OUTPUT_VARIABLE _llvmSourceRoot
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+- string(FIND "${LLVM_INCLUDE_DIRS}" "${_llvmSourceRoot}" _llvmIsInstalled)
+- if (NOT _llvmIsInstalled)
++ if(NOT "${_llvmSourceRoot}" IN_LIST LLVM_INCLUDE_DIRS)
+ list(APPEND LLVM_INCLUDE_DIRS "${LLVM_INSTALL_PREFIX}/include")
+ endif()
+ endif()
+--
+2.47.0
+
diff --git a/dev-util/clazy/files/clazy-1.12-LIBRARY_DIRS.patch b/dev-util/clazy/files/clazy-1.12-LIBRARY_DIRS.patch
new file mode 100644
index 000000000000..44d59ce9c3f9
--- /dev/null
+++ b/dev-util/clazy/files/clazy-1.12-LIBRARY_DIRS.patch
@@ -0,0 +1,33 @@
+From d04f0203febdeac38c4b085babb1183747c2edfb Mon Sep 17 00:00:00 2001
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+Date: Sun, 10 Nov 2024 17:19:20 +0100
+Subject: do not inject lib dirs with installed llvm
+
+Including `${LLVM_INSTALL_PREFIX}/lib` in the `LINK_DIRECTORIES` only works,
+when lib is the correct LIBDIR for the current arch.
+Normally you would use `CMAKE_INSTALL_LIBDIR`, unless you know better.
+
+As a bonus we avoid duplicates.
+
+Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4215e49..9f77fb3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -106,7 +106,11 @@ include(ClazySources.cmake)
+
+ include_directories(${CMAKE_BINARY_DIR})
+ include_directories(${CLANG_INCLUDE_DIRS} ${CMAKE_CURRENT_LIST_DIR} ${CMAKE_CURRENT_LIST_DIR}/src)
+-link_directories("${LLVM_INSTALL_PREFIX}/lib" ${LLVM_LIBRARY_DIRS})
++link_directories(${LLVM_LIBRARY_DIRS})
++
++if(NOT "${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" IN_LIST LLVM_LIBRARY_DIRS)
++ link_directories("${LLVM_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
++endif()
+
+ set(clang_tooling_refactoring_lib clangToolingRefactoring)
+
+--
+2.47.0
+
diff --git a/dev-util/clazy/files/clazy-1.12-standalone-install-location.patch b/dev-util/clazy/files/clazy-1.12-standalone-install-location.patch
new file mode 100644
index 000000000000..76ff787a1bea
--- /dev/null
+++ b/dev-util/clazy/files/clazy-1.12-standalone-install-location.patch
@@ -0,0 +1,50 @@
+From 3912afc2e9cec14299e9866014a709a55a07be2e Mon Sep 17 00:00:00 2001
+From: Paul Zander <negril.nx+gentoo@gmail.com>
+Date: Sun, 10 Nov 2024 17:20:42 +0100
+Subject: Install clazy-standalone so relative path look-up works
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+fatal error: ‘stddef.h’ file not found, while using clazy-standalone Be sure the
+clazy-standalone binary is located in the same folder as the
+clang binary.
+
+Signed-off-by: Paul Zander <negril.nx+gentoo@gmail.com>
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9f77fb3..c67065e 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -199,6 +199,12 @@ endmacro()
+
+ set(SYMBOL_FILE Lazy.exports)
+
++execute_process(
++ COMMAND ${LLVM_CONFIG_EXECUTABLE} --bindir
++ OUTPUT_VARIABLE LLVM_BIN_DIR
++ OUTPUT_STRIP_TRAILING_WHITESPACE
++)
++
+ if (NOT CLAZY_BUILD_WITH_CLANG)
+ set(CLAZY_MINI_AST_DUMPER_SRCS src/MiniAstDumper.cpp)
+ add_clang_plugin(ClazyPlugin ${CLAZY_PLUGIN_SRCS} ${CLAZY_MINI_AST_DUMPER_SRCS})
+@@ -315,9 +321,14 @@ else()
+
+ target_link_libraries(clazy-standalone clazyPlugin)
+
+- install(TARGETS clazy-standalone DESTINATION bin PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
++ install(TARGETS clazy-standalone DESTINATION ${LLVM_BIN_DIR} PERMISSIONS OWNER_WRITE OWNER_EXECUTE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
++
+ endif()
+
++set_target_properties(clazy-standalone PROPERTIES
++ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/${LLVM_BIN_DIR}"
++)
++
+ function(to_raw_string_literal input_string output_string)
+ if (MSVC)
+ # Work around "C2026: string too big, trailing characters truncated"
+--
+2.47.0
+