Repository navigation
Expand file tree
/
Copy pathautotest.bat
More file actions
138 lines (120 loc) · 4.46 KB
/
Copy pathautotest.bat
File metadata and controls
138 lines (120 loc) · 4.46 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
@echo off
setlocal enabledelayedexpansion
cd /d "%~dp0"
echo shell log - autotest start
echo %cd%
:: Initialize MSVC environment if cl.exe is not available
where cl >nul 2>&1
if %errorlevel% neq 0 (
echo ----Setting up MSVC environment----
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if exist "!VSWHERE!" (
for /f "usebackq delims=" %%i in (`"!VSWHERE!" -latest -property installationPath`) do (
set "VCVARS=%%i\VC\Auxiliary\Build\vcvars64.bat"
if exist "!VCVARS!" (
call "!VCVARS!"
goto :env_ready
)
)
)
for %%p in ("%ProgramFiles%" "%ProgramFiles(x86)%") do (
for %%v in (2022 2019) do (
for %%e in (Enterprise Professional Community BuildTools) do (
set "VCVARS=%%~p\Microsoft Visual Studio\%%v\%%e\VC\Auxiliary\Build\vcvars64.bat"
if exist "!VCVARS!" (
call "!VCVARS!"
goto :env_ready
)
)
)
)
echo ERROR: Could not find Visual Studio installation.
exit /b 1
)
:env_ready
set COMPLIE_RESULT=true
set WORKSPACE=%cd%
set "BACKEND_ARG=%~1"
echo shell log - BACKEND_ARG: [%BACKEND_ARG%]
:: Determine cmake args and target suffix based on BACKEND_ARG
set "CMAKE_BACKEND_ARGS="
set "TARGET_SUFFIX="
if /I "%BACKEND_ARG%"=="USE_OPENGL_SWIFTSHADER" (
set "CMAKE_BACKEND_ARGS=-DTGFX_USE_SWIFTSHADER=ON"
set "TARGET_SUFFIX=OpenGL"
)
if /I "%BACKEND_ARG%"=="USE_VULKAN_SWIFTSHADER" (
set "CMAKE_BACKEND_ARGS=-DTGFX_USE_VULKAN=ON -DTGFX_USE_SWIFTSHADER=ON"
set "TARGET_SUFFIX=Vulkan"
)
if /I "%BACKEND_ARG%"=="USE_VULKAN" (
set "CMAKE_BACKEND_ARGS=-DTGFX_USE_VULKAN=ON"
set "TARGET_SUFFIX=Vulkan"
)
if /I "%BACKEND_ARG%"=="USE_OPENGL" (
set "CMAKE_BACKEND_ARGS="
set "TARGET_SUFFIX=OpenGL"
)
if /I "%BACKEND_ARG%"=="USE_D3D12" (
set "CMAKE_BACKEND_ARGS=-DTGFX_USE_D3D12=ON"
set "TARGET_SUFFIX=D3D12"
)
if /I "%BACKEND_ARG%"=="USE_D3D12_WARP" (
set "CMAKE_BACKEND_ARGS=-DTGFX_USE_D3D12=ON -DTGFX_D3D12_USE_WARP=ON"
set "TARGET_SUFFIX=D3D12"
)
if "%TARGET_SUFFIX%"=="" (
echo ERROR: Unsupported backend argument: %BACKEND_ARG%
echo Supported: USE_OPENGL, USE_OPENGL_SWIFTSHADER, USE_VULKAN, USE_VULKAN_SWIFTSHADER, USE_D3D12, USE_D3D12_WARP
exit /b 1
)
echo shell log - CMAKE_BACKEND_ARGS: [%CMAKE_BACKEND_ARGS%]
echo shell log - TARGET_SUFFIX: [%TARGET_SUFFIX%]
:: NOTE: Do NOT call update_baseline.bat here. It uses git switch which changes files on disk,
:: and cmd.exe reads bat files line-by-line from disk, causing offset corruption after switch.
:: Run update_baseline.bat as a separate step (CI) or a separate cmd invocation (local) before
:: running this script.
:: Clean and create directories
if exist result rd /s /q result
mkdir result
if exist build rd /s /q build
mkdir build
cd build
:: Configure CMake with Ninja
cmake -G Ninja %CMAKE_BACKEND_ARGS% -DTGFX_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release ..
if %errorlevel% equ 0 (
echo ~~~~~~~~~~~~~~~~~~~CMakeLists OK~~~~~~~~~~~~~~~~~~
) else (
echo ~~~~~~~~~~~~~~~~~~~CMakeLists error~~~~~~~~~~~~~~~~~~
exit /b 1
)
:: Build
cmake --build . --target TGFXFullTest_%TARGET_SUFFIX%
if %errorlevel% equ 0 (
echo ~~~~~~~~~~~~~~~~~~~TGFXFullTest_%TARGET_SUFFIX% make successed~~~~~~~~~~~~~~~~~~
) else (
echo ~~~~~~~~~~~~~~~~~~~TGFXFullTest_%TARGET_SUFFIX% make error~~~~~~~~~~~~~~~~~~
exit /b 1
)
:: Copy SwiftShader DLLs to build directory if needed
if /I "%BACKEND_ARG%"=="USE_OPENGL_SWIFTSHADER" (
copy /y "%WORKSPACE%\vendor\swiftshader\win\x64\*.dll" "%WORKSPACE%\build\" >nul 2>&1
)
:: Rename SwiftShader to vulkan-1.dll so volk loads it directly (volk uses
:: LoadLibrary("vulkan-1.dll") on Windows, dlopen("libvulkan.dylib") on macOS).
if /I "%BACKEND_ARG%"=="USE_VULKAN_SWIFTSHADER" copy /y "%WORKSPACE%\vendor\swiftshader\win\x64\vk_swiftshader.dll" "%WORKSPACE%\build\vulkan-1.dll" >nul 2>&1
:: Run tests
TGFXFullTest_%TARGET_SUFFIX%.exe --gtest_output=json:TGFXFullTest.json
if %errorlevel% equ 0 (
echo ~~~~~~~~~~~~~~~~~~~TGFXFullTest_%TARGET_SUFFIX% successed~~~~~~~~~~~~~~~~~~
) else (
echo ~~~~~~~~~~~~~~~~~~~TGFXFullTest_%TARGET_SUFFIX% Failed~~~~~~~~~~~~~~~~~~
set COMPLIE_RESULT=false
)
:: Copy results
copy /y "%WORKSPACE%\build\*.json" "%WORKSPACE%\result\" >nul 2>&1
cd ..
xcopy /s /e /i /q "%WORKSPACE%\test\out" "%WORKSPACE%\result\out" >nul 2>&1
if "!COMPLIE_RESULT!"=="false" (
exit /b 1
)