Update networking layer w/ CURL and emscripten impl
This commit is contained in:
@@ -7,55 +7,59 @@ set build_dir=%script_dir%\Build
|
||||
|
||||
if not exist %build_dir% mkdir %build_dir%
|
||||
pushd %build_dir%
|
||||
REM Flags ======================================================================================
|
||||
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 DN_UNIT_TESTS_WITH_KECCAK %script_dir%\Source\Extra\dn_tests_main.cpp
|
||||
set msvc_driver_flags=%common_flags% -MT -EHa -GR- -Od -Oi -Z7 -wd4201 -W4 -nologo
|
||||
|
||||
REM Optionally pass `-analyze` to `msvc_compile_flags` for more checks, but,
|
||||
REM it slows down compilation by around 5s on my old laptop.
|
||||
set msvc_compile_flags=%msvc_driver_flags% -analyze -fsanitize=address /Fe:dn_unit_tests_msvc
|
||||
set clang_compile_flags=%msvc_driver_flags% -fsanitize=address -fsanitize=undefined /Fe:dn_unit_tests_clang
|
||||
set zig_compile_flags=%common_flags% -fsanitize=address -fsanitize=undefined -o dn_unit_tests_zig
|
||||
:: Build CURL if we can and incorporate it into the compile flags
|
||||
where /q cmake && (
|
||||
if not exist %build_dir%/Curl/Install/lib/libcurl-d.lib (
|
||||
cmake -B %build_dir%/Curl ^
|
||||
-S %script_dir%/External/curl-8.17.0 ^
|
||||
-G Ninja ^
|
||||
-D BUILD_SHARED_LIBS=OFF ^
|
||||
-D BUILD_STATIC_LIBS=ON ^
|
||||
-D BUILD_CURL_EXE=OFF ^
|
||||
-D BUILD_LIBCURL_DOCS=OFF ^
|
||||
-D BUILD_MISC_DOCS=OFF ^
|
||||
-D ENABLE_CURL_MANUAL=OFF ^
|
||||
-D CURL_USE_SCHANNEL=ON ^
|
||||
-D CURL_USE_LIBPSL=OFF ^
|
||||
-D CURL_STATIC_CRT=ON ^
|
||||
-D CMAKE_INSTALL_PREFIX=%build_dir%/Curl/Install
|
||||
|
||||
set msvc_link_flags=-link
|
||||
set clang_link_flags=%msvc_link_flags%
|
||||
|
||||
REM msvc =======================================================================================
|
||||
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
|
||||
call cl %script_dir%\single_header_generator.cpp -Z7 -nologo -link
|
||||
call %build_dir%\single_header_generator.exe %script_dir%\Source %script_dir%\Single_Header
|
||||
cmake --build %build_dir%/Curl --parallel --target install
|
||||
)
|
||||
)
|
||||
|
||||
:: MT Static CRT
|
||||
:: EHa- Disable exception handling
|
||||
:: GR- Disable C RTTI
|
||||
:: Oi Use CPU Intrinsics
|
||||
:: Z7 Combine multi-debug files to one debug file
|
||||
set flags=%flags% -D DN_UNIT_TESTS_WITH_KECCAK %script_dir%\Source\Extra\dn_tests_main.cpp
|
||||
set msvc_driver_flags=-EHa -GR- -Od -Oi -Z7 -wd4201 -W4 -nologo %flags% -fsanitize=address
|
||||
|
||||
REM REM clang-cl ===================================================================================
|
||||
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
|
||||
where /q emcc && (
|
||||
echo [BUILD] Emscripten emcc detected, compiling ...
|
||||
call emcc -g -msimd128 -msse2 %flags% -o %build_dir%\dn_unit_tests_emcc.js -s FETCH=1 -pthread -s ASYNCIFY=1 -lwebsocket -Wall
|
||||
)
|
||||
|
||||
where /q cl && (
|
||||
echo [BUILD] MSVC cl detected, compiling ...
|
||||
set msvc_cmd=cl -MTd %msvc_driver_flags% -analyze -Fe:dn_unit_tests_msvc -Fo:dn_unit_tests_msvc
|
||||
if exist %build_dir%/Curl/Install/lib/libcurl-d.lib (
|
||||
set msvc_cmd=!msvc_cmd! -D DN_UNIT_TESTS_WITH_CURL -I %build_dir%/Curl/Install/include %build_dir%/Curl/Install/lib/libcurl-d.lib crypt32.lib ws2_32.lib advapi32.lib wldap32.lib iphlpapi.lib secur32.lib
|
||||
)
|
||||
set msvc_cmd=!msvc_cmd! -link
|
||||
|
||||
REM zig ========================================================================================
|
||||
REM TODO(doyle):Can't build "Misc\dn_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 )
|
||||
powershell -Command "$time = Measure-Command { !msvc_cmd! | Out-Default }; Write-Host '[BUILD] msvc:'$time.TotalSeconds's'; exit $LASTEXITCODE" || exit /b 1
|
||||
call cl %script_dir%\single_header_generator.cpp -Z7 -nologo -link
|
||||
call %build_dir%\single_header_generator.exe %script_dir%\Source %script_dir%\Single-Header
|
||||
)
|
||||
|
||||
exit /b 1
|
||||
where /q clang-cl && (
|
||||
echo [BUILD] LLVM clang-cl detected, compiling ...
|
||||
set clang_cmd=clang-cl -MT %msvc_driver_flags% -fsanitize=undefined -Fe:dn_unit_tests_clang -link
|
||||
powershell -Command "$time = Measure-Command { !clang_cmd! | Out-Default }; Write-Host '[BUILD] clang-cl:'$time.TotalSeconds's'; exit $LASTEXITCODE" || exit /b 1
|
||||
)
|
||||
|
||||
exit /b 1
|
||||
popd
|
||||
|
||||
Reference in New Issue
Block a user