2019-02-20 13:22:21 +00:00
|
|
|
@echo OFF
|
2023-08-26 07:27:37 +00:00
|
|
|
setlocal EnableDelayedExpansion
|
|
|
|
|
|
|
|
set script_dir_backslash=%~dp0
|
|
|
|
set script_dir=%script_dir_backslash:~0,-1%
|
2019-02-20 13:22:21 +00:00
|
|
|
|
2021-08-08 23:03:15 +00:00
|
|
|
if not exist Build mkdir Build
|
|
|
|
pushd Build
|
2023-08-25 13:49:03 +00:00
|
|
|
REM Flags ======================================================================================
|
2023-08-26 07:27:37 +00:00
|
|
|
REM MT Static CRT
|
|
|
|
REM EHa- Disable exception handling
|
|
|
|
REM GR- Disable C RTTI
|
|
|
|
REM O2 Optimisation Level 2
|
|
|
|
REM Oi Use CPU Intrinsics
|
|
|
|
REM Z7 Combine multi-debug files to one debug file
|
|
|
|
set common_flags=-D DQN_TEST_WITH_MAIN -I %script_dir% %script_dir%\Misc\dqn_unit_tests.cpp
|
|
|
|
|
2023-08-29 14:14:31 +00:00
|
|
|
set msvc_driver_flags=%common_flags% -MT -EHa -GR- -Od -Oi -Z7 -wd4201 -W4 -nologo
|
2023-08-29 12:35:25 +00:00
|
|
|
|
|
|
|
REM Optionally pass `-analyze` to `msvc_compile_flags` for more checks, but,
|
|
|
|
REM it slows down compilation by around 5s on my old laptop.
|
2023-10-24 13:11:48 +00:00
|
|
|
set msvc_compile_flags=%msvc_driver_flags% -analyze -fsanitize=address /Fe:dqn_unit_tests_msvc
|
2023-08-26 07:27:37 +00:00
|
|
|
set clang_compile_flags=%msvc_driver_flags% -fsanitize=address -fsanitize=undefined /Fe:dqn_unit_tests_clang
|
|
|
|
set zig_compile_flags=%common_flags% -fsanitize=address -fsanitize=undefined -o dqn_unit_tests_zig
|
|
|
|
|
|
|
|
set msvc_link_flags=-link
|
|
|
|
set clang_link_flags=%msvc_link_flags%
|
2021-08-08 22:57:53 +00:00
|
|
|
|
2023-08-26 07:27:37 +00:00
|
|
|
REM msvc =======================================================================================
|
2023-08-26 07:34:02 +00:00
|
|
|
set has_msvc=1
|
|
|
|
where /q cl || set has_msvc=0
|
|
|
|
if %has_msvc% == 1 (
|
|
|
|
echo [BUILD] MSVC's cl detected, compiling ...
|
|
|
|
set msvc_cmd=cl %msvc_compile_flags% %msvc_link_flags%
|
|
|
|
powershell -Command "$time = Measure-Command { !msvc_cmd! | Out-Default }; Write-Host '[BUILD] msvc:'$time.TotalSeconds's'; exit $LASTEXITCODE" || exit /b 1
|
|
|
|
)
|
2021-08-08 22:57:53 +00:00
|
|
|
|
2023-08-26 07:27:37 +00:00
|
|
|
REM REM clang-cl ===================================================================================
|
2023-08-31 12:10:47 +00:00
|
|
|
set has_clang_cl=1
|
|
|
|
where /q clang-cl || set has_clang_cl=0
|
|
|
|
if %has_clang_cl% == 1 (
|
|
|
|
echo [BUILD] clang-cl detected, compiling ...
|
|
|
|
set clang_cmd=clang-cl %clang_compile_flags% %clang_link_flags%
|
|
|
|
powershell -Command "$time = Measure-Command { !clang_cmd! | Out-Default }; Write-Host '[BUILD] clang-cl:'$time.TotalSeconds's'; exit $LASTEXITCODE" || exit /b 1
|
|
|
|
)
|
2023-08-25 14:00:44 +00:00
|
|
|
|
2023-08-26 07:27:37 +00:00
|
|
|
REM zig ========================================================================================
|
|
|
|
REM TODO(doyle):Can't build "Misc\dqn_unit_tests.cpp|1 col 1| error: unable to build C object: FileNotFound"
|
|
|
|
REM set has_zig=1
|
|
|
|
REM where /q zig || set has_zig=0
|
|
|
|
REM if %has_zig% == 1 (
|
|
|
|
REM echo [BUILD] zig detected, compiling ...
|
|
|
|
REM set zig_cmd=zig c++ %zig_compile_flags%
|
|
|
|
REM powershell -Command "$time = Measure-Command { !zig_cmd! | Out-Default }; Write-Host '[BUILD] zig:'$time.TotalSeconds's'; exit $LASTEXITCODE" || exit /b 1
|
|
|
|
REM )
|
2023-08-27 08:07:13 +00:00
|
|
|
|
|
|
|
exit /b 1
|
2019-02-20 13:22:21 +00:00
|
|
|
popd
|