2016-07-07 21:47:33 +01:00
|
|
|
@echo off
|
|
|
|
|
|
2021-04-25 22:09:22 +01:00
|
|
|
setlocal EnableDelayedExpansion
|
|
|
|
|
|
2022-11-26 11:48:09 -05:00
|
|
|
where /Q cl.exe || (
|
2023-06-13 13:21:15 +01:00
|
|
|
set __VSCMD_ARG_NO_LOGO=1
|
|
|
|
|
for /f "tokens=*" %%i in ('"C:\Program Files (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
|
|
|
|
|
)
|
|
|
|
|
call "!VS!\VC\Auxiliary\Build\vcvarsall.bat" amd64 || exit /b 1
|
2022-11-26 11:48:09 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if "%VSCMD_ARG_TGT_ARCH%" neq "x64" (
|
2023-06-13 13:21:15 +01:00
|
|
|
if "%ODIN_IGNORE_MSVC_CHECK%" == "" (
|
|
|
|
|
echo ERROR: please run this from MSVC x64 native tools command prompt, 32-bit target is not supported!
|
|
|
|
|
exit /b 1
|
|
|
|
|
)
|
2022-11-26 11:48:09 -05:00
|
|
|
)
|
|
|
|
|
|
2021-04-28 11:56:47 +01:00
|
|
|
for /f "usebackq tokens=1,2 delims=,=- " %%i in (`wmic os get LocalDateTime /value`) do @if %%i==LocalDateTime (
|
2021-09-14 17:54:50 +01:00
|
|
|
set CURR_DATE_TIME=%%j
|
2021-04-28 11:56:47 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set curr_year=%CURR_DATE_TIME:~0,4%
|
|
|
|
|
set curr_month=%CURR_DATE_TIME:~4,2%
|
2021-04-25 22:09:22 +01:00
|
|
|
|
2016-07-07 21:47:33 +01:00
|
|
|
:: Make sure this is a decent name and not generic
|
|
|
|
|
set exe_name=odin.exe
|
|
|
|
|
|
|
|
|
|
:: Debug = 0, Release = 1
|
2019-12-22 11:19:42 +01:00
|
|
|
if "%1" == "1" (
|
|
|
|
|
set release_mode=1
|
|
|
|
|
) else if "%1" == "release" (
|
|
|
|
|
set release_mode=1
|
|
|
|
|
) else (
|
2020-06-23 09:20:13 +01:00
|
|
|
set release_mode=0
|
2019-12-22 11:19:42 +01:00
|
|
|
)
|
|
|
|
|
|
2020-08-23 15:25:19 +02:00
|
|
|
:: Normal = 0, CI Nightly = 1
|
|
|
|
|
if "%2" == "1" (
|
2021-09-14 17:54:50 +01:00
|
|
|
set nightly=1
|
2020-08-23 15:25:19 +02:00
|
|
|
) else (
|
2021-09-14 17:54:50 +01:00
|
|
|
set nightly=0
|
2020-08-23 15:25:19 +02:00
|
|
|
)
|
|
|
|
|
|
2021-04-25 22:09:22 +01:00
|
|
|
set odin_version_raw="dev-%curr_year%-%curr_month%"
|
|
|
|
|
|
2020-01-04 10:59:12 +00:00
|
|
|
set compiler_flags= -nologo -Oi -TP -fp:precise -Gm- -MP -FC -EHsc- -GR- -GF
|
2021-04-25 22:10:52 +01:00
|
|
|
set compiler_defines= -DODIN_VERSION_RAW=\"%odin_version_raw%\"
|
2020-03-19 15:14:31 +00:00
|
|
|
|
2023-04-11 11:55:29 +02:00
|
|
|
if not exist .git\ goto skip_git_hash
|
2023-07-31 17:18:06 +03:00
|
|
|
for /f "tokens=1,2" %%i IN ('git show "--pretty=%%cd %%h" "--date=format:%%Y-%%m" --no-patch --no-notes HEAD') do (
|
2023-07-31 17:46:45 +03:00
|
|
|
set odin_version_raw=dev-%%i
|
2023-07-31 17:18:06 +03:00
|
|
|
set GIT_SHA=%%j
|
|
|
|
|
)
|
2020-08-23 15:25:19 +02:00
|
|
|
if %ERRORLEVEL% equ 0 set compiler_defines=%compiler_defines% -DGIT_SHA=\"%GIT_SHA%\"
|
2023-04-11 11:55:29 +02:00
|
|
|
:skip_git_hash
|
|
|
|
|
|
2020-08-23 15:25:19 +02:00
|
|
|
if %nightly% equ 1 set compiler_defines=%compiler_defines% -DNIGHTLY
|
2016-07-07 21:47:33 +01:00
|
|
|
|
|
|
|
|
if %release_mode% EQU 0 ( rem Debug
|
2019-09-02 21:16:17 +01:00
|
|
|
set compiler_flags=%compiler_flags% -Od -MDd -Z7
|
2016-07-07 21:47:33 +01:00
|
|
|
) else ( rem Release
|
2020-03-19 15:30:10 +00:00
|
|
|
set compiler_flags=%compiler_flags% -O2 -MT -Z7
|
|
|
|
|
set compiler_defines=%compiler_defines% -DNO_ARRAY_BOUNDS_CHECK
|
2016-07-07 21:47:33 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
set compiler_warnings= ^
|
2016-12-16 11:31:08 +00:00
|
|
|
-W4 -WX ^
|
2021-08-19 15:43:51 +01:00
|
|
|
-wd4100 -wd4101 -wd4127 -wd4146 ^
|
2022-12-18 22:49:10 +00:00
|
|
|
-wd4505 ^
|
2021-08-19 15:43:51 +01:00
|
|
|
-wd4456 -wd4457
|
2016-07-07 21:47:33 +01:00
|
|
|
|
2021-09-11 17:06:29 +01:00
|
|
|
set compiler_includes= ^
|
|
|
|
|
/Isrc\
|
2016-10-31 00:10:31 +00:00
|
|
|
set libs= ^
|
2020-02-01 22:50:57 +00:00
|
|
|
kernel32.lib ^
|
2022-12-28 21:52:41 -08:00
|
|
|
Synchronization.lib ^
|
2023-08-03 13:16:23 +01:00
|
|
|
bin\llvm\windows\LLVM-C.lib
|
|
|
|
|
|
|
|
|
|
set tilde_backend=0
|
|
|
|
|
if %tilde_backend% EQU 1 (
|
|
|
|
|
set libs=%libs% src\tilde\tb.lib
|
|
|
|
|
set compiler_defines=%compiler_defines% -DODIN_TILDE_BACKEND
|
|
|
|
|
)
|
|
|
|
|
|
2016-07-07 21:47:33 +01:00
|
|
|
|
|
|
|
|
set linker_flags= -incremental:no -opt:ref -subsystem:console
|
|
|
|
|
|
2016-08-25 00:23:04 +01:00
|
|
|
if %release_mode% EQU 0 ( rem Debug
|
2022-07-08 21:48:33 +02:00
|
|
|
set linker_flags=%linker_flags% -debug /NATVIS:src\odin_compiler.natvis
|
2016-08-25 00:23:04 +01:00
|
|
|
) else ( rem Release
|
2016-10-06 17:11:17 +01:00
|
|
|
set linker_flags=%linker_flags% -debug
|
2016-08-25 00:23:04 +01:00
|
|
|
)
|
2016-07-07 21:47:33 +01:00
|
|
|
|
2020-03-19 15:14:31 +00:00
|
|
|
set compiler_settings=%compiler_includes% %compiler_flags% %compiler_warnings% %compiler_defines%
|
2016-07-07 21:47:33 +01:00
|
|
|
set linker_settings=%libs% %linker_flags%
|
|
|
|
|
|
2016-12-16 11:31:08 +00:00
|
|
|
del *.pdb > NUL 2> NUL
|
|
|
|
|
del *.ilk > NUL 2> NUL
|
2016-07-07 21:47:33 +01:00
|
|
|
|
2021-11-09 22:11:18 +00:00
|
|
|
cl %compiler_settings% "src\main.cpp" "src\libtommath.cpp" /link %linker_settings% -OUT:%exe_name%
|
|
|
|
|
if %errorlevel% neq 0 goto end_of_build
|
2020-08-23 15:25:19 +02:00
|
|
|
|
2022-09-08 17:18:54 +01:00
|
|
|
call build_vendor.bat
|
|
|
|
|
if %errorlevel% neq 0 goto end_of_build
|
2021-09-14 17:54:50 +01:00
|
|
|
|
2022-09-08 17:18:54 +01:00
|
|
|
if %release_mode% EQU 0 odin run examples/demo
|
2020-02-01 22:50:57 +00:00
|
|
|
|
2017-03-05 21:22:33 +00:00
|
|
|
del *.obj > NUL 2> NUL
|
2017-01-04 11:24:32 +00:00
|
|
|
|
2022-12-28 21:52:41 -08:00
|
|
|
:end_of_build
|