-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.bat
68 lines (56 loc) · 1.61 KB
/
generate.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
@echo off
setlocal
CALL :ARG-PARSER %*
if "%ARG_HELP%" == "1" (
echo Usage: .\generate.bat
echo Parameters:
echo /clean - clean the build folder
echo /open - open the project in Visual Studio
goto :EOF
)
if "%ARG_CLEAN%" == "1" (
echo "Clean build folder"
rmdir /s /q .\build
)
echo "Generate Visual Studio project"
cmake -S . -B build/visualstudio -G "Visual Studio 17 2022"
if "%ARG_OPEN%" == "1" (
echo "Open project"
start .\build\visualstudio\Atakama.sln
)
::*********************************************************
:: Parse commandline arguments into sane variables
:: Based on: https://stackoverflow.com/a/61552059
::*********************************************************
:ARG-PARSER
::Loop until two consecutive empty args
:loopargs
IF "%~1%~2" EQU "" GOTO :EOF
set "arg1=%~1"
set "arg2=%~2"
shift
::Allow either / or -
set "tst1=%arg1:-=/%"
if "%arg1%" NEQ "" (
set "tst1=%tst1:~0,1%"
) ELSE (
set "tst1="
)
set "tst2=%arg2:-=/%"
if "%arg2%" NEQ "" (
set "tst2=%tst2:~0,1%"
) ELSE (
set "tst2="
)
::Capture assignments (eg. /foo bar)
IF "%tst1%" EQU "/" IF "%tst2%" NEQ "/" IF "%tst2%" NEQ "" (
set "ARG_%arg1:~1%=%arg2%"
GOTO loopargs
)
::Capture flags (eg. /foo)
IF "%tst1%" EQU "/" (
set "ARG_%arg1:~1%=1"
GOTO loopargs
)
goto loopargs
GOTO :EOF