cleaner & order independent build.bat arg usage
This commit is contained in:
parent
4a371eb3b9
commit
99f0414261
136
build.bat
136
build.bat
@ -1,93 +1,38 @@
|
|||||||
@echo off
|
@echo off
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
:: Description of build options:
|
:: Description of command line arguments (disabled by default):
|
||||||
::
|
:: "debug" The target is intended to run in a debugger with debug info and optimizations disabled
|
||||||
:: - Configuration
|
:: "developer" The target will include all developer tooling
|
||||||
:: 1. debug: The target is intended to run in a debugger
|
:: "profiling" The target will be compiled with profiling markup
|
||||||
:: 2. debug_asan: The target is intended to run in a debugger with address sanitization enabled
|
:: "asan" The target will compile with address sanitizer enabled
|
||||||
:: 3. profiling: The target is compiled with optimizations, debug info, and profiler timing info
|
|
||||||
:: 4. 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
|
|
||||||
|
|
||||||
echo ---------------
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
where /q cmake || (
|
:: Verify environment
|
||||||
echo ERROR: "cmake" not found - please install it and add the executable to your path
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
|
if "%Platform%" neq "x64" (
|
||||||
|
echo ERROR: Platform is not "x64" - please run this from the MSVC x64 native tools command prompt.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
where /q clang.exe || (
|
where /q clang.exe || (
|
||||||
echo ERROR: "clang.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
echo ERROR: "clang.exe" not found.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
clang -v
|
|
||||||
echo ---------------
|
|
||||||
|
|
||||||
where /q lld-link || (
|
where /q lld-link || (
|
||||||
echo ERROR: "lld-link.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
echo ERROR: "lld-link.exe" not found.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo lld-link version
|
|
||||||
lld-link --version
|
|
||||||
echo ---------------
|
|
||||||
|
|
||||||
where /q ninja.exe || (
|
where /q ninja.exe || (
|
||||||
echo ERROR: "ninja.exe" not found - please run this from the MSVC x64 native tools command prompt.
|
echo ERROR: "ninja.exe" not found.
|
||||||
exit /b 1
|
exit /b 1
|
||||||
)
|
)
|
||||||
echo ninja version
|
|
||||||
ninja --version
|
|
||||||
echo ---------------
|
|
||||||
|
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
where /q cmake || (
|
||||||
:: Configuration
|
echo ERROR: "cmake.exe" not found.
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
||||||
|
|
||||||
set config_default=-DRTC=0 -DASAN=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_debug_asan=%config1_debug% -DASAN=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 "debug_asan" (
|
|
||||||
if /I "%arg_config%" neq "profiling" (
|
|
||||||
if /I "%arg_config%" neq "release" (
|
|
||||||
echo ERROR: must specify either 'debug', 'debug_asan', 'profiling', or 'release' 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
|
exit /b 1
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -95,15 +40,41 @@ if %argerror% neq false (
|
|||||||
:: Choose configuration from args
|
:: Choose configuration from args
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
|
|
||||||
set opt_config1=
|
:: Must explicitly pass disabled CMake options or else missing options are
|
||||||
if "%arg_config%" equ "debug" set opt_config1=%config1_debug%
|
:: assumed to be equal to the value from the last build
|
||||||
if "%arg_config%" equ "debug_asan" set opt_config1=%config1_debug_asan%
|
set cmake_options_zero=-DRTC=0 -DASAN=0 -DCRTLIB=0 -DDEBINFO=0 -DDEVELOPER=0 -DPROFILING=0 -DUNOPTIMIZED=0
|
||||||
if "%arg_config%" equ "profiling" set opt_config1=%config1_profiling%
|
|
||||||
if "%arg_config%" equ "release" set opt_config1=%config1_release%
|
|
||||||
|
|
||||||
set opt_config2=
|
set cmake_options_enabled=
|
||||||
if "%arg_platform%" equ "developer" set opt_config2=%config2_developer%
|
|
||||||
if "%arg_platform%" equ "user" set opt_config2=%config2_user%
|
echo ========================================
|
||||||
|
|
||||||
|
for %%a in (%*) do set "%%a=1"
|
||||||
|
|
||||||
|
if "%debug%" == "1" (
|
||||||
|
echo [Debug build]
|
||||||
|
set cmake_options_enabled=%cmake_options_enabled% -DRTC=1 -DCRTLIB=1 -DDEBINFO=1 -DUNOPTIMIZED=1
|
||||||
|
) else (
|
||||||
|
echo [Release build]
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%developer%" == "1" (
|
||||||
|
echo [Developer build]
|
||||||
|
set cmake_options_enabled=%cmake_options_enabled% -DDEVELOPER=1
|
||||||
|
) else (
|
||||||
|
echo [User build]
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%profiling%" == "1" (
|
||||||
|
echo [Profiling enabled]
|
||||||
|
set cmake_options_enabled=%cmake_options_enabled% -DPROFILING=1 -DCRTLIB=1 -DDEBINFO=1
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%asan%" == "1" (
|
||||||
|
echo [Address sanitizer enabled]
|
||||||
|
set cmake_options_enabled=%cmake_options_enabled% -DASAN=1 -DCRTLIB=1 -DDEBINFO=1
|
||||||
|
)
|
||||||
|
|
||||||
|
echo ========================================
|
||||||
|
|
||||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||||
:: Build
|
:: Build
|
||||||
@ -111,10 +82,7 @@ if "%arg_platform%" equ "user" set opt_config2=%config2_user%
|
|||||||
|
|
||||||
if not exist "build" mkdir build
|
if not exist "build" mkdir build
|
||||||
|
|
||||||
echo Calling cmake with options: %opt_config1% %opt_config2%
|
cmake -H. -G Ninja -B build %cmake_options_zero% %cmake_options_enabled%^
|
||||||
|
|
||||||
:: https://stackoverflow.com/a/46593308
|
|
||||||
cmake -H. -G Ninja -B build %config_default% %opt_config1% %opt_config2%^
|
|
||||||
-DCMAKE_C_COMPILER:PATH="clang.exe"^
|
-DCMAKE_C_COMPILER:PATH="clang.exe"^
|
||||||
-DCMAKE_CXX_COMPILER:PATH="clang.exe"^
|
-DCMAKE_CXX_COMPILER:PATH="clang.exe"^
|
||||||
-DCMAKE_C_COMPILER_ID="Clang"^
|
-DCMAKE_C_COMPILER_ID="Clang"^
|
||||||
@ -125,6 +93,6 @@ cmake -H. -G Ninja -B build %config_default% %opt_config1% %opt_config2%^
|
|||||||
if NOT %errorlevel% == 0 exit /b 1
|
if NOT %errorlevel% == 0 exit /b 1
|
||||||
|
|
||||||
cmake --build build
|
cmake --build build
|
||||||
@REM cmake --build build -v
|
:: cmake --build build -v
|
||||||
|
|
||||||
exit /b %errorlevel%
|
exit /b %errorlevel%
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user