CI: Add native Windows VS2019 build

Adds a native build of Mesa using Meson with the Visual Studio 2019
toolchain on a Windows host.

Though Docker is supported on Windows, Docker-in-Docker is not possible,
nor are podman and skopeo available. We handle this by creating the
container from a shell-executor Windows machine, which gives us a native
PowerShell that we can execute Docker from. This attempts to do the same
copy-from-upstream-or-create-if-not-exists optimisation as the
ci-templates do for our Linux builds, albeit open-coded in PowerShell.

The Mesa build itself is executed inside a container, using Meson and
Ninja.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Acked-by: Jose Fonseca <jfonseca@vmware.com>
Acked-by: Brian Paul <brianp@vmware.com>
Acked-by: Eric Engestrom <eric@engestrom.ch>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4304>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4304>
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d152387..75b2578 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -185,6 +185,43 @@
     - meson-arm64
     - arm_test
 
+# Native Windows docker builds
+# 
+# Unlike the above Linux-based builds - including MinGW/SCons builds which
+# cross-compile for Windows - which use the freedesktop ci-templates, we
+# cannot use the same scheme here. As Windows lacks support for
+# Docker-in-Docker, and Podman does not run natively on Windows, we have
+# to open-code much of the same ourselves.
+#
+# This is achieved by first running in a native Windows shell instance
+# (host PowerShell) in the container stage to build and push the image,
+# then in the build stage by executing inside Docker.
+
+.windows-docker-vs2019:
+  variables:
+    WINDOWS_TAG: "2020-03-24"
+    WINDOWS_IMAGE: "$CI_REGISTRY_IMAGE/windows/x64_build:$WINDOWS_TAG"
+    WINDOWS_UPSTREAM_IMAGE: "$CI_REGISTRY/$FDO_UPSTREAM_REPO/windows/x64_build:$WINDOWS_TAG"
+
+windows_build_vs2019:
+  extends:
+    - .container
+    - .windows-docker-vs2019
+  stage: container
+  variables:
+    GIT_STRATEGY: fetch # we do actually need the full repository though
+  tags:
+    - windows
+    - shell
+    - "1809"
+  script:
+    - .\.gitlab-ci\windows\mesa_container.ps1 $CI_REGISTRY $CI_REGISTRY_USER $CI_REGISTRY_PASSWORD $WINDOWS_IMAGE $WINDOWS_UPSTREAM_IMAGE
+  
+.use-windows_build_vs2019:
+  extends: .windows-docker-vs2019
+  image: "$WINDOWS_IMAGE"
+  needs:
+    - windows_build_vs2019
 
 # BUILD
 
@@ -218,7 +255,9 @@
 .build-windows:
   extends: .build-common
   tags:
-    - mesa-windows
+    - windows
+    - docker
+    - "1809"
   cache:
     key: ${CI_JOB_NAME}
     paths:
@@ -386,15 +425,13 @@
     CC: "ccache clang-9"
     CXX: "ccache clang++-9"
 
-.meson-windows:
+meson-windows-vs2019:
   extends:
     - .build-windows
+    - .use-windows_build_vs2019
   stage: meson-misc
-  before_script:
-    - $ENV:ARCH = "x86"
-    - $ENV:VERSION = "2019\Community"
   script:
-    - cmd /C .gitlab-ci\meson-build.bat
+    - . .\.gitlab-ci\windows\mesa_build.ps1
 
 scons-win64:
   extends: .scons-build