From b0d418a51b9187eb6de93eb7c03416e8f2376e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 3 Jan 2022 21:48:05 +0400 Subject: [PATCH 1/7] cmake: fix warnings variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Do not use strings for compiler flags. Signed-off-by: Marc-André Lureau --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9a5eac1..713e8534 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,12 +257,12 @@ if(MSVC) # see https://msdn.microsoft.com/en-us/library/z78503e6.aspx # 4018 'expression' : signed/unsigned mismatch - set(WARNINGS "4018") + set(WARNINGS 4018) # 4090 'operation' : different 'modifier' qualifiers # 4101 'identifier' : unreferenced local variable # 4127 conditional expression is constant # 4244 'argument' : conversion from 'type1' to 'type2', possible loss of data - set(WARNINGS_DISABLED "4090 4101 4127 4244") + set(WARNINGS_DISABLED 4090 4101 4127 4244) # 4002 too many actual parameters for macro 'identifier' # 4003 not enough actual parameters for macro 'identifier' # 4013 'function' undefined; assuming extern returning int @@ -271,7 +271,7 @@ if(MSVC) # 4047 operator' : 'identifier1' differs in levels of indirection from 'identifier2' # 4114 same type qualifier used more than once # 4133 'type' : incompatible types - from 'type1' to 'type2' - set(WARNINGS_ERRORS "4002 4003 4013 4028 4031 4047 4114 4133") + set(WARNINGS_ERRORS 4002 4003 4013 4028 4031 4047 4114 4133) if(DBUS_MSVC_ANALYZE AND MSVC_VERSION GREATER 1600) string(APPEND CMAKE_C_FLAGS " /analyze") endif() From 2a5f1cfda7351f8c96dc1cab89cc030e1f28a00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Mon, 3 Jan 2022 21:50:19 +0400 Subject: [PATCH 2/7] cmake: add -fno-common when !MSVC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 713e8534..a60428a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -228,10 +228,12 @@ endif() # # setup warnings # -# We're treating -fno-common like a warning: it makes the linker more -# strict, because on some systems the linker is *always* this strict -string(APPEND CMAKE_C_FLAGS " -fno-common") -string(APPEND CMAKE_CXX_FLAGS " -fno-common") +if(NOT MSVC) + # We're treating -fno-common like a warning: it makes the linker more + # strict, because on some systems the linker is *always* this strict + string(APPEND CMAKE_C_FLAGS " -fno-common") + string(APPEND CMAKE_CXX_FLAGS " -fno-common") +endif() option(ENABLE_WERROR "Unconditionally make all compiler warnings fatal" OFF) From a58d46b78957de03119dd54ab1a8346ff850abdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 13 Jan 2022 16:30:54 +0400 Subject: [PATCH 3/7] bus/signal: fix compilation when only -Dembedded-tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- bus/signals.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bus/signals.c b/bus/signals.c index 2af5039b..d7314878 100644 --- a/bus/signals.c +++ b/bus/signals.c @@ -122,7 +122,7 @@ bus_match_rule_unref (BusMatchRule *rule) } } -#if defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) +#if defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) || defined(DBUS_ENABLE_EMBEDDED_TESTS) static dbus_bool_t append_key_and_escaped_value (DBusString *str, const char *token, const char *value) { @@ -312,7 +312,7 @@ match_rule_to_string (BusMatchRule *rule) _dbus_string_free (&str); return NULL; } -#endif /* defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) */ +#endif /* defined(DBUS_ENABLE_VERBOSE_MODE) || defined(DBUS_ENABLE_STATS) || defined(DBUS_ENABLE_EMBEDDED_TESTS) */ dbus_bool_t bus_match_rule_set_message_type (BusMatchRule *rule, From e0deb95b31de0ebf2f09bdd3a0a9289dbb283d6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 4 Jan 2022 15:01:10 +0400 Subject: [PATCH 4/7] gitlab-ci: factorize build jobs with "extends" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is easier to read and modify than anchors. And we are going to move more Debian-specific to the base ".debian-build" next. Signed-off-by: Marc-André Lureau --- .gitlab-ci.yml | 49 +++++++++++++++++-------------------------------- 1 file changed, 17 insertions(+), 32 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1c14a47a..976d9ff4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -47,93 +47,78 @@ variables: ci_distro: "debian" ci_suite: "buster" -production: +.debian-build: stage: build image: "debian:buster-slim" - variables: - ci_variant: "production" - script: &script + script: - chown -R user . - runuser -u user ./tools/ci-build.sh +production: + extends: .debian-build + variables: + ci_variant: "production" + debug: - stage: build - image: "debian:buster-slim" + extends: .debian-build variables: ci_variant: "debug" - script: *script reduced: - stage: build + extends: .debian-build when: manual - image: "debian:buster-slim" variables: ci_variant: "reduced" - script: *script legacy: - stage: build + extends: .debian-build when: manual - image: "debian:buster-slim" variables: ci_variant: "legacy" - script: *script cmake: - stage: build - image: "debian:buster-slim" + extends: .debian-build variables: ci_buildsys: "cmake-dist" - script: *script i686-w64-mingw32-debug: - stage: build - image: "debian:buster-slim" + extends: .debian-build variables: ci_host: "i686-w64-mingw32" ci_variant: "debug" - script: *script i686-w64-mingw32-cmake: - stage: build + extends: .debian-build when: manual - image: "debian:buster-slim" variables: ci_buildsys: "cmake" ci_host: "i686-w64-mingw32" - script: *script x86_64-w64-mingw32: - stage: build - image: "debian:buster-slim" + extends: .debian-build variables: ci_host: "x86_64-w64-mingw32" - script: *script x86_64-w64-mingw32-cmake-debug: - stage: build - image: "debian:buster-slim" + extends: .debian-build variables: ci_buildsys: "cmake" ci_host: "x86_64-w64-mingw32" ci_variant: "debug" - script: *script stretch: + extends: .debian-build when: manual - stage: build image: "debian:stretch-slim" variables: ci_suite: "stretch" - script: *script xenial: + extends: .debian-build when: manual - stage: build image: "ubuntu:xenial" variables: ci_distro: "ubuntu" ci_suite: "xenial" - script: *script # vim:set sw=2 sts=2 et: From f8067a07c372989acb260926706cb793aedfd276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 4 Jan 2022 15:07:04 +0400 Subject: [PATCH 5/7] gitlab-ci: move "before_script" and "cache" to .debian-build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As we are introducing Windows builds next, move out Unix-specific job definitions to the base job. Signed-off-by: Marc-André Lureau --- .gitlab-ci.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 976d9ff4..bdd3e2e8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,20 +25,6 @@ image: debian:buster-slim stages: - build -before_script: - - ./tools/ci-install.sh - - mkdir -p .ccache - - export CCACHE_BASEDIR="$(pwd)" - - export CCACHE_DIR="$CCACHE_BASEDIR/.ccache" - # Debian's ccache package creates symlinks here for all supported - # compilers - - export PATH="/usr/lib/ccache:$PATH" - -cache: - key: ${CI_JOB_NAME} - paths: - - .ccache/ - variables: ci_in_docker: "yes" ci_local_packages: "yes" @@ -50,6 +36,18 @@ variables: .debian-build: stage: build image: "debian:buster-slim" + cache: + key: ${CI_JOB_NAME} + paths: + - .ccache/ + before_script: + - ./tools/ci-install.sh + - mkdir -p .ccache + - export CCACHE_BASEDIR="$(pwd)" + - export CCACHE_DIR="$CCACHE_BASEDIR/.ccache" + # Debian's ccache package creates symlinks here for all supported + # compilers + - export PATH="/usr/lib/ccache:$PATH" script: - chown -R user . - runuser -u user ./tools/ci-build.sh From 98c903656d5755ba27eeb3f41640e92f232c77ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 4 Jan 2022 15:14:51 +0400 Subject: [PATCH 6/7] gitlab-ci: build a Windows docker image, with VS15 & msys MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Based on GStreamer & Mesa freedesktop gitlab CI, use the Windows 1809 runner provided by the GStreamer Foundation. https://www.freedesktop.org/wiki/Infrastructure/ Signed-off-by: Marc-André Lureau --- .gitlab-ci.yml | 37 +++++++++++++++++ tools/docker/windows/Dockerfile | 65 ++++++++++++++++++++++++++++++ tools/docker/windows/Install.cmd | 18 +++++++++ tools/docker/windows/container.ps1 | 60 +++++++++++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 tools/docker/windows/Dockerfile create mode 100644 tools/docker/windows/Install.cmd create mode 100644 tools/docker/windows/container.ps1 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bdd3e2e8..5b183890 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,7 @@ image: debian:buster-slim stages: + - 'build docker' - build variables: @@ -32,6 +33,42 @@ variables: ci_sudo: "yes" ci_distro: "debian" ci_suite: "buster" + ### + # IMPORTANT + # These are the version tags for the docker images the CI runs against. + # If you are hacking on them or need a them to rebuild, its enough + # to change any part of the string of the image you want. + ### + WINDOWS_TAG: "2022-01-07.1" + + UPSTREAM_BRANCH: 'master' + UPSTREAM_REPO: 'dbus/dbus' + WINDOWS_AMD64_SUFFIX: 'amd64/windows' + WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$UPSTREAM_BRANCH" + WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$UPSTREAM_REPO/$WINDOWS_AMD64_SUFFIX:$WINDOWS_TAG-$UPSTREAM_BRANCH" + + +windows amd64 docker: + stage: "build docker" + variables: + # this file needs to be relative to docker/windows/ subdir + # as it makes life easier in the powershell script + DOCKERFILE: "tools/docker/windows/Dockerfile" + timeout: 2h 30m + tags: + - windows + - shell + - "1809" + script: + # We need to pass an array and to resolve the env vars, so we can't use a variable: + - $DOCKER_BUILD_ARGS = @("--build-arg", "DEFAULT_BRANCH=$UPSTREAM_BRANCH") + + - "& tools/docker/windows/container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE $DOCKERFILE" + - | + if (!($?)) { + echo "Failed to build the image" + Exit 1 + } .debian-build: stage: build diff --git a/tools/docker/windows/Dockerfile b/tools/docker/windows/Dockerfile new file mode 100644 index 00000000..c9a91200 --- /dev/null +++ b/tools/docker/windows/Dockerfile @@ -0,0 +1,65 @@ +# escape=` + +FROM 'mcr.microsoft.com/windows/servercore:ltsc2019' + +# Make sure any failure in PowerShell scripts is fatal +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"] +ENV ErrorActionPreference='Stop' + +# Install Chocolatey +RUN iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) +# Install required packages +RUN choco install -y vcredist140 +RUN choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' +RUN choco install -y git --params '/NoAutoCrlf /NoCredentialManager /NoShellHereIntegration /NoGuiHereIntegration /NoShellIntegration' +RUN choco install -y windows-sdk-8.1 +RUN choco install -y python3 +RUN choco install -y msys2 --params '/NoPath /NoUpdate /InstallDir:C:\\msys64' + +RUN 'git config --global user.email "cirunner@dbus.freedesktop.org"; git config --global user.name "D-Bus CI system"' + +RUN pip3 install meson +# FIXME: Python fails to validate SSL certificates, for unclear reasons +# try various ways to update the store, certifi-win32 seems to work as long as we fetch before +# See also: https://bugs.python.org/issue36011 +RUN pip3 install --upgrade certifi +RUN pip3 install python-certifi-win32 +RUN (New-Object System.Net.WebClient).DownloadString('https://sourceforge.net') >$null +RUN (New-Object System.Net.WebClient).DownloadString('https://wrapdb.mesonbuild.com/v2/pcre_8.37-2/get_patch') >$null +RUN (New-Object System.Net.WebClient).DownloadString('https://zlib.net/fossils/') >$null + +# MinGW environment +RUN c:\msys64\usr\bin\bash -lc 'pacman -S --noconfirm mingw-w64-ucrt-x86_64-toolchain expat glib2-devel' + +# Visual Studio can't be installed with choco. +# It depends on dotnetfx v4.8.0.20190930, which requires a reboot: dotnetfx (exit code 3010) +# https://github.com/microsoft/vs-dockerfiles/blob/main/native-desktop/ +# Set up environment to collect install errors. +COPY Install.cmd C:\TEMP\ +ADD https://aka.ms/vscollect.exe C:\TEMP\collect.exe +# Download channel for fixed install. +ARG CHANNEL_URL=https://aka.ms/vs/15/release/channel +ADD ${CHANNEL_URL} C:\TEMP\VisualStudio.chman +# Download and install Build Tools for Visual Studio 2017 for native desktop workload. +ADD https://aka.ms/vs/15/release/vs_buildtools.exe C:\TEMP\vs_buildtools.exe +RUN C:\TEMP\Install.cmd C:\TEMP\vs_buildtools.exe --quiet --wait --norestart --nocache ` + --channelUri C:\TEMP\VisualStudio.chman ` + --installChannelUri C:\TEMP\VisualStudio.chman ` + --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended` + --installPath C:\BuildTools + +# Upstream expat doesn't ship devel? let's build it then... +# ADD https://github.com/libexpat/libexpat/releases/download/R_2_4_1/expat-win32bin-2.4.1.exe C:\TEMP\expat.exe +# RUN C:\TEMP\expat.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART /SP- +RUN git clone --depth 1 --branch R_2_4_2 https://github.com/libexpat/libexpat +WORKDIR "/libexpat/expat" +RUN cmake --install-prefix c:/ -G '"Visual Studio 15 2017 Win64"' . +RUN cmake --build . --config Release +RUN cmake --install . --config Release + +# Build glib for MSVC +RUN git clone --depth 1 --branch 2.70.2 https://gitlab.gnome.org/GNOME/glib.git \glib +WORKDIR "/glib" +RUN cmd /c 'C:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 & meson setup builddir' +RUN meson compile -C builddir +RUN meson install --no-rebuild -C builddir diff --git a/tools/docker/windows/Install.cmd b/tools/docker/windows/Install.cmd new file mode 100644 index 00000000..7fa1c0cd --- /dev/null +++ b/tools/docker/windows/Install.cmd @@ -0,0 +1,18 @@ +@rem Copyright (C) Microsoft Corporation. All rights reserved. +@rem https://github.com/MicrosoftDocs/visualstudio-docs/blob/main/docs/install/advanced-build-tools-container.md#install-script +@rem Licensed under the MIT license. + +@if not defined _echo echo off +setlocal enabledelayedexpansion + +call %* +if "%ERRORLEVEL%"=="3010" ( + exit /b 0 +) else ( + if not "%ERRORLEVEL%"=="0" ( + set ERR=%ERRORLEVEL% + call C:\TEMP\collect.exe -zip:C:\vslogs.zip + + exit /b !ERR! + ) +) diff --git a/tools/docker/windows/container.ps1 b/tools/docker/windows/container.ps1 new file mode 100644 index 00000000..1386495c --- /dev/null +++ b/tools/docker/windows/container.ps1 @@ -0,0 +1,60 @@ +# Copied from mesa, big kudos +# +# https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/.gitlab-ci/windows/mesa_container.ps1 +# https://gitlab.freedesktop.org/mesa/mesa/-/blob/34e3e164936d1d3cef267da7780e87f062fedf39/.gitlab-ci/windows/mesa_container.ps1 + +# Implements the equivalent of ci-templates container-ifnot-exists, using +# Docker directly as we don't have buildah/podman/skopeo available under +# Windows, nor can we execute Docker-in-Docker +$registry_uri = $args[0] +$registry_username = $args[1] +$registry_password = $args[2] +$registry_user_image = $args[3] +$registry_central_image = $args[4] +$dockerfile = $args[5] + +docker --config "windows-docker.conf" login -u "$registry_username" -p "$registry_password" "$registry_uri" +if (!$?) { + Write-Host "docker login failed to $registry_uri" + Exit 1 +} + +# if the image already exists, don't rebuild it +docker --config "windows-docker.conf" pull "$registry_user_image" +if ($?) { + Write-Host "User image $registry_user_image already exists; not rebuilding" + docker --config "windows-docker.conf" logout "$registry_uri" + Exit 0 +} + +# if the image already exists upstream, copy it +docker --config "windows-docker.conf" pull "$registry_central_image" +if ($?) { + Write-Host "Copying central image $registry_central_image to user image $registry_user_image" + docker --config "windows-docker.conf" tag "$registry_central_image" "$registry_user_image" + docker --config "windows-docker.conf" push "$registry_user_image" + $pushstatus = $? + docker --config "windows-docker.conf" logout "$registry_uri" + if (!$pushstatus) { + Write-Host "Pushing image to $registry_user_image failed" + Exit 1 + } + Exit 0 +} + +Write-Host "No image found at $registry_user_image or $registry_central_image; rebuilding" +docker --config "windows-docker.conf" build $DOCKER_BUILD_ARGS --no-cache -t "$registry_user_image" -f "$dockerfile" "./ci/docker/windows" +if (!$?) { + Write-Host "Container build failed" + docker --config "windows-docker.conf" logout "$registry_uri" + Exit 1 +} +Get-Date + +docker --config "windows-docker.conf" push "$registry_user_image" +$pushstatus = $? +docker --config "windows-docker.conf" logout "$registry_uri" +if (!$pushstatus) { + Write-Host "Pushing image to $registry_user_image failed" + Exit 1 +} From 84e60c55e470a06fb39eeb433763400ddf393c3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 4 Jan 2022 15:16:02 +0400 Subject: [PATCH 7/7] gitlab-ci: add cmake Windows builds with VS and mingw-ucrt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- .gitlab-ci.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5b183890..d70b94af 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -156,4 +156,39 @@ xenial: ci_distro: "ubuntu" ci_suite: "xenial" +.win-build: + image: $WINDOWS_IMAGE + stage: build + tags: + - 'docker' + - 'windows' + - '1809' + needs: + - "windows amd64 docker" + timeout: '2h' + before_script: + - $ErrorActionPreference = "Stop" + - $WarningPreference = "Stop" + - $env:DBUS_TEST_MALLOC_FAILURES = 0 + - $env:PATH += ";C:\bin" + +windows-cmake-mingw-ucrt64: + extends: .win-build + script: + - $env:MSYSTEM = "UCRT64" + - $env:CHERE_INVOKING = "1" + - $env:MSYS2_PATH_TYPE = "inherit" + - $env:PATH += ";C:\msys64\usr\bin" + # FIXME: glib from msys2 has issues, disable it for now + - C:\msys64\usr\bin\bash -lc 'cmake -G \"MinGW Makefiles\" -S . -B build -DDBUS_WITH_GLIB=OFF && cmake --build build --config Release' + +windows-cmake-vs15: + extends: .win-build + script: + - cmake -DCMAKE_PREFIX_PATH=C:/ -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DDBUS_ENABLE_VERBOSE_MODE=OFF -S . -B build + - cmake --build build --config Debug + - cmake --install build --config Debug + # FIXME: a few tests timeout on gitlab runner for unknown reason + - cd build ; ctest -C Debug -VV --timeout 1200 -E '(dbus-daemon|monitor)' + # vim:set sw=2 sts=2 et: