diff --git a/package/archlinux/PKGBUILD-coverage b/package/archlinux/PKGBUILD-coverage index dded1d332..707f64de9 100644 --- a/package/archlinux/PKGBUILD-coverage +++ b/package/archlinux/PKGBUILD-coverage @@ -100,7 +100,8 @@ check() { rm -rf coverage mkdir coverage - # Keep in sync with package/ci/appveyor-lcov.sh and circleci.yml, please + # Keep in sync with package/ci/appveyor-desktop{,-mingw}.bat and + # circleci.yml, please # TODO figure out a way to avoid adding --ignore-errors mismatch lcov --ignore-errors mismatch --directory . --capture --output-file coverage.info lcov --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null diff --git a/package/ci/appveyor-desktop-mingw.bat b/package/ci/appveyor-desktop-mingw.bat index 89260c348..ffd7c1321 100644 --- a/package/ci/appveyor-desktop-mingw.bat +++ b/package/ci/appveyor-desktop-mingw.bat @@ -72,13 +72,14 @@ rem Test install, after running the tests as for them it shouldn't be needed cmake --build . --target install || exit /b rem Coverage upload -set PATH=C:\msys64\usr\bin;%PATH% -bash %APPVEYOR_BUILD_FOLDER%\package\ci\appveyor-lcov.sh || exit /b -rem The damn new codecov binary is apparently unable to work with -rem subdirectories on Windows. Nobody cares. -rem https://github.com/codecov/codecov-action/issues/862 cd %APPVEYOR_BUILD_FOLDER% -move build\coverage.info coverage.info || exit /b +set GCOV=C:/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov.exe +rem Keep in sync with circleci.yml, appveyor-desktop.bat and PKBUILD-coverage, +rem please. The --source-dir needs to be present in order to circumvent +rem Warning: "../foo" cannot be normalized because of "..", so skip it. +rem that happens with CMake before 3.21 that doesn't yet pass full paths to +rem Ninja: https://github.com/mozilla/grcov/issues/1182 +grcov build -t lcov --source-dir %APPVEYOR_BUILD_FOLDER%/build --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" -o coverage.info --excl-line LCOV_EXCL_LINE --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b rem Official docs say "not needed for public repos", in reality not using the rem token is "extremely flakey". What's best is that if the upload fails, the rem damn thing exits with a success error code, and nobody cares: diff --git a/package/ci/appveyor-desktop.bat b/package/ci/appveyor-desktop.bat index 56d62f670..1b0733d62 100644 --- a/package/ci/appveyor-desktop.bat +++ b/package/ci/appveyor-desktop.bat @@ -6,11 +6,14 @@ set PATH=%APPVEYOR_BUILD_FOLDER%\deps\bin;%PATH% rem OpenAL DLL is renamed & copied to magnum's bin dir automatically by the rem buildsystem, no need to do that here anymore -rem need to explicitly specify a 64-bit target, otherwise CMake+Ninja can't -rem figure that out -- https://gitlab.kitware.com/cmake/cmake/issues/16259 -rem for TestSuite we need to enable exceptions explicitly with /EH as these are -rem currently disabled -- https://github.com/catchorg/Catch2/issues/1113 -if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" set COMPILER_EXTRA=-DCMAKE_CXX_COMPILER="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/clang-cl.exe" -DCMAKE_LINKER="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/lld-link.exe" -DCMAKE_CXX_FLAGS="-m64 /EHsc" +rem - Need to explicitly specify a 64-bit target, otherwise CMake+Ninja can't +rem figure that out -- https://gitlab.kitware.com/cmake/cmake/issues/16259 +rem - For TestSuite we need to enable exceptions explicitly with /EH as these +rem are currently disabled -- https://github.com/catchorg/Catch2/issues/1113 +rem - The MSVC 2022 build has coverage enabled, for which the profile library +rem has to be explicitly linked -- https://bugs.llvm.org/show_bug.cgi?id=40877, +rem https://gitlab.kitware.com/cmake/cmake/-/issues/23437 +if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" set COMPILER_EXTRA=-DCMAKE_CXX_COMPILER="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/clang-cl.exe" -DCMAKE_LINKER="C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/bin/lld-link.exe" -DCMAKE_CXX_FLAGS="-m64 /EHsc --coverage" -DCMAKE_EXE_LINKER_FLAGS="-libpath:\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/lib/clang/18/lib/windows\" \"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/lib/clang/18/lib/windows/clang_rt.profile-x86_64.lib\"" -DCMAKE_SHARED_LINKER_FLAGS="-libpath:\"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/lib/clang/18/lib/windows\" \"C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/Llvm/x64/lib/clang/18/lib/windows/clang_rt.profile-x86_64.lib\"" if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2019" set COMPILER_EXTRA=-DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/clang-cl.exe" -DCMAKE_LINKER="C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/Llvm/bin/lld-link.exe" -DCMAKE_CXX_FLAGS="-m64 /EHsc" rem Build Corrade @@ -81,3 +84,15 @@ ctest -V -E "GLTest|GLBenchmark|VkTest" --timeout 60 || exit /b rem Test install, after running the tests as for them it shouldn't be needed cmake --build . --target install || exit /b + +cd %APPVEYOR_BUILD_FOLDER% + +rem Gather and upload coverage on the clang-cl MSVC 2022 build. Keep in sync +rem with circleci.yml, appveyor-desktop-mingw.bat and PKBUILD-coverage, please. +if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" grcov build -t lcov --keep-only "*/src/Magnum*/*" --ignore "*/src/MagnumExternal/*" --ignore "*/Test/*" --ignore "*/build/src/*" -o coverage.info --excl-line LCOV_EXCL_LINE --excl-start LCOV_EXCL_START --excl-stop LCOV_EXCL_STOP || exit /b +rem Official docs say "not needed for public repos", in reality not using the +rem token is "extremely flakey". What's best is that if the upload fails, the +rem damn thing exits with a success error code, and nobody cares: +rem https://github.com/codecov/codecov-circleci-orb/issues/139 +rem https://community.codecov.com/t/commit-sha-does-not-match-circle-build/4266 +if "%COMPILER%" == "msvc-clang" if "%APPVEYOR_BUILD_WORKER_IMAGE%" == "Visual Studio 2022" codecov -f ./coverage.info -t 3b1a7cc0-8bfb-4cde-8d99-dc04572a43c3 -X gcov || exit /b diff --git a/package/ci/appveyor-lcov.sh b/package/ci/appveyor-lcov.sh deleted file mode 100644 index 9e5f681c5..000000000 --- a/package/ci/appveyor-lcov.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash -set -ev - -# This thing used to use MSYS's pacman to fetch lcov. However: -# -# - the lcov 1.13 package there was empty for some reason, so we had to -# download the source on our own (https://github.com/appveyor/ci/issues/1628) -# - at some point, MSYS repos got new packagers and we had to update the -# keyring by hand (https://www.msys2.org/news/#2020-06-29-new-packagers) -# - then, zstd-compressed packages happened, however the used version of pacman -# didn't understand zstd yet, so for perl, which lcov depends on, we had to -# manually download an archive that was still compressed with XZ (instead of -# going the more complicated way of updating pacman itself first, in every CI -# run) -# - and THEN, since 2021-11-20, the perl XZ packages were removed, causing a -# 404, but a rather weird one, since curl just downloaded the 404 page but -# didn't treat that as an error -# -# Then I made a step back and laughed at the needless suffering, because -# AppVeyor ships Perl on its own and since we fetch our own lcov anyway, the -# MSYS insanity is not needed for ANYTHING AT ALL, in fact. - -# Important: 1.13 is the only version that actually works. 1.15 doesn't, tries -# to find the original source files in build/.../CMakeFiles/src/Magnum and -# results in a zero-byte coverage being happily uploaded, with no error message -# produced whatsoever. How nice. -wget https://github.com/linux-test-project/lcov/archive/v1.13.tar.gz -tar -xzf v1.13.tar.gz - -# Keep in sync with PKBUILD-coverage and circleci.yml, please -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --directory . --capture --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/src/MagnumExternal/*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/Test/*" --output-file coverage.info > /dev/null -lcov-1.13/bin/lcov --gcov-tool /c/mingw-w64/x86_64-7.2.0-posix-seh-rt_v5-rev1/mingw64/bin/gcov --remove coverage.info "*/build/src/*" --output-file coverage.info > /dev/null diff --git a/package/ci/appveyor.yml b/package/ci/appveyor.yml index f3c2533c0..ac073891e 100644 --- a/package/ci/appveyor.yml +++ b/package/ci/appveyor.yml @@ -123,8 +123,9 @@ install: - 7z x ninja-win.zip -oC:/tools - set PATH=C:/tools;%PATH% -# Codecov uploader -- IF "%TARGET%" == "desktop" IF "%COMPILER%" == "mingw" appveyor DownloadFile https://uploader.codecov.io/latest/windows/codecov.exe -FileName C:/tools/codecov.exe +# Codecov uploader and grcov. Used for MinGW and clang-cl. +- IF "%TARGET%" == "desktop" IF NOT "%COMPILER%" == "msvc" appveyor DownloadFile https://github.com/mozilla/grcov/releases/download/v0.8.20/grcov-x86_64-pc-windows-msvc.zip && 7z x grcov-x86_64-pc-windows-msvc.zip -oC:/tools +- IF "%TARGET%" == "desktop" IF NOT "%COMPILER%" == "msvc" appveyor DownloadFile https://uploader.codecov.io/latest/windows/codecov.exe -FileName C:/tools/codecov.exe - IF "%TARGET_GLES2%" == "ON" set TARGET_GLES3=OFF - IF "%TARGET_GLES2%" == "OFF" set TARGET_GLES3=ON diff --git a/package/ci/circleci.yml b/package/ci/circleci.yml index d3b8d83eb..58c735e15 100644 --- a/package/ci/circleci.yml +++ b/package/ci/circleci.yml @@ -290,7 +290,8 @@ commands: steps: - run: name: Collect code coverage - # Keep in sync with PKBUILD-coverage and appveyor-lcov.sh, please + # Keep in sync with PKBUILD-coverage and appveyor-desktop-{,mingw}.bat, + # please command: | lcov $LCOV_EXTRA_OPTS --directory . --capture --output-file coverage.info > /dev/null lcov $LCOV_EXTRA_OPTS --extract coverage.info "*/src/Magnum*/*" --output-file coverage.info > /dev/null