diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-01-04 15:14:51 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2022-01-21 21:16:45 +0400 |
commit | 98c903656d5755ba27eeb3f41640e92f232c77ae (patch) | |
tree | 858484e4c9e36f627d35efb6d789620017a7fa56 /tools | |
parent | f8067a07c372989acb260926706cb793aedfd276 (diff) | |
download | dbus-98c903656d5755ba27eeb3f41640e92f232c77ae.tar.gz |
gitlab-ci: build a Windows docker image, with VS15 & msys
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 <marcandre.lureau@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/docker/windows/Dockerfile | 65 | ||||
-rw-r--r-- | tools/docker/windows/Install.cmd | 18 | ||||
-rw-r--r-- | tools/docker/windows/container.ps1 | 60 |
3 files changed, 143 insertions, 0 deletions
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 +} |