forked from qt/qt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-qt.cmd
353 lines (277 loc) · 7.76 KB
/
build-qt.cmd
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
@echo off
setlocal ENABLEEXTENSIONS
setlocal ENABLEDELAYEDEXPANSION
set SCRIPT_NAME=%~nx0
set SCRIPT_PATH=%~dp0
set SCRIPT_PATH=%SCRIPT_PATH:~0,-1%
for %%* in (%SCRIPT_PATH%) do set SCRIPT_FOLDER=%%~nx*
set SCRIPT_ARGS=%*
rem You can use tt as a temporary file for stashing stuff
set tt=%Time: =0%
set tt=%tt::=%
set tt=%tt:.=%
set tt=%tt:,=%
set tt=%TEMP%\%tt%.%SCRIPT_NAME%
set PWD=%CD%
:start_here
call :main %*
cd "%PWD%"
echo.
exit /b %errorlevel%
:subroutines
:setup
echo.
echo ##############
echo #
echo # Setting up Qt %BUILD_ALIAS% build environment
echo.
set QTSRCDIR=%SCRIPT_PATH%
pushd "%QTSRCDIR%\.."
set QT_INSTALL_ROOT=%CD%
popd
if "%TOOL_CHAIN%" == "msvc2008" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio 9.0\VC\vcvarsall.bat"
goto :eof
)
if "%TOOL_CHAIN%" == "msvc2010" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
goto :eof
)
rem msvc2012 through msvc2015 correspond to Visual Studio versions 11 through 14,
rem which is why they're install paths appear be one version behind, eg. msvc2012 is installed in the 11.0 folder
if "%TOOL_CHAIN%" == "msvc2012" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
goto :eof
)
if "%TOOL_CHAIN%" == "msvc2013" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
goto :eof
)
if "%TOOL_CHAIN%" == "msvc2015" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
goto :eof
)
rem Microsoft's tool layout changed in msvc2017 onwards. See the following:
rem https://blogs.msdn.microsoft.com/vcblog/2016/10/07/compiler-tools-layout-in-visual-studio-15/
rem VSEDITION can be Community | Professional | Enterprise
set VSEDITION=Community
if "%TOOL_CHAIN%" == "msvc2017" (
call "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\%VSEDITION%\VC\Auxiliary\Build\vcvarsall.bat" amd64_x86
goto :eof
)
goto :eof
:configure
echo.
echo ##############
echo #
echo # Configuring Qt %BUILD_ALIAS%
echo.
if not exist "%QT_INSTALL_ROOT%\%BUILD_ALIAS%" mkdir "%QT_INSTALL_ROOT%\%BUILD_ALIAS%"
copy "%SCRIPT_PATH%\jom.exe" "%QT_INSTALL_ROOT%\%BUILD_ALIAS%\jom.exe"
cd "%QT_INSTALL_ROOT%\%BUILD_ALIAS%"
call "%SCRIPT_PATH%\build-targets\%BUILD_TARGET%.cmd" :configure %TOOL_CHAIN%
if %errorlevel% neq 0 (
echo.
echo ##############
echo #
echo # ^^!^^! Fatal error %errorlevel% while configuring Qt %BUILD_ALIAS%^^!^^!
echo.
popd
goto :eof
)
echo.
echo ##############
echo #
echo # Qt %BUILD_ALIAS% configuration complete
echo.
goto :eof
:build
echo.
echo ##############
echo #
echo # Building Qt %BUILD_ALIAS%
echo.
if not exist "%QT_INSTALL_ROOT%\%BUILD_ALIAS%" (
echo.
echo ##############
echo #
echo # Build failed -- Call "%SCRIPTNAME% configure" first
echo.
set errorlevel=996
goto :eof
)
pushd "%QT_INSTALL_ROOT%\%BUILD_ALIAS%"
set PATH=%cd%\bin;%PATH%
call "%SCRIPT_PATH%\build-targets\%BUILD_TARGET%.cmd" :build
if %errorlevel% neq 0 (
echo.
echo ##############
echo #
echo # ^^!^^! Fatal error %errorlevel% while building Qt %BUILD_ALIAS%^^!^^!
echo.
popd
goto :eof
)
popd
echo.
echo ##############
echo #
echo # Qt %BUILD_ALIAS% build complete
echo.
goto :eof
:distill
echo.
echo ##############
echo #
echo # Distilling Qt %BUILD_ALIAS%
echo.
if not exist "%QT_INSTALL_ROOT%\%BUILD_ALIAS%" (
echo.
echo ##############
echo #
echo # Distillation failed -- "%QT_INSTALL_ROOT%\%BUILD_ALIAS%" doesn't exist
echo.
set errorlevel=995
goto :eof
)
pushd "%QT_INSTALL_ROOT%\%BUILD_ALIAS%"
set PATH=%cd%\bin;%PATH%
jom /NOLOGO clean
if %errorlevel% neq 0 (
echo.
echo ##############
echo #
echo # ^^!^^! Fatal error %errorlevel% while distilling Qt %BUILD_ALIAS% ^^!^^!
echo.
popd
goto :eof
)
rem It look's like the only thing that's needed in .\src is some headers in .\src\corelib\global
rem So let's grab those and delete the 100's of MB of intermediates
xcopy /i /e .\src\corelib\global .\src-tt\corelib\global
rmdir /q /s .\src
move .\src-tt .\src
popd
echo.
echo ##############
echo #
echo # Qt %BUILD_ALIAS% distillation complete
echo.
goto :eof
:show_help
echo.
echo ############################################################
echo.##
echo ## %SCRIPT_NAME% is used to build Qt for 32-bit Windows based targets
echo.##
echo ## Usage: %SCRIPT_NAME% target [build_action] [tool_chain]
echo.##
echo ## where [] indicates an optional parameter, and:
echo.##
echo ## - target is one of {%BUILD_TARGETS%}.
echo ## - [build_action] is one of {configure, build, distill, all}.
echo ## Default is all, ie. perform configure, build, and distill in sequence
echo ## - tool_chain is one of {msvc2008, msvc2010, msvc2012, msvc2013, msvc2015, msvc2017}.
echo ## Default is msvc2008
echo.##
echo.## --------------------------------------------------------
echo.##
echo ## You called %SCRIPT_NAME% from "%PWD%" with
echo.##
echo ## %SCRIPT_NAME% %SCRIPT_ARGS%
echo.##
if "%~1" neq "" (
echo.## which caused error, "%~1"
echo.##
)
echo ############################################################
echo.
goto :eof
:main
git branch > tt
set /p GIT_BRANCH= <tt
set GIT_BRANCH=%GIT_BRANCH:* =%
git rev-parse HEAD > tt
set /p GIT_ID= <tt
set GIT_ID=%GIT_ID:~0,6%
set QT_VERSION=%GIT_BRANCH%-%GIT_ID%
del tt
for /r "%SCRIPT_PATH%\build-targets" %%f in (*.cmd) do (
if not defined BUILD_TARGETS (
call set "BUILD_TARGETS=%%~nf"
) else (
call set "BUILD_TARGETS=%%BUILD_TARGETS%%, %%~nf"
)
)
set BUILD_TARGET=%~1
if not defined BUILD_TARGET (
call :show_help "target not specified"
set errorlevel=999
goto :finish
)
for /r "%SCRIPT_PATH%\build-targets" %%f in (*.cmd) do (
if %BUILD_TARGET%==%%~nf set VALID_BUILD_TARGET=true
)
for /f %%a in ('echo -h ^&echo --help') do (
if %~1==%%a (
call :show_help
goto :eof
)
)
if not defined VALID_BUILD_TARGET (
call :show_help "unknown target"
set errorlevel=998
goto :finish
)
set BUILD_TASK=%~2
if "%2" == "" set BUILD_TASK=all
for /f %%a in ('echo configure ^&echo build ^&echo distill ^&echo all') do (
if %BUILD_TASK%==%%a set VALID_BUILD_TASK=true
)
if not defined VALID_BUILD_TASK (
call :show_help "unknown build task"
set errorlevel=997
goto :finish
)
set TOOL_CHAIN=%~3
if "%3" == "" set TOOL_CHAIN=msvc2008
for /f %%a in ('echo msvc2008 ^&echo msvc2010 ^&echo msvc2012 ^&echo msvc2013 ^&echo msvc2015 ^&echo msvc2017') do (
if %TOOL_CHAIN%==%%a set KNOWN_TOOL_CHAIN=true
)
if not defined KNOWN_TOOL_CHAIN (
call :show_help "unknown tool chain"
set errorlevel=994
goto :finish
)
set BUILD_ALIAS=qt%QT_VERSION%-%BUILD_TARGET%-%TOOL_CHAIN%
:start
echo.
echo ##############
echo #
echo # Starting Qt %BUILD_ALIAS% %BUILD_TASK% at %Date% %Time%
echo.
call :setup
if "%BUILD_TASK%" neq "all" (
call :%BUILD_TASK%
goto :finish
)
call :configure
if %errorlevel% neq 0 goto :finish
call :build
if %errorlevel% neq 0 goto :finish
call :distill
if %errorlevel% neq 0 goto :finish
:finish
if %errorlevel% neq 0 (
echo. Failed with error %errorlevel% :-^(
) else (
echo. All done :-^) at %Date% %Time%
call :warmFuzzy
)
goto :eof
:warmFuzzy
echo. __ __ __ ____ _____ _ _ ____ ## ___-___ ##
echo. /__\ ( ) ( ) ( _ \( _ )( \( )( ___) o##=ooO- _~~ -Ooo=##o
echo. /(__)\ )(__ )(__ )(_) ))(_)( ) ( )__) ## \\ - + // ##
echo.(__)(__)(____)(____) (____/(_____)(_)\_)(____) \\__\0/__//
goto :eof