Add Windows MSVC and MSYS2 builds
authorXavier Claessens <xavier.claessens@collabora.com>
Sun, 25 Nov 2018 18:38:06 +0000 (13:38 -0500)
committerXavier Claessens <xclaesse@gmail.com>
Fri, 16 Aug 2019 17:17:01 +0000 (17:17 +0000)
This adds 3 new jobs that build against msys2 x86_64, msvc 2017 x86
and msvc 2017 x86_64. For the msvc build, some subprojects (like libnice)
don't satisfy all their deps, and are getting automatically disabled.

This doesn't add jobs that run the test suite also. Will hopefully
get implemented later on.

docker/windows/Dockerfile [new file with mode: 0644]
docker/windows/cleanup.ps1 [new file with mode: 0644]
docker/windows/prepare.ps1 [new file with mode: 0644]
gitlab/ci_template.yml

diff --git a/docker/windows/Dockerfile b/docker/windows/Dockerfile
new file mode 100644 (file)
index 0000000..32eaccc
--- /dev/null
@@ -0,0 +1,9 @@
+# escape=`
+
+FROM 'mcr.microsoft.com/windows/servercore:1607'
+
+# Make sure any failure in PowerShell scripts is fatal
+SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]
+
+COPY prepare.ps1 cleanup.ps1 C:\
+RUN C:\prepare.ps1 ; C:\cleanup.ps1
diff --git a/docker/windows/cleanup.ps1 b/docker/windows/cleanup.ps1
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/docker/windows/prepare.ps1 b/docker/windows/prepare.ps1
new file mode 100644 (file)
index 0000000..9bf2cfe
--- /dev/null
@@ -0,0 +1,46 @@
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;
+
+Write-Host "Installing VisualStudio"
+Invoke-WebRequest -Uri 'https://aka.ms/vs/15/release/vs_buildtools.exe' -OutFile C:\vs_buildtools.exe
+Start-Process C:\vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended' -Wait
+Remove-Item C:\vs_buildtools.exe -Force
+
+Write-Host "Installing Python"
+Invoke-WebRequest -Uri 'https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe' -OutFile C:\python-3.7.0.exe
+Start-Process C:\python-3.7.0.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait
+Remove-Item C:\python-3.7.0.exe -Force
+
+Write-Host "Installing Git"
+Invoke-WebRequest -Uri 'https://github.com/git-for-windows/git/releases/download/v2.19.1.windows.1/MinGit-2.19.1-64-bit.zip' -OutFile C:\mingit.zip
+Expand-Archive C:\mingit.zip -DestinationPath c:\mingit
+Remove-Item C:\mingit.zip -Force
+$env:PATH = [System.Environment]::GetEnvironmentVariable('PATH', 'Machine') + ';' + 'c:\mingit\cmd'
+[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine)
+
+Write-Host "Installing 7zip"
+Invoke-WebRequest -Uri 'https://www.7-zip.org/a/7z1805-x64.exe' -OutFile C:\7z-x64.exe
+Start-Process C:\7z-x64.exe -ArgumentList '/S /D=C:\7zip\' -Wait
+Remove-Item C:\7z-x64.exe -Force
+
+Write-Host "Installing MSYS2"
+Invoke-WebRequest -Uri 'https://ayera.dl.sourceforge.net/project/msys2/Base/x86_64/msys2-base-x86_64-20180531.tar.xz' -OutFile C:\msys2-x86_64.tar.xz
+C:\7zip\7z e C:\msys2-x86_64.tar.xz -Wait
+C:\7zip\7z x C:\msys2-x86_64.tar -o"C:\\"
+Remove-Item C:\msys2-x86_64.tar.xz -Force
+Remove-Item C:\msys2-x86_64.tar -Force
+Remove-Item C:\7zip -Recurse -Force
+
+# FIXME: This works but then docker fails to save the image. Needs to investigate why.
+#$env:PATH += ";C:\msys64\usr\bin;C:\msys64\mingw64/bin;C:\msys64\mingw32/bin"
+#C:\msys64\usr\bin\bash -c "pacman-key --init && pacman-key --populate msys2 && pacman-key --refresh-keys"
+#C:\msys64\usr\bin\bash -c "pacman -Syuu --noconfirm"
+#C:\msys64\usr\bin\bash -c "pacman -Sy --noconfirm --needed mingw-w64-x86_64-toolchain ninja"
+
+pip install meson
+
+git config --global user.email "gst-build@gstreamer.net"
+git config --global user.name "Gstbuild Runner"
+
+# Download gst-build and all its subprojects
+git clone https://gitlab.freedesktop.org/gstreamer/gst-build.git C:\gst-build
+meson subprojects download --sourcedir C:\gst-build
index ac6f198..197dd99 100644 (file)
@@ -20,7 +20,6 @@ variables:
   GIT_STRATEGY: none
   MESON_BUILDTYPE_ARGS: --default-library=both
   DEFAULT_MESON_ARGS: >
