-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildandrun.bat
73 lines (61 loc) · 1.65 KB
/
buildandrun.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
:: Build a project and run it. Previous binary is deleted before building
:: and binaries built by the script are deleted after execution.
:: Runs build and execution in silent mode but in case of error repeats in verbose mode.
:: %1 - full path to project file
:: %2 - config (Debug|Release)
:: %3 - platform (Win32|Win64)
:: %4 - (opt) defines
:: %5 - (opt) binary output path, default: .\ (near proj)
:: © Fr0sT
@ECHO OFF
SETLOCAL
IF .%~1.==.. GOTO :NoParam
IF .%~2.==.. GOTO :NoParam
IF .%~3.==.. GOTO :NoParam
SET CDir=%~dp0%
SET BuildCmd=%CDir%\build.bat
SET Proj=%~1
SET BinaryPath=%~5
IF .%BinaryPath%.==.. SET BinaryPath=.\
SET Binary=%~dp1\%BinaryPath%\%~n1.exe
SET ConfigParam=%2
SET PlatformParam=%3
SET DefinesParam=%4
IF .%DefinesParam%.==.. (
CALL :EchoNoNL %ConfigParam% @ %PlatformParam%...
) ELSE (
CALL :EchoNoNL %ConfigParam% @ %PlatformParam%, defines %DefinesParam%...
)
:: Remove previous binary
DEL "%Binary%" 2> NUL
:: Build silently, in case of error build verbosily, pause and exit
SET Params="Config=%ConfigParam%;Platform=%PlatformParam%;DCC_ExeOutput=%BinaryPath%"
SET Err=
CALL "%BuildCmd%" "%Proj%" %Params% %DefinesParam% > NUL || SET Err=1
IF DEFINED Err (
CALL "%BuildCmd%" "%Proj%" %Params% %DefinesParam%
PAUSE
GOTO :Err
)
:: Execute silently, in case of error execute verbosily, pause and exit
SET Err=
CALL "%Binary%" > NUL || SET Err=1
IF DEFINED Err (
CALL "%Binary%"
PAUSE
GOTO :Err
)
DEL "%Binary%" 2> NUL
ECHO OK
GOTO :EOF
:: ~~~ SUB ~~~
:: Print a line without line feed
:: %* - line to print
:EchoNoNL
SET /p "dummy=%*" < NUL
GOTO :EOF
:NoParam
ECHO Param error!
:Err
DEL "%Binary%" 2> NUL
CMD /C EXIT 1