1+ @ echo off
2+ setlocal EnableExtensions EnableDelayedExpansion
3+
4+ set " HERE = %~dp0 "
5+ set " REPO = %GITHUB_WORKSPACE% "
6+
7+ if not defined REPO (
8+ for /f " delims=" %%i in ('git -C " %HERE% " rev-parse --show-toplevel 2^ > nul ') do set " REPO = %%i "
9+ )
10+
11+ if not defined REPO (
12+ for %%i in (" %HERE% ..\.." ) do set " REPO = %%~fi "
13+ )
14+
15+ if not exist " %HERE% obj\generated\brovvulk_gen.c" (
16+ echo error: generated sources missing. Build the Brovan project first ^ (it runs the code generator^ ). 1 >& 2
17+ exit /b 1
18+ )
19+
20+ if not exist " %HERE% obj\generated\exports.def" (
21+ echo error: generated exports.def missing. 1 >& 2
22+ exit /b 1
23+ )
24+
25+ if not exist " %HERE% bin" mkdir " %HERE% bin"
26+ if not exist " %HERE% obj\build" mkdir " %HERE% obj\build"
27+
28+ where cl > nul 2 >& 1
29+ if errorlevel 1 call :init_msvc
30+ where cl > nul 2 >& 1
31+ if errorlevel 1 (
32+ echo error: cl.exe not found. Run this from a Visual Studio developer environment on GitHub Actions Windows runners. 1 >& 2
33+ exit /b 1
34+ )
35+
36+ pushd " %HERE% "
37+ cl /nologo /O2 /MT /LD vulkan_shim.c /I. /I..\vulkan-headers /Foobj\build\ /Febin\vulkan-1.dll /link /DEF:obj\generated\exports.def /IMPLIB:bin\vulkan-1.lib kernel32.lib
38+ if errorlevel 1 (
39+ popd
40+ exit /b 1
41+ )
42+ popd
43+
44+ echo Deploying vulkan-1.dll:
45+ call :deploy " %REPO% \VirtualFS"
46+
47+ if exist " %REPO% \Brovan\bin" (
48+ for /r " %REPO% \Brovan\bin" %%E in (Brovan.exe) do call :deploy " %%~dpE \VirtualFS"
49+ )
50+
51+ if exist " %REPO% \Brovan.Graphics" (
52+ for /r " %REPO% \Brovan.Graphics" %%E in (Brovan.exe) do call :deploy " %%~dpE \VirtualFS"
53+ )
54+
55+ exit /b 0
56+
57+ :init_msvc
58+ set " VSDEVCMD = "
59+ for %%P in (
60+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsDevCmd.bat"
61+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2022\Professional\Common7\Tools\VsDevCmd.bat"
62+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2022\Community\Common7\Tools\VsDevCmd.bat"
63+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat"
64+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat"
65+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2019\Professional\Common7\Tools\VsDevCmd.bat"
66+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"
67+ " %ProgramFiles(x86)% \Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsDevCmd.bat"
68+ ) do (
69+ if exist %%~P (
70+ set " VSDEVCMD = %%~P "
71+ goto :have_vsdevcmd
72+ )
73+ )
74+
75+ for /f " usebackq delims=" %%P in (`where vswhere.exe 2^ > nul `) do (
76+ for /f " usebackq delims=" %%Q in (`" %%P " -latest -products * -requires Microsoft.Component.MSBuild -find Common7\Tools\VsDevCmd.bat 2^ > nul `) do (
77+ if exist " %%Q " (
78+ set " VSDEVCMD = %%Q "
79+ goto :have_vsdevcmd
80+ )
81+ )
82+ )
83+
84+ exit /b 1
85+
86+ :have_vsdevcmd
87+ call " %VSDEVCMD% " -arch=amd64 -host_arch=amd64 > nul
88+ exit /b 0
89+
90+ :deploy
91+ set " VFS = %~1 \C\Windows\System32"
92+ if not exist " %VFS% " mkdir " %VFS% "
93+ copy /Y " %HERE% bin\vulkan-1.dll" " %VFS% \vulkan-1.dll" > nul
94+ echo deployed -^ > %VFS% \vulkan-1.dll
95+ exit /b 0
0 commit comments