-
Notifications
You must be signed in to change notification settings - Fork 0
296 lines (259 loc) · 12 KB
/
build-mesa.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
#
# .github/workflows/build-mesa.yml
#
# Copyright 2024 Jens A. Koch.
# SPDX-License-Identifier: MIT
# This file is part of https://github.com/jakoch/rasterizers
#
name: "Build on Windows: Mesa llvmpipe"
on:
# You can manually run this workflow.
workflow_dispatch:
push:
branches:
- main
tags:
- "*.*.*"
pull_request:
branches:
- main
# This workflow runs on schedule: every Sunday at 1 am.
#schedule:
# - cron: "0 1 * * 0"
# needed by "softprops/action-gh-release"
permissions:
contents: write
# improve CI concurrency by automatically cancelling outdated jobs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
# ---------------------------------------------------------------------------------------
build-on-windows-mesa:
# ---------------------------------------------------------------------------------------
name: "Windows VC17"
# https://github.com/actions/runner-images
# Installed Software: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md
runs-on: windows-2022
env:
MESA_VERSION_TAG: 'mesa-24.1.3'
MESA_SOURCE_DIR: ${{github.workspace}}\mesa
MESA_BUILD_DIR: ${{github.workspace}}\mesa\build
MESA_INSTALL_DIR: ${{github.workspace}}\mesa\install
LLVM_VERSION: '18.1.8'
LLVM_PROJECT_DIR: ${{github.workspace}}\llvm-project
LLVM_CMAKE_DIR: ${{github.workspace}}\llvm-project\cmake
LLVM_SOURCE_DIR: ${{github.workspace}}\llvm-project\llvm
LLVM_BUILD_DIR: ${{github.workspace}}\llvm-project\llvm\build
LLVM_INSTALL_DIR: ${{github.workspace}}\llvm-project\llvm\install
DIRECTX_HEADER_TAG: 'v1.614.0'
DIRECTX_SDK_DIR: ${{github.workspace}}\directx
defaults:
run:
shell: cmd
#
# Building Mesa
#
# https://docs.mesa3d.org/install.html + https://docs.mesa3d.org/meson.html
#
# Build Dependencies:
# 1. meson
# 2. winflexbison (bison, flex)
# 3. python packages: packaging, mako
# 4. llvm
# 5. directx-sdk
#
# Pre-installed on GHA
# - git, curl, 7z
# - cmake
# - python, pip
# - rustc
# - msvc VC17
steps:
- name: 🤘 Checkout Code
uses: actions/checkout@v4 # https://github.com/actions/checkout
- name: 🤘 Checkout Code - https://gitlab.freedesktop.org/mesa/mesa
run: |
git clone --depth 1 --branch ${{ env.MESA_VERSION_TAG }} https://gitlab.freedesktop.org/mesa/mesa.git mesa
- name: 🛠️ Setup Visual Studio Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1 # https://github.com/ilammy/msvc-dev-cmd
# https://community.chocolatey.org/packages/cmake
- name: 🔽 Install CMake
run: choco install cmake --installargs 'ADD_CMAKE_TO_PATH=System' --no-progress
# Reminder: This step requires that the CMakePresets for CI contain
# "CMAKE_CXX_COMPILER_LAUNCHER": "sccache".
- name: 🎯 Setup Build Cache
uses: hendrikmuhs/ccache-action@v1 # https://github.com/hendrikmuhs/ccache-action
with:
variant: sccache
key: mesa-build-${{ github.ref }}
restore-keys: |
mesa-build-${{ github.ref }}
mesa-build-
- name: 🛠️ [LLVM] Make project folder
run: |
mkdir llvm-project
- name: 🔽 [LLVM] Install LLVM into llvm-project folder
working-directory: ${{ env.LLVM_PROJECT_DIR }}
run: |
curl -sfL -o llvm-${{ env.LLVM_VERSION }}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.LLVM_VERSION }}/llvm-${{ env.LLVM_VERSION }}.src.tar.xz
7z x -bb0 -txz llvm-${{ env.LLVM_VERSION }}.src.tar.xz
7z x -bb0 -ttar llvm-${{ env.LLVM_VERSION }}.src.tar
del llvm-${{ env.LLVM_VERSION }}.src.tar.xz
del llvm-${{ env.LLVM_VERSION }}.src.tar
mv llvm-${{ env.LLVM_VERSION }}.src ${{ env.LLVM_SOURCE_DIR }}
- name: 🔽 [LLVM] Install CMAKE modules into llvm-project folder
working-directory: ${{ env.LLVM_PROJECT_DIR }}
run: |
curl -sfL -o cmake-${{ env.LLVM_VERSION }}.src.tar.xz https://github.com/llvm/llvm-project/releases/download/llvmorg-${{ env.LLVM_VERSION }}/cmake-${{ env.LLVM_VERSION }}.src.tar.xz
7z x -bb0 -txz cmake-${{ env.LLVM_VERSION }}.src.tar.xz
7z x -bb0 -ttar cmake-${{ env.LLVM_VERSION }}.src.tar
del cmake-${{ env.LLVM_VERSION }}.src.tar.xz
del cmake-${{ env.LLVM_VERSION }}.src.tar
mv cmake-${{ env.LLVM_VERSION }}.src ${{ env.LLVM_CMAKE_DIR }}
# in-source build, dir: llvm-project/llvm/build
- name: 🛠️ [LLVM] Make build folder
working-directory: ${{ env.LLVM_SOURCE_DIR }}
run: |
mkdir build
#- name: ❔ CHECK important folders, to see if everything is present (before building)
# run: |
# dir /S /B ${{ env.LLVM_PROJECT_DIR }}
- name: 🖋️ [LLVM] Configure
working-directory: ${{ env.LLVM_BUILD_DIR }}
run: |
cmake ^
-B ${{ env.LLVM_BUILD_DIR }} ^
-S ${{ env.LLVM_SOURCE_DIR }} ^
-G Ninja ^
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache ^
-D CMAKE_SYSTEM_NAME=Windows ^
-D CMAKE_SYSTEM_PROCESSOR=x86_64 ^
-D CMAKE_INSTALL_PREFIX="${{ env.LLVM_INSTALL_DIR }}" ^
-D CMAKE_BUILD_TYPE="Release" ^
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
-D BUILD_SHARED_LIBS=OFF ^
-D LLVM_HOST_TRIPLE="x86_64-windows-msvc" ^
-D LLVM_DEFAULT_TARGET_TRIPLE="x86_64-windows-msvc" ^
-D LLVM_TARGETS_TO_BUILD="X86" ^
-D LLVM_ENABLE_BACKTRACES=OFF ^
-D LLVM_ENABLE_UNWIND_TABLES=OFF ^
-D LLVM_ENABLE_CRASH_OVERRIDES=OFF ^
-D LLVM_ENABLE_TERMINFO=OFF ^
-D LLVM_ENABLE_LIBXML2=OFF ^
-D LLVM_ENABLE_LIBEDIT=OFF ^
-D LLVM_ENABLE_LIBPFM=OFF ^
-D LLVM_ENABLE_ZLIB=OFF ^
-D LLVM_ENABLE_Z3_SOLVER=OFF ^
-D LLVM_ENABLE_WARNINGS=OFF ^
-D LLVM_ENABLE_PEDANTIC=OFF ^
-D LLVM_ENABLE_WERROR=OFF ^
-D LLVM_ENABLE_ASSERTIONS=OFF ^
-D LLVM_BUILD_LLVM_C_DYLIB=OFF ^
-D LLVM_BUILD_UTILS=OFF ^
-D LLVM_BUILD_TESTS=OFF ^
-D LLVM_BUILD_DOCS=OFF ^
-D LLVM_BUILD_EXAMPLES=OFF ^
-D LLVM_BUILD_BENCHMARKS=OFF ^
-D LLVM_INCLUDE_UTILS=OFF ^
-D LLVM_INCLUDE_TESTS=OFF ^
-D LLVM_INCLUDE_DOCS=OFF ^
-D LLVM_INCLUDE_EXAMPLES=OFF ^
-D LLVM_INCLUDE_BENCHMARKS=OFF ^
-D LLVM_ENABLE_BINDINGS=OFF ^
-D LLVM_OPTIMIZED_TABLEGEN=ON ^
-D LLVM_ENABLE_PLUGINS=OFF ^
-D LLVM_ENABLE_IDE=OFF
- name: 🙏 [LLVM] Build
run: |
ninja -C ${{ env.LLVM_BUILD_DIR }}
ninja -C ${{ env.LLVM_BUILD_DIR }} install
- name: 🛠️ [LLVM] Add to PATH
shell: pwsh
run: |
$env:PATH += ";${{ env.LLVM_INSTALL_DIR }};${{ env.LLVM_INSTALL_DIR }}\bin"
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
# https://community.chocolatey.org/packages/pkgconfiglite
# https://community.chocolatey.org/packages/winflexbison
# https://community.chocolatey.org/packages/winflexbison3 ???
# https://community.chocolatey.org/packages/meson
- name: 🔽 Install Meson
run: |
choco install meson winflexbison pkgconfiglite
refreshenv
- name: 🛠️ [MESON] Add to PATH
shell: pwsh
run: |
$env:PATH += ";C:\Program Files\Meson\"
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: 🛠️ [MESON] Verify Installation
run: meson --version
- name: 🔽 [DIRECTX-HEADERS] Build + Install (d3d12.h)
env:
CC: "sccache cl"
CXX: "sccache cl"
run: |
git clone https://github.com/microsoft/DirectX-Headers -b ${{ env.DIRECTX_HEADER_TAG }} --depth 1
cd DirectX-Headers
meson setup build --backend=ninja --buildtype=release -Dbuild-test=false --prefix="${{ env.DIRECTX_SDK_DIR }}"
meson install -C build
cd ..
rm -rf DirectX-Headers
- name: 🛠️ [DIRECTX-HEADERS] Add to PATH
shell: pwsh
run: |
$env:PATH += ";${{ env.DIRECTX_SDK_DIR }}"
echo "PATH=$env:PATH" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: 🔽 [PYTHON] Install Packages
run: |
pip install packaging mako
#
# Mesa Build Options
#
# https://gitlab.freedesktop.org/mesa/mesa/-/blob/main/meson_options.txt
#
#
# -Dvulkan-drivers="swrast,amd,microsoft-experimental"
# -Dgallium-drivers="swrast,d3d12,zink"
#
- name: 🖋️ [MESA] Setup (swrast llvmpipe)
env:
CC: "sccache cl"
CXX: "sccache cl"
CPPFLAGS: "-I${{ env.DIRECTX_SDK_DIR }}/include"
run: |
meson setup ^
${{ env.MESA_BUILD_DIR }} ^
${{ env.MESA_SOURCE_DIR }} ^
--prefix="${{ env.MESA_INSTALL_DIR }}\mesa-llvmpipe" ^
--default-library=static ^
-D buildtype=release ^
-D platforms=windows ^
-D b_vscrt=mt ^
-D b_ndebug=true ^
-D llvm=enabled ^
-D shared-llvm=disabled ^
-D osmesa=true ^
-D gallium-drivers=swrast ^
-D vulkan-drivers=swrast ^
-D build-tests=true
- name: 🙏 [MESA] Build + Install
run: |
ninja -C ${{ env.MESA_BUILD_DIR }}
ninja -C ${{ env.MESA_BUILD_DIR }} install
# Versioning Pattern: "mesa-lvp-24.1.3-win64.zip"
- name: 🏷️ Versionize Artifact
shell: pwsh
run: |
$version = $env:MESA_VERSION_TAG -replace "^mesa-", ""
echo "MESA_LVP_ARTIFACT_NAME=mesa-lvp-$version-win64" >> $env:GITHUB_ENV
echo "MESA_LVP_ARTIFACT_ZIPFILE=mesa-lvp-$version-win64.zip" >> $env:GITHUB_ENV
- name: 📦 Package
run: |
7z a -tzip -mx9 "${{ env.MESA_LVP_ARTIFACT_ZIPFILE }}" "${{ env.MESA_INSTALL_DIR }}\*"
- name: 📦 🚀 Upload Artifact
uses: actions/upload-artifact@v4 # https://github.com/actions/upload-artifact
with:
name: ${{ env.MESA_LVP_ARTIFACT_NAME }}
path: ${{ env.MESA_LVP_ARTIFACT_ZIPFILE }}