mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-06-07 23:28:23 +02:00
Merge branch 'win-ci' into 'master'
CI: add Windows native builds See merge request dbus/dbus!218
This commit is contained in:
commit
7f5469d7dc
6 changed files with 255 additions and 55 deletions
147
.gitlab-ci.yml
147
.gitlab-ci.yml
|
|
@ -23,22 +23,9 @@
|
|||
image: debian:buster-slim
|
||||
|
||||
stages:
|
||||
- 'build docker'
|
||||
- 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"
|
||||
|
|
@ -46,94 +33,162 @@ 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"
|
||||
|
||||
production:
|
||||
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
|
||||
image: "debian:buster-slim"
|
||||
variables:
|
||||
ci_variant: "production"
|
||||
script: &script
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
.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:
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
@ -257,12 +259,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 +273,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()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
65
tools/docker/windows/Dockerfile
Normal file
65
tools/docker/windows/Dockerfile
Normal file
|
|
@ -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
|
||||
18
tools/docker/windows/Install.cmd
Normal file
18
tools/docker/windows/Install.cmd
Normal file
|
|
@ -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!
|
||||
)
|
||||
)
|
||||
60
tools/docker/windows/container.ps1
Normal file
60
tools/docker/windows/container.ps1
Normal file
|
|
@ -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
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue