This repository was archived by the owner on Apr 20, 2026. It is now read-only.
forked from mmozeiko/build-mesa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.cmd
More file actions
419 lines (360 loc) · 15.1 KB
/
build.cmd
File metadata and controls
419 lines (360 loc) · 15.1 KB
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
@echo off
setlocal enabledelayedexpansion
set MESA_VERSION=26.0.5
set MESA_SHA256=d229c9937d9a25ca0a8958c59f425174563d300ec42acbea2dbe84a055023368
set LLVM_VERSION=22.1.3
set LLVM_SHA256=2488c33a959eafba1c44f253e5bbe7ac958eb53fa626298a3a5f4b87373767cd
set LLVM_RELEASE=https://discourse.llvm.org/t/llvm-22-1-3-released/90467
>nul find "'%LLVM_VERSION%'" meson\meson.llvm.build || (
echo llvm version in meson.llvm.build does not match expected %LLVM_VERSION% value^^!
exit /b 1
)
rem *** architectures ***
if "%PROCESSOR_ARCHITECTURE%" equ "x86" (
set HOST_ARCH=x86
) else if "%PROCESSOR_ARCHITECTURE%" equ "AMD64" (
set HOST_ARCH=x64
) else if "%PROCESSOR_ARCHITECTURE%" equ "ARM64" (
set HOST_ARCH=arm64
) else (
echo Unknown host architecture^^!
exit /b 1
)
if "%1" neq "" (
set MESA_ARCH=%1
) else (
set MESA_ARCH=%HOST_ARCH%
)
if "%MESA_ARCH%" equ "x86" (
set TARGET_ARCH=x86
set LLVM_TARGETS_TO_BUILD=X86
set TARGET_ARCH_NAME=i686
) else if "%MESA_ARCH%" equ "x64" (
set TARGET_ARCH=x64
set LLVM_TARGETS_TO_BUILD=X86
set TARGET_ARCH_NAME=x86_64
) else if "%MESA_ARCH%" equ "arm64" (
set TARGET_ARCH=arm64
set LLVM_TARGETS_TO_BUILD=AArch64
set TARGET_ARCH_NAME=aarch64
) else (
echo Unknown "%MESA_ARCH%" build architecture^^!
exit /b 1
)
set MESON_CROSS=--cross-file "%CD%\meson\meson-%MESA_ARCH%.txt"
if "%MESA_ARCH%" equ "x86" (
set MESON_CROSS=%MESON_CROSS% -Dmin-windows-version=7
)
set PATH=%CD%\llvm-%MESA_ARCH%\bin;%CD%\winflexbison;%PATH%
rem *** check dependencies ***
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
where /q tar.exe || echo ERROR: "tar.exe" not found && exit /b 1
where /q cmake.exe || echo ERROR: "cmake.exe" not found && exit /b 1
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 || exit /b 1
python.exe -c "import packaging" 2>nul || pip.exe install packaging || exit /b 1
python.exe -c "import mako" 2>nul || pip.exe install mako || exit /b 1
python.exe -c "import yaml" 2>nul || pip.exe install pyyaml || exit /b 1
if "%GITHUB_WORKFLOW%" neq "" (
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 ninja.exe || (
if "%HOST_ARCH%" equ "x86" (
echo Sorry, ninja binary is not available on 32-bit windows anymore^^!
exit /b 1
) else if "%HOST_ARCH%" equ "x64" (
curl.exe -sfLO https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip || exit /b 1
) else if "%HOST_ARCH%" equ "arm64" (
curl.exe -sfLo ninja-win.zip https://github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-winarm64.zip || exit /b 1
)
tar.exe -xf ninja-win.zip || exit /b 1
del ninja-win.zip 1>nul 2>nul
)
if not exist winflexbison (
echo Downloading win_flex_bison
mkdir winflexbison
pushd winflexbison
rem 2.5.25 is buggy when running parallel make, see: https://github.com/lexxmark/winflexbison/issues/86
curl.exe -sfL -o win_flex_bison.zip https://github.com/lexxmark/winflexbison/releases/download/v2.5.24/win_flex_bison-2.5.24.zip || exit /b 1
tar.exe -xf win_flex_bison.zip || exit /b 1
del win_flex_bison.zip 1>nul 2>nul
popd
)
rem *** find Visual Studio ***
set VSCMD_SKIP_SENDTELEMETRY=1
if "%VS%" equ "" (
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
)
rem *** download & build llvm ***
if exist "llvm-%LLVM_VERSION%-%MESA_ARCH%\lib\LLVMSupport.lib" (
call "%VS%\Common7\Tools\VsDevCmd.bat" -arch=%TARGET_ARCH% -host_arch=%HOST_ARCH% -startdir=none -no_logo || exit /b 1
goto :skip-llvm-build
)
call :get "https://github.com/llvm/llvm-project/releases/download/llvmorg-%LLVM_VERSION%/llvm-project-%LLVM_VERSION%.src.tar.xz" "llvm-project-%LLVM_VERSION%.src" "%LLVM_SHA256%" || exit /b 1
if "%TARGET_ARCH%" neq "%HOST_ARCH%" (
call "%VS%\Common7\Tools\VsDevCmd.bat" -arch=%HOST_ARCH% -host_arch=%HOST_ARCH% -startdir=none -no_logo || exit /b 1
cmake.exe ^
-Wno-dev ^
-G Ninja ^
-S llvm-project-%LLVM_VERSION%.src\llvm ^
-B llvm-project-%LLVM_VERSION%.build-native ^
-D CMAKE_INSTALL_PREFIX="%CD%\llvm-%LLVM_VERSION%-native" ^
-D CMAKE_BUILD_TYPE="Release" ^
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
-D BUILD_SHARED_LIBS=OFF ^
-D LLVM_TARGETS_TO_BUILD=%LLVM_TARGETS_TO_BUILD% ^
-D LLVM_ENABLE_BACKTRACES=OFF ^
-D LLVM_ENABLE_UNWIND_TABLES=OFF ^
-D LLVM_ENABLE_CRASH_OVERRIDES=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 || exit /b 1
ninja.exe -C llvm-project-%LLVM_VERSION%.build-native llvm-tblgen || exit /b 1
echo . > llvm-project-%LLVM_VERSION%.build-native\bin\llvm-nm.exe
echo . > llvm-project-%LLVM_VERSION%.build-native\bin\llvm-readobj.exe
set LLVM_CMAKE_FLAGS=-D CMAKE_SYSTEM_NAME=Windows -D LLVM_NATIVE_TOOL_DIR="%CD%\llvm-project-%LLVM_VERSION%.build-native\bin"
) else (
set LLVM_CMAKE_FLAGS=
)
call "%VS%\Common7\Tools\VsDevCmd.bat" -arch=%TARGET_ARCH% -host_arch=%HOST_ARCH% -startdir=none -no_logo || exit /b 1
cmake.exe ^
-Wno-dev ^
-G Ninja ^
-S llvm-project-%LLVM_VERSION%.src\llvm ^
-B llvm-project-%LLVM_VERSION%.build-%MESA_ARCH% ^
%LLVM_CMAKE_FLAGS% ^
-D CMAKE_INSTALL_PREFIX="%CD%\llvm-%LLVM_VERSION%-%MESA_ARCH%" ^
-D CMAKE_BUILD_TYPE="Release" ^
-D CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ^
-D BUILD_SHARED_LIBS=OFF ^
-D LLVM_HOST_TRIPLE=%TARGET_ARCH_NAME%-pc-windows-msvc ^
-D LLVM_TARGETS_TO_BUILD=%LLVM_TARGETS_TO_BUILD% ^
-D LLVM_ENABLE_BACKTRACES=OFF ^
-D LLVM_ENABLE_UNWIND_TABLES=OFF ^
-D LLVM_ENABLE_CRASH_OVERRIDES=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_TOOL_LTO_BUILD=OFF ^
-D LLVM_ENABLE_PLUGINS=OFF ^
-D LLVM_ENABLE_IDE=OFF || exit /b 1
ninja.exe -C llvm-project-%LLVM_VERSION%.build-%MESA_ARCH% llvm-headers llvm-libraries || exit /b 1
ninja.exe -C llvm-project-%LLVM_VERSION%.build-%MESA_ARCH% install-llvm-headers install-llvm-libraries 1>nul || exit /b 1
:skip-llvm-build
rem *** extra libs ***
set LINK=version.lib ntdll.lib
rem *** download mesa source ***
rd /s /q mesa-%MESA_VERSION% 1>nul 2>nul
call :get "https://archive.mesa3d.org/mesa-%MESA_VERSION%.tar.xz" "mesa-%MESA_VERSION%" "%MESA_SHA256%" || exit /b 1
git.exe apply --directory=mesa-%MESA_VERSION% patches/gallium-use-tex-cache.patch || exit /b 1
git.exe apply --directory=mesa-%MESA_VERSION% patches/gallium-static-build.patch || exit /b 1
git.exe apply --directory=mesa-%MESA_VERSION% patches/dxil-hash.patch || exit /b 1
rem fixes from https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15275
git.exe apply --directory=mesa-%MESA_VERSION% patches/mesa-llvm22-fix.patch || exit /b 1
mkdir mesa-%MESA_VERSION%\subprojects\llvm 1>nul || exit /b 1
copy meson\meson.llvm.build mesa-%MESA_VERSION%\subprojects\llvm\meson.build 1>nul || exit /b 1
rem *** llvmpipe, lavapipe ***
rd /s /q mesa-build-%MESA_ARCH% 1>nul 2>nul
meson.exe setup ^
mesa-build-%MESA_ARCH% ^
mesa-%MESA_VERSION% ^
--prefix="%CD%\mesa-llvmpipe-%MESA_ARCH%" ^
--default-library=static ^
-Dbuildtype=release ^
-Db_ndebug=true ^
-Db_vscrt=mt ^
-Dc_args="-wd4189 -wd4319" ^
-Dllvm=enabled ^
-Dplatforms=windows ^
-Dvideo-codecs= ^
-Dgallium-drivers=llvmpipe ^
-Dvulkan-drivers=swrast ^
-Degl=enabled ^
-Dgles1=enabled ^
-Dgles2=enabled ^
%MESON_CROSS% || exit /b 1
ninja.exe -C mesa-build-%MESA_ARCH% install || exit /b 1
python.exe mesa-%MESA_VERSION%\src\vulkan\util\vk_icd_gen.py --api-version 1.4 --xml mesa-%MESA_VERSION%\src\vulkan\registry\vk.xml --icd-lib-path . --icd-filename vulkan_lvp.dll --use-backslash --out mesa-llvmpipe-%MESA_ARCH%\bin\lvp_icd.%TARGET_ARCH_NAME%.json || exit /b 1
rem *** d3d12, dzn ***
rd /s /q mesa-build-%MESA_ARCH% 1>nul 2>nul
meson.exe setup ^
mesa-build-%MESA_ARCH% ^
mesa-%MESA_VERSION% ^
--prefix="%CD%\mesa-d3d12-%MESA_ARCH%" ^
--default-library=static ^
-Dbuildtype=release ^
-Db_ndebug=true ^
-Db_vscrt=mt ^
-Dc_args="-wd4189 -wd4319" ^
-Dllvm=disabled ^
-Dplatforms=windows ^
-Dvideo-codecs=all ^
-Dmediafoundation-codecs=all ^
-Dgallium-mediafoundation=enabled ^
-Dgallium-drivers=d3d12 ^
-Dvulkan-drivers=microsoft-experimental ^
-Degl=enabled ^
-Dgles1=enabled ^
-Dgles2=enabled ^
%MESON_CROSS% || exit /b 1
ninja.exe -C mesa-build-%MESA_ARCH% install || exit /b 1
python.exe mesa-%MESA_VERSION%\src\vulkan\util\vk_icd_gen.py --api-version 1.1 --xml mesa-%MESA_VERSION%\src\vulkan\registry\vk.xml --icd-lib-path . --icd-filename vulkan_dzn.dll --use-backslash --out mesa-d3d12-%MESA_ARCH%\bin\dzn_icd.%TARGET_ARCH_NAME%.json || exit /b 1
rem *** zink ***
git.exe apply --directory=mesa-%MESA_VERSION% patches/zink-static-build.patch || exit /b 1
git.exe apply --directory=mesa-%MESA_VERSION% patches/zink-drop-nullDescriptor-requirement.patch || exit /b 1
rd /s /q mesa-build-%MESA_ARCH% 1>nul 2>nul
meson.exe setup ^
mesa-build-%MESA_ARCH% ^
mesa-%MESA_VERSION% ^
--prefix="%CD%\mesa-zink-%MESA_ARCH%" ^
--default-library=static ^
-Dbuildtype=release ^
-Db_ndebug=true ^
-Db_vscrt=mt ^
-Dc_args="-wd4189 -wd4319" ^
-Dllvm=disabled ^
-Dplatforms=windows ^
-Dvideo-codecs= ^
-Dgallium-drivers=zink ^
-Degl=enabled ^
-Dgles1=enabled ^
-Dgles2=enabled ^
%MESON_CROSS% || exit /b 1
ninja.exe -C mesa-build-%MESA_ARCH% install || exit /b 1
rem *** done ***
if "%GITHUB_WORKFLOW%" neq "" (
mkdir archive-llvmpipe-%MESA_ARCH%
pushd archive-llvmpipe-%MESA_ARCH%
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\opengl32.dll . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\libEGL.dll . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\lib\libEGL.lib . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\libGLESv1_CM.dll . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\lib\libGLESv1_CM.lib . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\libGLESv2.dll . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\lib\libGLESv2.lib . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-llvmpipe-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
mkdir archive-lavapipe-%MESA_ARCH%
pushd archive-lavapipe-%MESA_ARCH%
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\vulkan_lvp.dll . || exit /b 1
copy /y ..\mesa-llvmpipe-%MESA_ARCH%\bin\lvp_icd.%TARGET_ARCH_NAME%.json . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-lavapipe-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
mkdir archive-d3d12-%MESA_ARCH%
pushd archive-d3d12-%MESA_ARCH%
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\opengl32.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\libEGL.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\lib\libEGL.lib . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\libGLESv1_CM.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\lib\libGLESv1_CM.lib . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\libGLESv2.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\lib\libGLESv2.lib . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-d3d12-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
mkdir archive-zink-%MESA_ARCH%
pushd archive-zink-%MESA_ARCH%
copy /y ..\mesa-zink-%MESA_ARCH%\bin\opengl32.dll . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\bin\libEGL.dll . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\lib\libEGL.lib . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\bin\libGLESv1_CM.dll . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\lib\libGLESv1_CM.lib . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\bin\libGLESv2.dll . || exit /b 1
copy /y ..\mesa-zink-%MESA_ARCH%\lib\libGLESv2.lib . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-zink-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
mkdir archive-dzn-%MESA_ARCH%
pushd archive-dzn-%MESA_ARCH%
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\vulkan_dzn.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\dzn_icd.%TARGET_ARCH_NAME%.json . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-dzn-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
mkdir archive-mft-%MESA_ARCH%
pushd archive-mft-%MESA_ARCH%
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\msh264enchmft.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\msh265enchmft.dll . || exit /b 1
copy /y ..\mesa-d3d12-%MESA_ARCH%\bin\msav1enchmft.dll . || exit /b 1
%SZIP% a -mx=9 -mqs=on ..\mesa-mft-%MESA_ARCH%-%MESA_VERSION%.7z || exit /b 1
popd
echo MESA_VERSION=%MESA_VERSION%>>"%GITHUB_OUTPUT%"
echo LLVM_VERSION=%LLVM_VERSION%>>"%GITHUB_OUTPUT%"
echo LLVM_RELEASE=%LLVM_RELEASE%>>"%GITHUB_OUTPUT%"
)
echo Done^^!
goto :eof
:get
rem arguments <url> <folder> <sha256>
set URL=%~1
set FILENAME=%~nx1
set FOLDER=%~2
set SHA256=%~3
if exist "%FOLDER%" goto :eof
if not exist "%FILENAME%" (
echo Downloading %FILENAME%
curl.exe -sfLo "%FILENAME%" "%URL%" || exit /b 1
)
echo Checking %FILENAME% sha256
for /f "tokens=*" %%s in ('certutil.exe -hashfile "%FILENAME%" sha256 ^| findstr /v hash') do (
if "%%s" neq "%SHA256%" (
echo SHA256 hash mismatch for %FILENAME%
echo Expected: %SHA256%
echo Actual: %%s
exit /b 1
)
)
echo Unpacking %FILENAME%
tar.exe -xf "%FILENAME%" || exit /b 1
goto :eof