forked from TeamSpen210/HammerAddons
-
Notifications
You must be signed in to change notification settings - Fork 15
/
build.bat
124 lines (105 loc) · 2.98 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
@echo off
SETLOCAL enabledelayedexpansion
SET games=momentum p2ce templategame
SET modes=fgd md
SET "build_dir=build"
SET "build_md_dir=build_md"
SET bin_dir=bin/win64
:: Setup hammer folder copy exclusions (*_momentum, *_p2ce, etc)
SET "robocopy_exclusions=scripts "
FOR %%i in (%games%) do (
CALL SET "game_exclude=*_%%i "
SET "robocopy_exclusions=!robocopy_exclusions!!game_exclude!"
)
SET mode=%1
:: Make sure mode isn't empty by asking the user
:while_mode
IF [%mode%]==[] (echo Modes: %modes% & echo Enter mode. Use ALL to build everything. & SET /P mode= & GOTO :while_mode)
SET game=%2
:: Make sure game isn't empty by asking the user for what game to build
:while_game
IF [%game%]==[] (echo Games: %games% & echo Enter game to build. Use ALL to build every game. & SET /P game= & GOTO :while_game)
IF /I %mode%==ALL (
CALL :build_fgd_cleanup
CALL :build_md_cleanup
GOTO :main_build_step
)
IF /I %mode%==FGD (
CALL :build_fgd_cleanup
GOTO :main_build_step
)
IF /I %mode%==MD (
CALL :build_md_cleanup
GOTO :main_build_step
)
:main_build_step
IF /I %game%==ALL (
:: Modify build directory to not have directories clash
CALL SET "main_build_dir=!build_dir!"
FOR %%i in (%games%) do (
CALL SET "game_build_dir=!main_build_dir!"
SET "build_dir=!game_build_dir!/%%i"
CALL :build %%i
)
EXIT
) ELSE (
FOR %%i in (%games%) do (
IF /I %game%==%%i (
CALL :build %%i
EXIT
)
)
echo Unknown game. Exitting. & EXIT /B 1
)
:build_fgd_cleanup
echo Removing previous FGD build in ./%build_dir%/
rmdir /S /Q "%build_dir%"
EXIT /B
:build_md_cleanup
echo Removing previous markdown build in ./%build_md_dir%/
rmdir /S /Q "%build_md_dir%"
EXIT /B
:build
IF /I %mode%==ALL (
CALL :build_fgd_%%1
CALL :build_game_markdown %1
EXIT /B
)
IF /I %mode%==FGD (
CALL :build_fgd_%%1
EXIT /B
)
IF /I %mode%==MD (
CALL :build_game_markdown %1
)
EXIT /B
:build_fgd_p2ce
CALL :copy_hammer_files p2ce
CALL :build_game_fgd p2ce srctools --extra patch_postcompiler.fgd
EXIT /B
:build_fgd_momentum
CALL :copy_hammer_files momentum
CALL :build_game_fgd momentum
EXIT /B
:build_fgd_templategame
CALL :copy_hammer_files templategame
CALL :build_game_fgd templategame
EXIT /B
:build_game_fgd
echo Building FGD for %1...
mkdir "%build_dir%/%1"
python unify_fgd.py %3 %4 exp %1 %2 -o "%build_dir%/%1/%1.fgd"
IF %ERRORLEVEL% NEQ 0 (echo Building FGD for %1 has failed. Exitting. & EXIT)
EXIT /B
:build_game_markdown
echo Generating markdown from FGD for %1...
mkdir "%build_md_dir%/%1"
python unify_fgd.py expmd %1 -o "%build_md_dir%/%1"
IF %ERRORLEVEL% NEQ 0 (echo Building markdown for %1 has failed. Exitting. & EXIT)
EXIT /B
:copy_hammer_files
echo Copying Hammer files...
robocopy hammer %build_dir%/hammer /S /PURGE /XD %robocopy_exclusions%
IF %ERRORLEVEL% LSS 8 robocopy hammer/cfg_%1 %build_dir%/hammer/cfg /S
IF %ERRORLEVEL% LSS 8 EXIT /B 0
echo Failed copying Hammer files for %1. Exitting. & EXIT