-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.bat
238 lines (196 loc) · 4.65 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
@echo off
setlocal
set my_name=%~n0
set my_dir="%~dp0"
set "my_dir=%my_dir:~1,-2%"
set /a prog=0
set /a cln=0
set /a verbose=0
set /a DP_FLAG=1
set /a EP_FLAG=2
set /a debug=0
set /a release=0
set /a bitness=64
set /a debug_print=EP_FLAG
set /a pdb=0
set /a rtl=0
set platform=x64
set configuration=Debug
set pts=v142
set prog_proj=talk.vcxproj
GOTO :ParseParams
:ParseParams
IF [%1]==[] GOTO main
if [%1]==[/?] goto help
if [%1]==[/h] goto help
if [%1]==[/help] goto help
IF /i "%~1"=="/talk" (
SET /a prog=1
goto reParseParams
)
IF /i "%~1"=="/cln" (
SET /a cln=1
goto reParseParams
)
IF /i "%~1"=="/d" (
SET /a debug=1
goto reParseParams
)
IF /i "%~1"=="/r" (
SET /a release=1
goto reParseParams
)
:: print flags
IF /i "%~1"=="/dp" (
SET /a "debug_print=%~2"
SHIFT
goto reParseParams
)
IF /i "%~1"=="/dpf" (
SET /a "debug_print=%debug_print%|DP_FLAG"
goto reParseParams
)
IF /i "%~1"=="/epf" (
set /a "debug_print=%debug_print%|EP_FLAG"
goto reParseParams
)
IF /i "%~1"=="/pdb" (
SET /a pdb=1
goto reParseParams
)
IF /i "%~1"=="/rtl" (
SET /a rtl=1
goto reParseParams
)
IF /i "%~1"=="/pts" (
SET pts=%~2
SHIFT
goto reParseParams
)
IF /i "%~1"=="/b" (
SET /a bitness=%~2
SHIFT
goto reParseParams
)
IF /i "%~1"=="/v" (
SET /a verbose=1
goto reParseParams
) ELSE (
echo Unknown option : "%~1"
)
:reParseParams
SHIFT
if [%1]==[] goto main
GOTO :ParseParams
:main
set /a "s=%debug%+%release%"
if %s% == 0 (
set /a debug=0
set /a release=1
)
set platform=
if %bitness% == 64 (
set platform=x64
)
if %bitness% == 32 (
set platform=x86
)
if [%platform%] EQU [] (
echo ERROR: Bitness /b has to be 32 or 64!
EXIT /B 1
)
set /a "s=%prog%+%cln%"
if %s% == 0 (
set /a prog=1
)
if %verbose% == 1 (
echo prog: %prog%
echo cln: %cln%
echo.
echo debug: %debug%
echo release: %release%
echo bitness: %bitness%
echo pdb: %pdb%
echo dprint: %debug_print%
echo rtl: %rtl%
echo pts: %pts%
)
if %cln% == 1 (
if %verbose% == 1 echo removing "%my_dir%\build"
rmdir /s /q "%my_dir%\build" >nul 2>&1
)
if %prog%==1 call :build %prog_proj%
endlocal
exit /B 0
:build
SETLOCAL
set proj=%~1
if %debug%==1 call :buildEx %proj%,%platform%,Debug,%debug_print%,%rtl%,%pdb%,%pts%
if %release%==1 call :buildEx %proj%,%platform%,Release,%debug_print%,%rtl%,%pdb%,%pts%
ENDLOCAL
EXIT /B %ERRORLEVEL%
:buildEx
SETLOCAL
set proj=%~1
set platform=%~2
set conf=%~3
set /a dpf=%~4
set rtl=%~5
set /a pdb=%~6
set pts=%~7
:: print flags
set /a "dp=%dpf%&~EP_FLAG"
set /a "ep=%dpf%&EP_FLAG"
if not %ep% == 0 (
set /a ep=1
)
if %rtl% == 1 (
set rtl=%conf%
) else (
set rtl=None
)
:: pdbs
if [%conf%] EQU [Debug] (
set /a pdb=1
)
if %verbose% EQU 1 (
echo build
echo - Project=%proj%
echo - Platform=%platform%
echo - Configuration=%conf%
echo - DebugPrint=%dp%
echo - ErrorPrint=%ep%
echo - RuntimeLib=%rtl%
echo - PDB=%pdb%
echo - PTS=%pts%
echo.
)
msbuild %proj% /p:Platform=%platform% /p:Configuration=%conf% /p:PlatformToolset=%pts% /p:DebugPrint=%dp% /p:ErrorPrint=%ep% /p:RuntimeLib=%rtl% /p:PDB=%pdb%
echo.
echo ----------------------------------------------------
echo.
echo.
ENDLOCAL
EXIT /B %ERRORLEVEL%
:usage
echo Usage: %my_name% [/talk] [/d] [/r] [/b 32^|64] [/pdb] [/rtl]
echo Default: %my_name% [/talk /r /b 64]
exit /B 0
:help
call :usage
echo.
echo Targets:
echo /talk: Build Talk.
echo.
echo Options:
echo /d: Build in debug mode.
echo /r: Build in release mode.
echo /b: Bitness of exe. 32^|64. Default: 64.
echo /pdb: Compile with pdbs.
echo /rtl: Compile with RuntimeLibrary.
echo /pts: msbuild PlatformToolSet. Default: v142.
echo.
echo /v: More verbose mode.
echo /h: Print this.
echo.
exit /B 0