-
Notifications
You must be signed in to change notification settings - Fork 1
/
winBuild.bat
242 lines (207 loc) · 5.21 KB
/
winBuild.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
239
240
241
242
@echo off
setlocal
set my_name=%~n0
set my_dir="%~dp0"
set "my_dir=%my_dir:~1,-2%"
set name=hexter
set /a exe=0
set /a dll=0
set /a cln=0
set /a bitness=64
set platform=x64
set /a debug=0
set /a release=0
set /a rtl=0
set /a dp=0
set /a pdb=0
set /a ico=1
set /a verbose=0
:: adjust this path, if you're using another version or path.
set buildTools="C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
set pts=v142
:: set pts=WindowsApplicationForDrivers10.0
:: default
if [%1]==[] goto main
GOTO :ParseParams
:ParseParams
REM IF "%~1"=="" GOTO Main
if [%1]==[/?] goto help
if [%1]==[/h] goto help
if [%1]==[/help] goto help
IF /i "%~1"=="/exe" (
SET /a exe=1
goto reParseParams
)
IF /i "%~1"=="/dll" (
SET /a dll=1
goto reParseParams
)
IF /i "%~1"=="/cln" (
SET /a cln=1
goto reParseParams
)
IF /i "%~1"=="/b" (
SET /a bitness="%~2"
SHIFT
goto reParseParams
)
IF /i "%~1"=="/d" (
SET /a debug=1
goto reParseParams
)
IF /i "%~1"=="/r" (
SET /a release=1
goto reParseParams
)
IF /i "%~1"=="/bt" (
SET buildTools="%~2"
SHIFT
goto reParseParams
)
IF /i "%~1"=="/pts" (
SET pts="%~2"
SHIFT
goto reParseParams
)
IF /i "%~1"=="/rtl" (
SET /a rtl=1
goto reParseParams
)
IF /i "%~1"=="/pdb" (
SET /a pdb=1
goto reParseParams
)
IF /i "%~1"=="/dp" (
SET /a dp=1
goto reParseParams
)
IF /i "%~1"=="/xi" (
SET /a ico=0
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 platform
set /a valid=0
if %bitness% == 32 (
set platform=x86
set /a valid=1
) else (
if %bitness% == 64 (
set platform=x64
set valid=1
)
)
if %valid% == 0 (
goto help
)
:: test valid targets
set /a "valid=%exe%+%dll%+%cln%"
if %valid% == 0 (
set /a exe=1
)
:: set release default
set /a "valid=%release%+%debug%"
if not %valid% == 1 (
set /a release=1
set /a debug=0
)
:: set runtime lib
set rtlib=No
if %debug% == 1 (
if %rtl% == 1 (
set rtlib=Debug
)
set /a pdb=1
) else (
if %release% == 1 (
if %rtl% == 1 (
set rtlib=Release
)
)
)
:: verbose print
if %verbose% == 1 (
echo exe=%exe%
echo dll=%dll%
echo bitness=%bitness%
echo platform=%platform%
echo debug=%debug%
echo release=%release%
echo buildTools=%buildTools%
echo rtlib=%rtlib%
echo pts=%pts%
echo ico=%ico%
echo proj=%proj%
)
:: set vcvars, if necessary
:: pseudo nop command to prevent if else bug in :build
set vcvars=call
if [%VisualStudioVersion%] EQU [] (
if not exist %buildTools% (
echo [e] No build tools found in %buildTools%!
echo Please set the correct path in this script or with the /bt option.
exit /b -1
)
set vcvars="%buildTools:~1,-1%\VC\Auxiliary\Build\vcvars%bitness%.bat"
)
:: build targets
if %cln% == 1 (
echo removing "%my_dir%\build"
rmdir /s /q "%my_dir%\build" >nul 2>&1
)
if %exe% == 1 (
call :build Hexter.vcxproj Application
)
if %dll% == 1 (
call :build Hexter.vcxproj DynamicLibrary
)
endlocal
exit /B %errorlevel%
:build
setlocal
set proj=%1
set ct=%2
set conf=
if %debug% EQU 1 (
set conf=Debug
) else (
if %release% EQU 1 set conf=Release
)
cmd /k "%vcvars% & msbuild Hexter.vcxproj /p:Platform=%platform% /p:PlatformToolset=%pts% /p:Configuration=%conf% /p:RuntimeLib=%rtlib% /p:PDB=%pdb% /p:ConfigurationType=%ct% /p:DebugPrint=%dp% /p:Icon=%ico% & exit"
endlocal
exit /B 0
:usage
@echo Usage: %my_name% [/exe] [/dll] [/b 32^|64] [/r^|/d] [/rtl] [/pdb] [/pts ^<toolset^>] [/bt ^<path^>] [/xi] [/v] [/h]
@echo Default: %my_name% [/exe /b %bitness% /m %mode% /pts %pts% /bt %buildTools%]
exit /B 0
:help
call :usage
echo.
echo Targets:
echo /exe Build Hexter.exe application.
echo /dll Build Hexter.dll library.
echo.
echo Options:
echo /b Target bitness: 32^|64. Default: 64.
echo /d Build in debug mode.
echo /r Build in release mode (default).
echo /rtl Statically include runtime libs. Increases file size but may be needed if a "VCRUNTIMExxx.dll not found Error" occurs on the target system.
echo /pdb Include pdb symbols into release build. Default in debug mode.
echo /bt Custom path to Microsoft Visual Studio BuildTools
echo /pts Platformtoolset. Defaults to "v142".
echo /xi No icon for the exe.
echo.
echo /v more verbose output
echo /h print this
endlocal
exit /B 0