| 1 | # Native Windows GitLab CI builds |
| 2 | |
| 3 | <!-- |
| 4 | # Copyright 2019-2022, Mesa contributors |
| 5 | # Copyright 2022, Collabora, Ltd. |
| 6 | # SPDX-License-Identifier: MIT |
| 7 | |
| 8 | Based on https://gitlab.freedesktop.org/mesa/mesa/-/blob/8396df5ad90aeb6ab2267811aba2187954562f81/.gitlab-ci/windows/README.md |
| 9 | --> |
| 10 | |
| 11 | We are using the same basic approach to Windows CI building as Mesa, just as we |
| 12 | do on Linux. See |
| 13 | <https://gitlab.freedesktop.org/mesa/mesa/-/tree/main/.gitlab-ci/windows> for |
| 14 | the details there. The following is the Mesa readme, lightly modified to fit |
| 15 | Monado. |
| 16 | |
| 17 | Unlike Linux, Windows cannot reuse the freedesktop ci-templates as they exist |
| 18 | as we do not have Podman, Skopeo, or even Docker-in-Docker builds available |
| 19 | under Windows. |
| 20 | |
| 21 | We still reuse the same model: build a base container with the core operating |
| 22 | system and infrequently-changed build dependencies, then execute Monado builds |
| 23 | only inside that base container. This is open-coded in PowerShell scripts. |
| 24 | |
| 25 | ## Base container build |
| 26 | |
| 27 | The base container build jobs execute the `monado_container.ps1` script which |
| 28 | reproduces the ci-templates behaviour. It looks for the registry image in |
| 29 | the user's namespace, and exits if found. If not found, it tries to copy |
| 30 | the same image tag from the upstream Monado repository. If that is not found, |
| 31 | the image is rebuilt inside the user's namespace. |
| 32 | |
| 33 | The rebuild executes `docker build` which calls `monado_deps_*.ps1` inside the |
| 34 | container to fetch and install all build dependencies. This includes Visual |
| 35 | Studio Build Tools (downloaded from Microsoft, under the license which |
| 36 | allows use by open-source projects), and other build tools from Scoop. |
| 37 | (These are done as two separate jobs to allow "resuming from the middle".) |
| 38 | |
| 39 | This job is executed inside a Windows shell environment directly inside the |
| 40 | host, without Docker. |
| 41 | |
| 42 | ## Monado build |
| 43 | |
| 44 | The Monado build runs inside the base container, executing `mesa_build.ps1`. |
| 45 | This simply compiles Monado using CMake and Ninja, executing the build and |
| 46 | unit tests. |
| 47 | |
| 48 | ## Local testing |
| 49 | |
| 50 | To try these scripts locally, you need this done once, rebooting after they are complete: |
| 51 | |
| 52 | ```pwsh |
| 53 | scoop install sudo |
| 54 | sudo Add-MpPreference -ExclusionProcess dockerd.exe |
| 55 | sudo Add-MpPreference -ExclusionProcess docker.exe |
| 56 | winget install stevedore |
| 57 | sudo Add-MpPreference -ExclusionPath c:\ProgramData\docker |
| 58 | ``` |
| 59 | |
| 60 | then this, done when you want to test: |
| 61 | |
| 62 | ```pwsh |
| 63 | docker context use desktop-windows |
| 64 | ``` |
| 65 | |
| 66 | before doing your normal `docker build .`, etc. (It may still be very slow |
| 67 | despite the virus scanning exclusions.) |
| 68 | |
| 69 | If you're having issues accessing the network, see this comment's instructions: |
| 70 | <https://github.com/docker/for-win/issues/9847#issuecomment-832674649> |