From 3f3102d7fef814e9c49abb8c529e4fdf53684d85 Mon Sep 17 00:00:00 2001 From: Tal Regev <tal.regev@gmail.com> Date: Wed, 19 Feb 2025 11:51:19 +0200 Subject: [PATCH] Add vcpkg to meson ci --- extras/ci/gitlab-ci.yml | 90 +++++++++++++++++++++++++++++++++++++++++ meson-vcpkg.txt | 25 ++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 meson-vcpkg.txt diff --git a/extras/ci/gitlab-ci.yml b/extras/ci/gitlab-ci.yml index 16e825f49a1f..70508cc6e8a5 100644 --- a/extras/ci/gitlab-ci.yml +++ b/extras/ci/gitlab-ci.yml @@ -410,6 +410,96 @@ debian-meson: - html-coverage/ - ${CI_PROJECT_DIR}/build-meson/meson-logs/testlog.junit.xml +nightly-debian-meson-vcpkg: + rules: + - if: '$CI_PIPELINE_SOURCE == "schedule"' + extends: .base-template + coverage: '/^coverage result: (\d+.\d+)$/' + image: + name: $VLC_DEBIAN_IMAGE + script: + - | + export NCPU=$(getconf _NPROCESSORS_ONLN) + echo "Building branch '${CI_COMMIT_BRANCH}' (default: '${CI_DEFAULT_BRANCH}')" + - | + echo -e "\e[0Ksection_start:$(date +%s):build_tools_section\r\e[0KTools build" + # Build tools + ( cd extras/tools && ./bootstrap && make -j$NCPU --output-sync=recurse ) + export PATH="$(pwd)/extras/tools/build/bin:$PATH" + echo -e "\e[0Ksection_end:$(date +%s):build_tools_section\r\e[0K" + - | + echo -e "\e[0Ksection_start:$(date +%s):vcpkg_setup_section\r\e[0Kvcpkg setup" + # clone unzip + ( git clone https://git.launchpad.net/ubuntu/+source/unzip -b debian/bookworm ) + # compile unzip + ( cd unzip && make -f unix/Makefile linux_noasm && cd .. ) + # Add unzip to path + export PATH="${PWD}/unzip:${PATH}" + # do not cache vcpkg + export VCPKG_FEATURE_FLAGS=-binarycaching + # clone vcpkg + ( git clone https://github.com/microsoft/vcpkg ) + # bootstrap vcpkg + ( vcpkg/bootstrap-vcpkg.sh -disableMetrics ) + # install packges + ( vcpkg/vcpkg x-set-installed pkgconf libpng x265 ) + echo -e "\e[0Ksection_end:$(date +%s):vcpkg_setup_section\r\e[0K" + - | + echo -e "\e[0Ksection_start:$(date +%s):setup_meson_section\r\e[0KMeson setup" + # Setup meson build dir + meson setup build-meson \ + --native-file meson-vcpkg.txt \ + -Db_coverage=true \ + -Dextra_checks=true \ + || (echo "ERROR: Meson setup failed!" >&2 ; cat build-meson/meson-logs/meson-log.txt >&2 ; exit 1) + echo -e "\e[0Ksection_end:$(date +%s):setup_meson_section\r\e[0K" + - | + echo -e "\e[0Ksection_start:$(date +%s):build_meson_section\r\e[0KVLC build" + # Build VLC + ninja -C build-meson || (echo "ERROR: Build failed!" >&2 ; exit 2) + echo -e "\e[0Ksection_end:$(date +%s):build_meson_section\r\e[0K" + - | + echo -e "\e[0Ksection_start:$(date +%s):tests_meson_section\r\e[0KVLC tests" + # Run tests + meson test -C build-meson || (echo "ERROR: Tests failed!" >&2 ; cat build-meson/meson-logs/testlog.txt >&2 ; exit 3) + echo -e "\e[0Ksection_end:$(date +%s):tests_meson_section\r\e[0K" + - | + # We split in two different commands to handle the case where + # the coverage will be generated on different jobs later. + # Note: qt generated files need to be remove from the report since their + # coverage should not be checked. It leads to gcovr having trouble + # parsing the coverage otherwise. + gcovr -r "${CI_PROJECT_DIR}/" --json "${CI_PROJECT_DIR}/${CI_JOB_NAME}.cov.json" -j$NCPU --gcov-ignore-parse-errors=negative_hits.warn_once_per_file --exclude "build-meson/modules/gui/qt/.*_qrc.cpp" --exclude "build-meson/modules/gui/qt/.*_assets.cpp" + + - mkdir html-coverage + - > + gcovr --add-tracefile "${CI_PROJECT_DIR}/${CI_JOB_NAME}.cov.json" + --xml="cobertura.xml" + --html="html-coverage/vlc.html" + --html-details -s -j$NCPU + - | + # Ensure that sources are reported from CI_PROJECT_DIR directory so + # that gitlab can associate the files correctly. + sed -i 's,<source>.*</source>,<source>'"${CI_PROJECT_DIR}"'</source>,' cobertura.xml + # Expose the line coverage percentage to gitlab from the cobertura XML. + - > + grep -Eo 'line-rate="[^"]+"' cobertura.xml | head -n 1 | + grep -Eo '[0-9.]+' | awk '{ print "coverage result:", $1 * 100 } ' || + true + allow_failure: true + variables: *variables-debian + artifacts: + reports: + junit: build-meson/meson-logs/testlog.junit.xml + coverage_report: + coverage_format: cobertura + path: cobertura.xml + paths: + - ${CI_PROJECT_DIR}/${CI_JOB_NAME}.cov.json + - cobertura.xml + - html-coverage/ + - ${CI_PROJECT_DIR}/build-meson/meson-logs/testlog.junit.xml + # # Snap builds # diff --git a/meson-vcpkg.txt b/meson-vcpkg.txt new file mode 100644 index 000000000000..87f023939303 --- /dev/null +++ b/meson-vcpkg.txt @@ -0,0 +1,25 @@ +[constants] +vcpkg_base_path = '@GLOBAL_SOURCE_ROOT@/vcpkg/' +vcpkg_base_install_dir = vcpkg_base_path + 'installed/' +vcpkg_target_triplet = 'x64-linux' +vcpkg_host_triplet = 'x64-linux' +vcpkg_installed_dir = vcpkg_base_install_dir + vcpkg_target_triplet + '/' +vcpkg_host_installed_dir = vcpkg_base_install_dir + vcpkg_host_triplet + '/' +vcpkg_toolchain_file = vcpkg_base_path + 'scripts/toolchains/linux.cmake' +vcpkg_cmake_toolchain_file = vcpkg_base_path + 'scripts/buildsystems/vcpkg.cmake' + +[binaries] +vcpkg = [ vcpkg_base_path + 'vcpkg'] +pkg-config = [ vcpkg_installed_dir + 'tools/pkgconf/pkgconf'] + +[cmake] +VCPKG_TARGET_TRIPLET = vcpkg_target_triplet +VCPKG_HOST_TRIPLET = vcpkg_host_triplet +VCPKG_INSTALLED_DIR = vcpkg_installed_dir + +[properties] +cmake_toolchain_file = vcpkg_cmake_toolchain_file + +[paths] +cmake_prefix_path = [ vcpkg_installed_dir ] +pkg_config_path = [ vcpkg_installed_dir + '/lib/pkgconfig', vcpkg_installed_dir + '/share/pkgconfig' ] -- GitLab