-    --werror
     -Dpython=enabled
     -Dlibav=enabled
     -Dugly=enabled
@@ -82,7 +81,7 @@ gst indent:
   variables:
     CCACHE_BASEDIR: "${CI_PROJECT_DIR}"
     CCACHE_DIR: "${CI_PROJECT_DIR}/ccache"
-    MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS}"
+    MESON_ARGS: "${DEFAULT_MESON_ARGS} ${MESON_BUILDTYPE_ARGS} --werror"
 
   script:
     - ccache -z
@@ -346,6 +345,64 @@ valgrind ges:
       - "${CERBERO_HOME}/logs"
       - "*.tar.bz2"
 
+.build windows:
+  image: 'registry.freedesktop.org/gstreamer/gst-ci/amd64/windows:v4'
+  stage: 'build'
+  dependencies:
+    - 'manifest'
+  tags:
+    - 'docker'
+    - 'windows'
+    - '1607'
+  variables:
+    MESON_ARGS: >
+      ${DEFAULT_MESON_ARGS}
+      -Dpython=disabled
+      -Dlibav=disabled
+      -Dvaapi=disabled
+      -Ddevtools=disabled
+  script:
+    # For some reason, options are separated by newline instead of space, so we
+    # have to replace them first.
+    - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
+    # Gitlab executes PowerShell in docker, but VsDevCmd.bat is a batch script.
+    # Environment variables substitutions is done by PowerShell before calling
+    # cmd.exe, that's why we use $env:FOO instead of %FOO%
+    - cmd.exe /C "C:\BuildTools\Common7\Tools\VsDevCmd.bat -host_arch=amd64 -arch=$env:ARCH &&
+        cd C:\gst-build &&
+        python git-update --no-interaction --manifest=$env:CI_PROJECT_DIR/manifest.xml &&
+        meson build $env:MESON_ARGS &&
+        ninja -C build"
+  after_script:
+    # FIXME: cleanup build dir for artifacts.
+
+build vs2017 amd64:
+  extends: '.build windows'
+  variables:
+    ARCH: 'amd64'
+
+build vs2017 x86:
+  extends: '.build windows'
+  variables:
+    ARCH: 'x86'
+
+build msys2 :
+  extends: '.build windows'
+  script:
+    - $env:PATH += ";C:\msys64\usr\bin;C:\msys64\mingw64/bin;C:\msys64\mingw32/bin"
+    # FIXME: This should be done in Dockerfile, but doesn't work there. Needs to investigate why.
+    - C:\msys64\usr\bin\bash -c "pacman-key --init && pacman-key --populate msys2 && pacman-key --refresh-keys || true"
+    - C:\msys64\usr\bin\bash -c "pacman -Syu --noconfirm"
+    - C:\msys64\usr\bin\bash -c "pacman -Sy --noconfirm --needed mingw-w64-x86_64-toolchain ninja"
+    # For some reason, options are separated by newline instead of space, so we
+    # have to replace them first.
+    - $env:MESON_ARGS = $env:MESON_ARGS.replace("`n"," ")
+    - C:\msys64\usr\bin\bash -c "cd /c/gst-build &&
+        python git-update --no-interaction --manifest=$env:CI_PROJECT_DIR/manifest.xml &&
+        meson build $env:MESON_ARGS &&
+        ninja -C build"
+
+
 # Template for Cerbero GStreamer Deps
 #
 # This template is used by cerbero/ project to pre-built the GStreamer