ci: prepare the Windows image for MSYS2 cerbero builds

* Install MSYS2 and VS with choco
 * Install Windows SDK 8.1 requied for libvpx
 * Improve build time of the windows image using as much RUN layers as
   possible

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1000>
This commit is contained in:
Andoni Morales Alastruey 2021-10-01 17:20:30 +02:00 committed by GStreamer Marge Bot
parent ee1255079b
commit a1e332bf7e
6 changed files with 80 additions and 101 deletions

View file

@ -25,7 +25,7 @@ variables:
###
FEDORA_TAG: '2021-10-05.0'
INDENT_TAG: '2021-10-04.0'
WINDOWS_TAG: "2021-10-04.1"
WINDOWS_TAG: "2021-10-12.0"
GST_UPSTREAM_REPO: 'gstreamer/gstreamer'
FDO_UPSTREAM_REPO: 'gstreamer/gstreamer'

View file

@ -6,13 +6,41 @@ FROM 'mcr.microsoft.com/windows/servercore:ltsc2019'
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
ENV ErrorActionPreference='Stop'
COPY install_choco.ps1 C:\
RUN C:\install_choco.ps1
# 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 git-lfs
RUN choco install -y 7zip
RUN choco install -y windows-sdk-8.1
RUN choco install -y python3
RUN choco install -y msys2 --params '/NoPath /NoUpdate /InstallDir:C:\\msys64'
# 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
RUN pip3 install meson
RUN 'git config --global user.email "cirunner@gstreamer.freedesktop.org"; git config --global user.name "GStreamer CI system"'
COPY install_toolchain.ps1 C:\
RUN C:\install_toolchain.ps1
COPY install_mingw.ps1 C:\
RUN C:\install_mingw.ps1
ARG DEFAULT_BRANCH="main"
@ -20,4 +48,4 @@ COPY prepare_gst_env.ps1 C:\
RUN C:\prepare_gst_env.ps1
COPY prepare_cerbero_env.sh C:\
RUN C:\MinGW\msys\1.0\bin\bash.exe --login -c "C:/prepare_cerbero_env.sh"
RUN C:\MinGW\msys\1.0\bin\bash.exe --login -c "C:/prepare_cerbero_env.sh"

View file

@ -0,0 +1,17 @@
@rem Copyright (C) Microsoft Corporation. All rights reserved.
@rem Licensed under the MIT license. See LICENSE.txt in the project root for license information.
@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!
)
)

View file

@ -1,26 +0,0 @@
Get-Date
Write-Host "Installing Chocolatey"
Set-ExecutionPolicy Bypass -Scope Process -Force;
# Force TLS 1.2
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Import-Module "$env:ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
Update-SessionEnvironment
choco install -y vcredist140
$vc140_install = $?
Write-Host "Installing Chocolatey packages"
choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System'
$cmake_install = $?
choco install -y git --params "/NoAutoCrlf /NoCredentialManager /NoShellHereIntegration /NoGuiHereIntegration /NoShellIntegration"
$git_install = $?
choco install -y python3 git-lfs 7zip
$rest_installs = $?
if (!($vc140_install -and $cmake_install -and $git_install -and $rest_installs)) {
Write-Host "Failed to install some dependencies from choco"
Exit 1
}

View file

@ -0,0 +1,29 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$msys_mingw_get_url = 'https://dotsrc.dl.osdn.net/osdn/mingw/68260/mingw-get-0.6.3-mingw32-pre-20170905-1-bin.tar.xz'
Get-Date
Write-Host "Downloading and extracting mingw-get for MSYS"
Invoke-WebRequest -Uri $msys_mingw_get_url -OutFile C:\mingw-get.tar.xz
7z e C:\mingw-get.tar.xz -o"C:\\"
$res1 = $?
7z x C:\mingw-get.tar -o"C:\\MinGW"
$res2 = $?
if (!($res1 -and $res2)) {
Write-Host "Failed to extract mingw-get"
Exit 1
}
Remove-Item C:\mingw-get.tar.xz -Force
Remove-Item C:\mingw-get.tar -Force
Get-Date
Write-Host "Installing MSYS for Cerbero into C:/MinGW using mingw-get"
Start-Process -Wait C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit'
if (!$?) {
Write-Host "Failed to install Msys for cerbero using MinGW"
Exit 1
}
Write-Host "MSYS/MinGW Install Complete"

View file

@ -1,69 +0,0 @@
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
$msvc_2017_url = 'https://aka.ms/vs/15/release/vs_buildtools.exe'
$msys2_url = 'https://github.com/msys2/msys2-installer/releases/download/2021-02-15/msys2-base-x86_64-20210215.tar.xz'
$msys_mingw_get_url = 'https://dotsrc.dl.osdn.net/osdn/mingw/68260/mingw-get-0.6.3-mingw32-pre-20170905-1-bin.tar.xz'
Get-Date
Write-Host "Downloading Visual Studio 2017 build tools"
Invoke-WebRequest -Uri $msvc_2017_url -OutFile C:\vs_buildtools.exe
Get-Date
Write-Host "Installing Visual Studio 2017"
Start-Process -NoNewWindow -Wait C:\vs_buildtools.exe -ArgumentList '--wait --quiet --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended'
if (!$?) {
Write-Host "Failed to install Visual Studio tools"
Exit 1
}
Remove-Item C:\vs_buildtools.exe -Force
Get-Date
Write-Host "Downloading and extracting mingw-get for MSYS"
Invoke-WebRequest -Uri $msys_mingw_get_url -OutFile C:\mingw-get.tar.xz
7z e C:\mingw-get.tar.xz -o"C:\\"
$res1 = $?
7z x C:\mingw-get.tar -o"C:\\MinGW"
$res2 = $?
if (!($res1 -and $res2)) {
Write-Host "Failed to extract mingw-get"
Exit 1
}
Remove-Item C:\mingw-get.tar.xz -Force
Remove-Item C:\mingw-get.tar -Force
Get-Date
Write-Host "Installing MSYS for Cerbero into C:/MinGW using mingw-get"
Start-Process -Wait C:\MinGW\bin\mingw-get.exe -ArgumentList 'install msys-base mingw32-base mingw-developer-toolkit'
if (!$?) {
Write-Host "Failed to install Msys for cerbero using MinGW"
Exit 1
}
Get-Date
Write-Host "Installing MSYS2 into C:/msys64"
Invoke-WebRequest -Uri $msys2_url -OutFile C:\msys2-x86_64.tar.xz
7z e C:\msys2-x86_64.tar.xz -o"C:\\"
$res1 = $?
7z x C:\msys2-x86_64.tar -o"C:\\"
$res2 = $?
if (!($res1 -and $res2)) {
Write-Host "Failed to extract msys2"
Exit 1
}
Remove-Item C:\msys2-x86_64.tar.xz -Force
Remove-Item C:\msys2-x86_64.tar -Force
Get-Date
Write-Host "Installing Meson"
pip3 install meson
if (!$?) {
Write-Host "Failed to install meson from pip"
Exit 1
}
Write-Host "Toolchain Install Complete"