-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
executable file
·76 lines (60 loc) · 1.54 KB
/
build.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
:: Copyright 2024 GlitchyByte
:: SPDX-License-Identifier: MIT-0
:: Builds project.
:: [Setup]
@echo off
setlocal enabledelayedexpansion
set "calling_dir=%CD%"
set "script_dir=%~dp0"
cd /d "%script_dir%"
:: [Main]
goto afterFuncs
:: Usage.
:printUsage
echo Usage: build [Debug^|Release^|MinSizeRel^|RelWithDebInfo] [clean]
cd /d "%calling_dir%"
exit /b 1
:afterFuncs
:: Accept 1 or more parameters.
if "%~1"=="" goto printUsage
:: If there is more than 1 parameter, the 2nd must be "clean".
if not "%~2"=="" (
if /i "%~2"=="clean" (
set "clean=yes"
) else (
goto printUsage
)
) else (
set "clean=no"
)
:: Capture valid flavor.
set "flavor=%~1"
if /i not "%flavor%"=="Debug" if /i not "%flavor%"=="Release" if /i not "%flavor%"=="MinSizeRel" if /i not "%flavor%"=="RelWithDebInfo" (
goto printUsage
)
:: Dir constants.
cd /d "%script_dir%\code"
set "buildConfigDir=build\build.cmake"
set "binDir=build\bin"
:: Make sure build dir exists.
if not exist "build" mkdir "build"
if "%clean%"=="yes" (
echo Refreshing configuration...
:: Remove build dir.
if exist "%buildConfigDir%" rmdir /s /q "%buildConfigDir%"
:: Clean bin dir.
if exist "%binDir%" (
rmdir /s /q "%binDir%"
mkdir "%binDir%"
)
)
:: Configure.
echo Configuring: !flavor!
cmake -DCMAKE_BUILD_TYPE=!flavor! -B "%buildConfigDir%" -S .
:: Build.
echo Building: !flavor!
cmake --build "%buildConfigDir%" --config %flavor% --parallel
:: [Teardown]
cd /d "%calling_dir%"
:: Done!
echo Build done!