forked from mmozeiko/build-mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cmd
214 lines (184 loc) · 5.66 KB
/
build.cmd
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
@echo off
setlocal enabledelayedexpansion
set LLVM_VERSION=14.0.6
set MESA_VERSION=22.1.3
set PATH=%CD%\llvm\bin;%CD%\winflexbison;%PATH%
rem *** check dependencies ***
where /q python.exe || (
echo ERROR: "python.exe" not found
exit /b 1
)
where /q pip.exe || (
echo ERROR: "pip.exe" not found
exit /b 1
)
where /q meson.exe || (
pip install meson
where /q meson.exe || (
echo ERROR: "meson.exe" not found
exit /b 1
)
)
python -c "import mako" 2>nul || (
pip install mako
python -c "import mako" 2>nul || (
echo ERROR: "mako" module not found for python
exit /b 1
)
)
where /q git.exe || (
echo ERROR: "git.exe" not found
exit /b 1
)
where /q curl.exe || (
echo ERROR: "curl.exe" not found
exit /b 1
)
if exist "%ProgramFiles%\7-Zip\7z.exe" (
set SZIP="%ProgramFiles%\7-Zip\7z.exe"
) else (
where /q 7za.exe || (
echo ERROR: 7-Zip installation or "7za.exe" not found
exit /b 1
)
set SZIP=7za.exe
)
where /q cmake.exe || (
echo ERROR: "cmake.exe" not found
exit /b 1
)
where /q ninja.exe || (
curl -Lsf -o ninja-win.zip https://github.com/ninja-build/ninja/releases/download/v1.11.0/ninja-win.zip || exit /b 1
%SZIP% x -bb0 -y ninja-win.zip 1>nul 2>nul || exit /b 1
del ninja-win.zip 1>nul 2>nul
)
rem *** Visual Studio environment ***
where /Q cl.exe || (
set __VSCMD_ARG_NO_LOGO=1
for /f "tokens=*" %%i in ('"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -requires Microsoft.VisualStudio.Workload.NativeDesktop -property installationPath') do set VS=%%i
if "!VS!" equ "" (
echo ERROR: Visual Studio installation not found
exit /b 1
)
call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1
)
rem *** download sources ***
echo Downloading llvm
curl -sfL https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%/llvm-%LLVM_VERSION%.src.tar.xz ^
| %SZIP% x -bb0 -txz -si -so ^
| %SZIP% x -bb0 -ttar -si -aoa 1>nul 2>nul
move llvm-%LLVM_VERSION%.src llvm.src
echo Downloading mesa
curl -sfL https://archive.mesa3d.org//mesa-%MESA_VERSION%.tar.xz ^
| %SZIP% x -bb0 -txz -si -so ^
| %SZIP% x -bb0 -ttar -si -aoa 1>nul 2>nul
move mesa-%MESA_VERSION% mesa.src
git apply -p0 --directory=mesa.src mesa.patch || exit /b 1
echo Downloading win_flex_bison
if not exist winflexbison (
mkdir winflexbison
pushd winflexbison
curl -sfL -o win_flex_bison-2.5.25.zip https://github.com/lexxmark/winflexbison/releases/download/v2.5.25/win_flex_bison-2.5.25.zip || exit /b 1
%SZIP% x -bb0 -y win_flex_bison-2.5.25.zip 1>nul 2>nul || exit /b 1
del win_flex_bison-2.5.25.zip 1>nul 2>nul
popd
)
del "@PaxHeader" "HEAD" "pax_global_header" 1>nul 2>nul
rem *** llvm ***
cmake ^
-G Ninja ^
-S llvm.src ^
-B llvm.build ^
-D CMAKE_INSTALL_PREFIX="%CD%\llvm" ^
-D CMAKE_BUILD_TYPE="Release" ^
-D BUILD_SHARED_LIBS=OFF ^
-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_USE_CRT_RELEASE=MT ^
-D LLVM_ENABLE_IDE=OFF || exit /b 1
ninja -C llvm.build
ninja -C llvm.build install || exit /b 1
rem *** mesa llvmpipe ***
rd /s /q mesa.build 1>nul 2>nul
meson setup ^
mesa.build ^
mesa.src ^
--prefix="%CD%\mesa-llvmpipe" ^
--default-library=static ^
-Dbuildtype=release ^
-Db_ndebug=true ^
-Db_vscrt=mt ^
-Dllvm=enabled ^
-Dplatforms=windows ^
-Dosmesa=true ^
-Dgallium-drivers=swrast || exit /b 1
ninja -C mesa.build install || exit /b 1
rem *** mesa d3d12 ***
@REM rd /s /q mesa.build 1>nul 2>nul
@REM meson setup ^
@REM mesa.build ^
@REM mesa.src ^
@REM --prefix="%CD%\mesa-d3d12" ^
@REM --default-library=static ^
@REM -Dbuildtype=release ^
@REM -Db_ndebug=true ^
@REM -Db_vscrt=mt ^
@REM -Dllvm=disabled ^
@REM -Dplatforms=windows ^
@REM -Dosmesa=false ^
@REM -Dgallium-drivers=d3d12 || exit /b 1
@REM ninja -C mesa.build install || exit /b 1
rem *** done ***
rem output is in mesa-d3d12 and mesa-llvmpipe folders
if "%GITHUB_WORKFLOW%" neq "" (
mkdir archive-llvmpipe
pushd archive-llvmpipe
copy /y ..\mesa-llvmpipe\bin\opengl32.dll .
%SZIP% a -mx=9 ..\mesa-llvmpipe.zip
popd
@REM mkdir archive-osmesa
@REM pushd archive-osmesa
@REM copy /y ..\mesa-llvmpipe\bin\osmesa.dll .
@REM copy /y ..\mesa-llvmpipe\lib\osmesa.lib .
@REM copy /y ..\mesa-llvmpipe\include\GL\osmesa.h .
@REM %SZIP% a -mx=9 ..\mesa-osmesa.zip
@REM popd
@REM mkdir archive-d3d12
@REM pushd archive-d3d12
@REM copy /y ..\mesa-d3d12\bin\opengl32.dll .
@REM if exist "%ProgramFiles(x86)%\Windows Kits\10\Redist\D3D\x64\dxil.dll" (
@REM copy /y "%ProgramFiles(x86)%\Windows Kits\10\Redist\D3D\x64\dxil.dll" .
@REM ) else if exist "%WindowsSdkVerBinPath%x64\dxil.dll" (
@REM copy /y "%WindowsSdkVerBinPath%x64\dxil.dll" .
@REM )
@REM %SZIP% a -mx=9 ..\mesa-d3d12.zip
@REM popd
echo ::set-output name=LLVM_VERSION::%LLVM_VERSION%
echo ::set-output name=MESA_VERSION::%MESA_VERSION%
)