forked from pgadmin-org/pgadmin4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Make.bat
601 lines (501 loc) · 23.8 KB
/
Make.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
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
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
@ECHO off
SETLOCAL
REM
REM ****************************************************************
SET WD=%CD%
SET "PGBUILDPATH=%WD%\win-build"
SET CMDOPTION=""
IF "%1" == "clean" SET CMDOPTION="VALID"
IF "%1" == "x86" SET CMDOPTION="VALID"
IF "%1" == "amd64" SET CMDOPTION="VALID"
IF NOT %CMDOPTION%=="VALID" ( GOTO USAGE )
SET ARCHITECTURE=%1
IF "%ARCHITECTURE%"=="clean" (
GOTO CLEAN_RELEASE
GOTO EXIT
)
REM Main Functions
CALL :SET_PGADMIN4_ENVIRONMENT
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :VALIDATE_ENVIRONMENT
CALL :CLEAN_RELEASE
CALL :CREATE_VIRTUAL_ENV
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :CREATE_RUNTIME_ENV
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :CREATE_PYTHON_ENV
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :CLEANUP_ENV
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :CREATE_INSTALLER
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL :SIGN_INSTALLER
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CD %WD%
GOTO EXIT
REM Main function Ends
:CLEAN_RELEASE
ECHO Calling clean target...
IF EXIST "%PGBUILDPATH%" rd "%PGBUILDPATH%" /S /Q
FOR /R "%WD%" %%f in (*.pyc *.pyo) do DEL /q "%%f" > nul
IF EXIST "%WD%\pkg\win32\Output" rd "%WD%\pkg\win32\Output" /S /Q
IF EXIST DEL /q "%WD%\pkg\win32\installer.iss" > nul
CD %WD%
GOTO:eof
:SET_PGADMIN4_ENVIRONMENT
REM Check os architecture x86 or amd64
SET RegQry=HKLM\Hardware\Description\System\CentralProcessor\0
REG.exe Query %RegQry% > checkOS.txt
Find /i "x86" < CheckOS.txt > StringCheck.txt
SET OSTYPE=""
IF %ERRORLEVEL% == 0 (
SET OSTYPE=x86
) else (
SET OSTYPE=amd64
)
DEL CheckOS.txt StringCheck.txt
SET OSVALUE=""
IF "%OSTYPE%"=="x86" (
IF "%ARCHITECTURE%"=="amd64" (
ECHO ARCHITECTURE - %ARCHITECTURE% cannot be run on 32 bit machine
GOTO EXIT
)
SET OSVALUE=%OSTYPE%
)
REM Check IF its is windows 32 bit machine and selected architecture is x86
IF %OSVALUE%=="x86" (
IF "%PYTHON_HOME%" == "" SET "PYTHON_HOME=C:\Python27"
IF "%PYTHON_DLL%" == "" SET "PYTHON_DLL=C:\Windows\System32\python27.dll"
IF "%QTDIR%" == "" SET "QTDIR=C:\Qt\5.7\msvc2013"
IF "%PGDIR%" == "" SET "PGDIR=C:\Program Files\PostgreSQL\9.6"
IF "%INNOTOOL%" == "" SET "INNOTOOL=C:\Program Files\Inno Setup 5"
IF "%VCDIR%" == "" SET "VCDIR=C:\Program Files\Microsoft Visual Studio 12.0\VC"
SET "VCREDISTNAME=vcredist_x86.exe"
)
REM Check IF its is windows 64 bit machine and selected architecture is x86 or amd64
IF "%ARCHITECTURE%"=="x86" (
IF "%PYTHON_HOME%" == "" SET "PYTHON_HOME=C:\Python27"
IF "%PYTHON_DLL%" == "" SET "PYTHON_DLL=C:\Windows\SysWOW64\python27.dll"
IF "%QTDIR%" == "" SET "QTDIR=C:\Qt\5.7\msvc2013"
IF "%PGDIR%" == "" SET "PGDIR=C:\Program Files (x86)\PostgreSQL\9.6"
IF "%INNOTOOL%" == "" SET "INNOTOOL=C:\Program Files (x86)\Inno Setup 5"
IF "%VCDIR%" == "" SET "VCDIR=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
IF "%VCREDIST%" == "" SET "VCREDIST=C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\redist\1033\vcredist_x86.exe"
SET "VCREDISTNAME=vcredist_x86.exe"
)
IF "%ARCHITECTURE%"=="amd64" (
IF "%PYTHON_HOME%" == "" SET "PYTHON_HOME=C:\Python27-x64"
IF "%PYTHON_DLL%" == "" SET "PYTHON_DLL=C:\Windows\System32\python27.dll"
IF "%QTDIR%" == "" SET "QTDIR=C:\Qt\5.7\msvc2013"
IF "%PGDIR%" == "" SET "PGDIR=C:\Program Files\PostgreSQL\9.6"
IF "%INNOTOOL%" == "" SET "INNOTOOL=C:\Program Files\Inno Setup 5"
IF "%VCDIR%" == "" SET "VCDIR=C:\Program Files\Microsoft Visual Studio 12.0\VC"
IF "%VCREDIST%" == "" SET "VCREDIST=C:\Program Files\Microsoft Visual Studio 12.0\VC\redist\1033\vcredist_x64.exe"
SET "VCREDISTNAME=vcredist_x64.exe"
)
GOTO:eof
:VALIDATE_ENVIRONMENT
REM SET the variables IF not availalbe in windows environment
SET "VCVAR=%VCDIR%\vcvarsall.bat"
SET "VCNMAKE=%VCDIR%\bin\nmake.exe"
SET "QMAKE=%QTDIR%\bin\qmake.exe"
SET "VIRTUALENV=venv"
SET "TARGETINSTALLER=%WD%\dist"
SET "VCREDIST=%VCDIR%\redist\1033\%VCREDISTNAME%"
FOR /F "tokens=3" %%a IN ('findstr /C:"APP_RELEASE =" %WD%\web\config.py') DO SET APP_RELEASE=%%a
FOR /F "tokens=3" %%a IN ('findstr /C:"APP_REVISION =" %WD%\web\config.py') DO SET APP_REVISION_VERSION=%%a
FOR /F "tokens=3" %%a IN ('findstr /C:"APP_SUFFIX =" %WD%\web\config.py') DO SET APP_SUFFIX_VERSION=%%a
REM remove single quote from the string
SET APP_SUFFIX_VERSION=%APP_SUFFIX_VERSION:'=%
SET APP_NAME=""
FOR /F "tokens=2* DELims='" %%a IN ('findstr /C:"APP_NAME =" web\config.py') DO SET APP_NAME=%%a
FOR /f "tokens=1 DELims=." %%G IN ('%PYTHON_HOME%/python.exe -c "print('%APP_NAME%'.lower().replace(' ', ''))"') DO SET APP_SHORTNAME=%%G
FOR /F "tokens=4,5 delims=. " %%a IN ('%QMAKE% -v ^| findstr /B /C:"Using Qt version "') DO SET QT_VERSION=%%a.%%b
SET INSTALLERNAME=%APP_SHORTNAME%-%APP_RELEASE%.%APP_REVISION_VERSION%-%APP_SUFFIX_VERSION%-%ARCHITECTURE%.exe
IF "%APP_SUFFIX_VERSION%" == "" SET INSTALLERNAME=%APP_SHORTNAME%-%APP_RELEASE%.%APP_REVISION_VERSION%-%ARCHITECTURE%.exe
SET PGADMIN4_VERSION=v%APP_RELEASE%
SET PGADMIN4_APP_VERSION=%APP_RELEASE%.%APP_REVISION_VERSION%
ECHO ****************************************************************
ECHO S U M M A R Y
ECHO ****************************************************************
ECHO Target mode = %ARCHITECTURE%
ECHO INNOTOOL = %INNOTOOL%
ECHO VCDIR = %VCDIR%
ECHO VCDIST = %VCREDIST%
ECHO NMAKE = %VCNMAKE%
ECHO QTDIR = %QTDIR%
ECHO QMAKE = %QMAKE%
ECHO QT_VERSION = %QT_VERSION%
IF %QT_VERSION% GEQ 5.5 (
ECHO BROWSER = QtWebEngine
) ELSE (
ECHO BROWSER = QtWebKit
)
ECHO PYTHON_HOME = %PYTHON_HOME%
ECHO PYTHON_DLL = %PYTHON_DLL%
ECHO PGDIR = %PGDIR%
ECHO ****************************************************************
REM Check IF path SET in enviroments really exist or not ?
IF NOT EXIST "%INNOTOOL%" GOTO err_handle_inno
IF NOT EXIST "%VCDIR%" GOTO err_handle_visualstudio
IF NOT EXIST "%VCREDIST%" GOTO err_handle_visualstudio_dist
IF NOT EXIST "%VCVAR%" GOTO err_handle_visualstudio
IF NOT EXIST "%VCNMAKE%" GOTO err_handle_visualstudio
IF NOT EXIST "%QTDIR%" GOTO err_handle_qt
IF NOT EXIST "%QMAKE%" GOTO err_handle_qt
IF NOT EXIST "%PYTHON_HOME%" GOTO err_handle_python
IF NOT EXIST "%PYTHON_DLL%" GOTO err_handle_python
IF NOT EXIST "%PGDIR%" GOTO err_handle_pg
REM Check for QT and VC dependences
FOR /L %%G IN (15,1,19) DO "%VCDIR%\bin\cl.exe" /? 2>&1 | findstr /C:"Version %%G" > nul && SET MSVC_MAJOR_VERSION=%%G
IF %MSVC_MAJOR_VERSION%==19 SET QT_MSVC_PATH=msvc2015
IF %MSVC_MAJOR_VERSION%==18 SET QT_MSVC_PATH=msvc2013
IF %MSVC_MAJOR_VERSION%==17 SET QT_MSVC_PATH=msvc2012
IF %MSVC_MAJOR_VERSION%==16 SET QT_MSVC_PATH=msvc2010
IF %MSVC_MAJOR_VERSION%==15 SET QT_MSVC_PATH=msvc2008
REM on 64 bit machine if x86 is selected and QTDIR is set to 64 bit is should not allow
IF "%OSTYPE%"=="amd64" (
IF "%ARCHITECTURE%"=="x86" (
echo "%QTDIR%" | findstr /C:"_64" > nul && ( GOTO err_handle_qt_compactissue )
)
)
IF "%ARCHITECTURE%"=="amd64" (
SET QT_MSVC_PATH=%QT_MSVC_PATH%_64
)
IF NOT EXIST "%QTDIR%\..\%QT_MSVC_PATH%" GOTO err_handle_qt_mismatch
REM get Python version ex. 2.7.1 will get as 27
FOR /f "tokens=1 DELims=." %%G IN ('%PYTHON_HOME%/python.exe -c "import sys; print(sys.version.split(' ')[0])"') DO SET PYTHON_MAJOR=%%G
FOR /f "tokens=2 DELims=." %%G IN ('%PYTHON_HOME%/python.exe -c "import sys; print(sys.version.split(' ')[0])"') DO SET PYTHON_MINOR=%%G
SET "PYTHON_VERSION=%PYTHON_MAJOR%%PYTHON_MINOR%"
IF NOT EXIST "%PYTHON_HOME%\Scripts\virtualenv.exe" GOTO err_handle_pythonvirtualenv
SET PATH=%PGDIR%;%PGDIR%\bin;%PATH%
GOTO:eof
:CREATE_VIRTUAL_ENV
ECHO Creating Virtual Enviroment...
IF NOT EXIST "%PGBUILDPATH%" MKDIR "%PGBUILDPATH%"
CD "%PGBUILDPATH%"
"%PYTHON_HOME%\Scripts\virtualenv.exe" "%VIRTUALENV%"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Activating Virtual Enviroment - %PGBUILDPATH%\%VIRTUALENV%\Scripts\activate...
CALL "%PGBUILDPATH%\%VIRTUALENV%\Scripts\activate"
SET PATH=%PGDIR%\bin;%PATH%
ECHO Installing dependencies...
pip install -r "%WD%\requirements.txt"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
pip install sphinx
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Virtual Environment created successfully.
ECHO Deactivating Virtual Enviroment - %PGBUILDPATH%\%VIRTUALENV%\Scripts\deactivate...
CALL "%PGBUILDPATH%\%VIRTUALENV%\Scripts\deactivate"
CD %WD%
GOTO:eof
:CREATE_RUNTIME_ENV
ECHO Compiling source code...
MKDIR "%PGBUILDPATH%\runtime" > nul
REM --- Processing WEB ---
CD "%WD%\web"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Install Javascript dependencies
call yarn install
ECHO Bundle all Javascript
call yarn run bundle
XCOPY /S /I /E /H /Y "%WD%\web" "%PGBUILDPATH%\web" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
REM Clean up .pyc, .pyo, pgadmin4.db, config_local.py
ECHO Cleaning up unnecessary files...
FOR /R "%PGBUILDPATH%\web" %%f in (*.pyc *.pyo) do DEL /q "%%f"
FOR /R "%PGBUILDPATH%\web" %%f in (tests feature_tests __pycache__ node_modules) do RD /Q /S "%%f"
RD /Q /S "%PGBUILDPATH%\web\regression"
RD /Q /S "%PGBUILDPATH%\web\tools"
DEL /q "%PGBUILDPATH%\web\pgadmin4.db"
DEL /q "%PGBUILDPATH%\web\config_local.py"
ECHO Creating config_distro.py
ECHO SERVER_MODE = False > "%PGBUILDPATH%\web\config_distro.py"
ECHO HELP_PATH = '../../../docs/en_US/html/' >> "%PGBUILDPATH%\web\config_distro.py"
ECHO DEFAULT_BINARY_PATHS = { >> "%PGBUILDPATH%\web\config_distro.py"
ECHO 'pg': '$DIR/../runtime', >> "%PGBUILDPATH%\web\config_distro.py"
ECHO 'ppas': '' >> "%PGBUILDPATH%\web\config_distro.py"
ECHO } >> "%PGBUILDPATH%\web\config_distro.py"
ECHO Activating Virtual Enviroment - %PGBUILDPATH%\%VIRTUALENV%\Scripts\activate...
CALL "%PGBUILDPATH%\%VIRTUALENV%\Scripts\activate"
ECHO Building docs...
MKDIR "%PGBUILDPATH%\docs\en_US\html"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CD "%WD%\docs\en_US"
"%PGBUILDPATH%\%VIRTUALENV%\Scripts\python.exe" build_code_snippet.py
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
"%PGBUILDPATH%\%VIRTUALENV%\Scripts\sphinx-build.exe" "%WD%\docs\en_US" "%PGBUILDPATH%\docs\en_US\html"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Removing Sphinx
pip uninstall -y sphinx Pygments alabaster colorama docutils imagesize requests snowballstemmer
ECHO Assembling runtime environment...
CD "%WD%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL "%VCVAR%" %ARCHITECTURE%
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL "%QMAKE%"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL "%VCNMAKE%" clean
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL "%VCNMAKE%"
IF ERRORLEVEL 1 GOTO ERR_HANDLER
REM Copy binary to Release Folder
copy "%WD%\runtime\release\pgAdmin4.exe" "%PGBUILDPATH%\runtime"
IF ERRORLEVEL 1 GOTO ERR_HANDLER
REM Copy QT dependences
copy "%QTDIR%\bin\Qt5Core.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Sql.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Gui.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Qml.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5OpenGL.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Quick.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Sensors.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Widgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Network.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Multimedia.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebChannel.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5Positioning.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5PrintSupport.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5MultimediaWidgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
REM Install the appropriate browser components. We use QtWebEngine with Qt 5.5+
IF %QT_VERSION% GEQ 5.7 (
copy "%QTDIR%\bin\Qt5QuickWidgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
)
IF %QT_VERSION% GEQ 5.7 (
copy "%QTDIR%\resources\icudtl.dat" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\resources\qtwebengine_resources.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\resources\qtwebengine_devtools_resources.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\resources\qtwebengine_resources_100p.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\resources\qtwebengine_resources_200p.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngine.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngineCore.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngineWidgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\QtWebEngineProcess.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\opengl32sw.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
) ELSE (
IF %QT_VERSION% GEQ 5.5 (
copy "%QTDIR%\bin\icudt54.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\icuin54.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\icuuc54.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\icudtl.dat" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\qtwebengine_resources.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\qtwebengine_resources_100p.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\qtwebengine_resources_200p.pak" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngine.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngineCore.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebEngineWidgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\QtWebEngineProcess.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
) ELSE (
copy "%QTDIR%\bin\Qt5WebKit.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\bin\Qt5WebKitWidgets.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
)
)
MKDIR "%PGBUILDPATH%\runtime\platforms"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%QTDIR%\plugins\platforms\qwindows.dll" "%PGBUILDPATH%\runtime\platforms" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO [Paths] > "%PGBUILDPATH%\runtime\qt.conf"
ECHO Plugins=plugins >> "%PGBUILDPATH%\runtime\qt.conf"
copy "%PGDIR%\bin\libpq.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\ssleay32.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\libeay32.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\libintl-*.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\libiconv-*.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\zlib1.dll" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\pg_dump.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\pg_dumpall.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\pg_restore.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%PGDIR%\bin\psql.exe" "%PGBUILDPATH%\runtime"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
MKDIR "%PGBUILDPATH%\installer"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy "%VCREDIST%" "%PGBUILDPATH%\installer" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Runtime built successfully.
CD %WD%
GOTO:eof
:CREATE_PYTHON_ENV
copy %PYTHON_DLL% "%PGBUILDPATH%\runtime" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
REM Copy Python interpretor as it's needed to run background processes
copy %PYTHON_HOME%\python.exe "%PGBUILDPATH%\runtime" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
copy %PYTHON_HOME%\pythonw.exe "%PGBUILDPATH%\runtime" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
XCOPY /S /I /E /H /Y "%PYTHON_HOME%\DLLs" "%PGBUILDPATH%\%VIRTUALENV%\DLLs" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
XCOPY /S /I /E /H /Y "%PYTHON_HOME%\Lib" "%PGBUILDPATH%\%VIRTUALENV%\Lib" > nul
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO Cleaning up unnecessary files...
FOR /R "%PGBUILDPATH%\%VIRTUALENV%" %%f in (*.pyc *.pyo) do DEL /q "%%f"
FOR /R "%PGBUILDPATH%\%VIRTUALENV%\Lib" %%f in (test tests) do RD /Q /S "%%f"
RD /Q /S "%PGBUILDPATH%\%VIRTUALENV%\tcl"
CD %WD%
GOTO:eof
:CREATE_INSTALLER
ECHO Preparing for creation of windows installer...
IF NOT EXIST "%TARGETINSTALLER%" MKDIR "%TARGETINSTALLER%"
copy "%WD%\pkg\win32\Resources\pgAdmin4.ico" "%PGBUILDPATH%"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CD "%WD%"
CD pkg
CD win32
"%PYTHON_HOME%\python" "%WD%\pkg\win32\replace.py" "-i" "%WD%\pkg\win32\installer.iss.in" "-o" "%WD%\pkg\win32\installer.iss.in_stage1" "-s" MYAPP_NAME -r """%APP_NAME%"""
"%PYTHON_HOME%\python" "%WD%\pkg\win32\replace.py" "-i" "%WD%\pkg\win32\installer.iss.in_stage1" "-o" "%WD%\pkg\win32\installer.iss.in_stage2" "-s" MYAPP_FULLVERSION -r """%PGADMIN4_APP_VERSION%"""
"%PYTHON_HOME%\python" "%WD%\pkg\win32\replace.py" "-i" "%WD%\pkg\win32\installer.iss.in_stage2" "-o" "%WD%\pkg\win32\installer.iss.in_stage3" "-s" MYAPP_VERSION -r """%PGADMIN4_VERSION%"""
set ARCMODE=
IF "%ARCHITECTURE%"=="amd64" (
set ARCMODE="x64"
)
"%PYTHON_HOME%\python" "%WD%\pkg\win32\replace.py" "-i" "%WD%\pkg\win32\installer.iss.in_stage3" "-o" "%WD%\pkg\win32\installer.iss.in_stage4" "-s" MYAPP_ARCHITECTURESMODE -r """%ARCMODE%"""
"%PYTHON_HOME%\python" "%WD%\pkg\win32\replace.py" "-i" "%WD%\pkg\win32\installer.iss.in_stage4" "-o" "%WD%\pkg\win32\installer.iss" "-s" MYAPP_VCDIST -r """%VCREDISTNAME%"""
DEL /s "%WD%\pkg\win32\installer.iss.in_stage*" > nul
ECHO Creating windows installer... using INNO tool
CALL "%INNOTOOL%\ISCC.exe" /q "%WD%\pkg\win32\installer.iss"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
MOVE "%WD%\pkg\win32\Output\Setup.exe" "%TARGETINSTALLER%\%INSTALLERNAME%"
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO "Location - %TARGETINSTALLER%\%INSTALLERNAME%"
ECHO Installer generated successfully.
CD %WD%
GOTO:eof
:SIGN_INSTALLER
ECHO Attempting to sign the installer...
signtool sign /t http://timestamp.verisign.com/scripts/timstamp.dll "%TARGETINSTALLER%\%INSTALLERNAME%"
IF %ERRORLEVEL% NEQ 0 (
ECHO
ECHO ************************************************************
ECHO * Failed to sign the installer
ECHO ************************************************************
SLEEP 5
)
CD %WD%
GOTO:eof
:CLEANUP_ENV
ECHO Cleaning up private environment...
rd "%PGBUILDPATH%\%VIRTUALENV%\Include" /S /Q
DEL /s "%PGBUILDPATH%\%VIRTUALENV%\pip-selfcheck.json"
ECHO Cleaned up private environment successfully.
CD %WD%
GOTO:eof
:err_handle_inno
ECHO %INNOTOOL% does not exist
ECHO Please Install Innotool and SET INNOTOOL enviroment Variable.
ECHO SET "INNOTOOL=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_visualstudio
ECHO %VCDIR% does not exist, or
ECHO %VCVAR% does not exist, or
ECHO %VCNMAKE% does not exist.
ECHO Please Install Microsoft Visual studio and SET the VCDIR enviroment Variable.
ECHO SET "VCDIR%=<PATH>"
ECHO SET "VCVAR%=<PATH>"
ECHO SET "VCNMAKE%=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_visualstudio_dist
ECHO %VCREDIST% does not exist
ECHO Please Install Microsoft Visual studio and SET the VCDIST enviroment Variable.
ECHO SET "VCDIST%=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_python
ECHO %PYTHON_HOME% does not exist, or
ECHO PYTHON_VERSION is not SET, or
ECHO %PYTHON_DLL% does not exist.
ECHO Please install Python and SET the PYTHON_HOME enviroment Variable.
ECHO SET "PYTHON_VERSION=<VERSION NUMBER>"
ECHO SET "PYTHON_HOME=<PATH>"
ECHO SET "PYTHON_DLL=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_qt
ECHO %QTDIR% does not exist.
ECHO Please Install QT SDK and SET the QTDIR enviroment variable.
ECHO SET "QTDIR=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_qt_mismatch
ECHO %QTDIR%\..\%QT_MSVC_PATH%" does not match with your current Visual Studio, version %QT_MSVC_PATH%
ECHO Your current QT installation willraise a linking error with an MSVC version mismatch.
ECHO Please use a valid QT installation with a folder %QT_MSVC_PATH%. You can use the Qt Maintenance
ECHO Tool to add or remove compiler kits.
exit /B 1
GOTO EXIT
:err_handle_qt_compactissue
ECHO %QTDIR%" does support the current architecture selected %ARCHITECTURE%
ECHO Please use a valid QT installation with a folder %QT_MSVC_PATH%. You can use the Qt Maintenance
ECHO Tool to add or remove compiler kits.
exit /B 1
GOTO EXIT
:err_handle_pg
ECHO %PGDIR% does not exist.
ECHO Please Install Postgres and SET enviroment Variable
ECHO SET "PGDIR=<PATH>"
exit /B 1
GOTO EXIT
:err_handle_pythonvirtualenv
ECHO Python virtualenv is missing @ location - %PYTHON_HOME%\Scripts\virtualenv.exe
exit /B 1
GOTO EXIT
:ERR_HANDLER
ECHO.
ECHO Aborting build!
CD %WD%
exit /B 1
GOTO EXIT
:USAGE
ECHO Invalid command line options....
ECHO Usage: "Make.bat <x86 | amd64 | clean>"
ECHO.
exit /B 1
GOTO EXIT
:EXIT