112 lines
3.4 KiB
Batchfile
112 lines
3.4 KiB
Batchfile
@echo off
|
|
setlocal
|
|
|
|
:: Description of build options:
|
|
::
|
|
:: - Configuration
|
|
:: 1. debug: The target is intended to run in a debugger
|
|
:: 3. profiling: The target is compiled with optimizations, debug info, and profiler timing info
|
|
:: 2. release: The target is compiled with optimizations and no debug info
|
|
::
|
|
:: - Platform
|
|
:: 1. developer: The target will include all developer tooling
|
|
:: 2. user: The target will not include any developer tooling
|
|
|
|
where /q cmake || (
|
|
echo ERROR: "cmake" not found - please install it and add the executable to your path
|
|
exit /b 1
|
|
)
|
|
|
|
where /q clang.exe || (
|
|
echo ERROR: "clang.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
|
exit /b 1
|
|
)
|
|
|
|
if "%Platform%" neq "x64" (
|
|
echo ERROR: Platform is not "x64" - please run this from the MSVC x64 native tools command prompt.
|
|
exit /b 1
|
|
)
|
|
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
:: Configuration
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
set config_default=-DRTC=0 -DCRTLIB=0 -DDEBINFO=0 -DDEVELOPER=0 -DPROFILING=0 -DUNOPTIMIZED=0
|
|
|
|
:: Arg1 -> compiler options mappings
|
|
set config1_debug=-DRTC=1 -DCRTLIB=1 -DDEBINFO=1 -DUNOPTIMIZED=1
|
|
set config1_profiling=-DPROFILING=1 -DCRTLIB=1 -DDEBINFO=1
|
|
set config1_release=
|
|
|
|
:: Arg2 -> compiler options mappings
|
|
set config2_developer=-DDEVELOPER=1
|
|
set config2_user=
|
|
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
:: Check args
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
set argerror=false
|
|
|
|
:: Check arg 1
|
|
set arg_config=%1%
|
|
if /I "%arg_config%" neq "debug" (
|
|
if /I "%arg_config%" neq "profiling" (
|
|
if /I "%arg_config%" neq "release" (
|
|
echo ERROR: must specify either 'debug', 'release', or 'profiling' as first argument
|
|
set argerror=true
|
|
)
|
|
)
|
|
)
|
|
|
|
:: Check arg 2
|
|
set arg_platform=%2%
|
|
if /I "%arg_platform%" neq "developer" (
|
|
if /I "%arg_platform%" neq "user" (
|
|
echo ERROR: must specify either 'developer' or 'user' as second argument
|
|
set argerror=true
|
|
)
|
|
)
|
|
|
|
:: Exit if error
|
|
if %argerror% neq false (
|
|
exit /b 1
|
|
)
|
|
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
:: Choose configuration from args
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
set opt_config1=
|
|
if "%arg_config%" equ "debug" set opt_config1=%config1_debug%
|
|
if "%arg_config%" equ "profiling" set opt_config1=%config1_profiling%
|
|
if "%arg_config%" equ "release" set opt_config1=%config1_release%
|
|
|
|
set opt_config2=
|
|
if "%arg_platform%" equ "developer" set opt_config2=%config2_developer%
|
|
if "%arg_platform%" equ "user" set opt_config2=%config2_user%
|
|
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
:: Build
|
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
|
|
if not exist "build" mkdir build
|
|
|
|
echo Calling cmake with options: %opt_config1% %opt_config2%
|
|
|
|
:: https://stackoverflow.com/a/46593308
|
|
cmake -H. -G Ninja -B build %config_default% %opt_config1% %opt_config2%^
|
|
-DCMAKE_C_COMPILER:PATH="clang.exe"^
|
|
-DCMAKE_CXX_COMPILER:PATH="clang.exe"^
|
|
-DCMAKE_C_COMPILER_ID="Clang"^
|
|
-DCMAKE_CXX_COMPILER_ID="Clang"^
|
|
-DCMAKE_SYSTEM_NAME="Generic"^
|
|
-DPLATFORM_WIN32=1
|
|
|
|
if NOT %errorlevel% == 0 exit /b 1
|
|
|
|
cmake --build build
|
|
@REM cmake --build build -v
|
|
|
|
exit /b %errorlevel%
|