-
Notifications
You must be signed in to change notification settings - Fork 3
/
make_installer_framework.py
427 lines (372 loc) · 11.3 KB
/
make_installer_framework.py
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
# -*- python -*-
# ex: set syntax=python:
import os
from typing import List
from buildbot.plugins import schedulers, steps, util
# from .util import MACOS_REPO, WIN64_REPO
WIN64_REPO = 5
MACOS_REPO = 6
# Common
PROJECT_NAME = "inst_framework"
DESCRIPTION = "Build and publish tools for Qt and installer framework"
QT_PACKAGE_NAME = "inst_framework_qt"
INSTALLER_PACKAGE_NAME = "inst_framework"
LOGNAME = "stdio"
WORK_DIR = "build"
BUILD_SUBDIR_NAME = "build"
# Build constants
VM_CPU_COUNT = 6
MAC_OS_MIN_VERSION = "10.14"
MAC_OS_SDKS_PATH = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs"
REPKA_SCRIPT_NAME = "repka_release.py"
QT_GIT_URL = "https://github.com/nextgis-borsch/lib_qt5.git"
INSTALLER_GIT_URL = "https://github.com/nextgis/nextgis_installer.git"
USERNAME = "buildbot"
userkey = os.environ.get("BUILDBOT_PASSWORD")
# Helpers
def cmake_qt_configure_definition(configure_args: List[str]) -> str:
return "-DQT_CONFIGURE_ARGS=" + ";".join(
map(lambda arg: arg.replace(" ", ";"), configure_args)
)
# Build params
QT_CONFIGURE_COMMON_ARGS = [
"-accessibility",
"-no-icu",
"-no-sql-sqlite",
"-no-qml-debug",
"-no-feature-ftp",
"-no-feature-socks5",
"-skip qtactiveqt",
"-skip qtandroidextras",
"-skip qtcharts",
"-skip qtconnectivity",
"-skip qtdatavis3d",
"-skip qtdoc",
"-skip qtgamepad",
"-skip qtgraphicaleffects",
"-skip qtlocation",
"-skip qtmultimedia",
"-skip qtpurchasing",
"-skip qtquickcontrols",
"-skip qtquickcontrols2",
"-skip qtremoteobjects",
"-skip qtscript",
"-skip qtscxml",
"-skip qtsensors",
"-skip qtserialbus",
"-skip qtserialport",
"-skip qtspeech",
"-skip qtvirtualkeyboard",
"-skip qtwayland",
"-skip qtwebchannel",
"-skip qtwebengine",
"-skip qtwebglplugin",
"-skip qtwebsockets",
"-skip qtwebview",
"-skip qt3d",
"-skip qtxmlpatterns",
"-nomake examples",
"-nomake tests",
# Old options
# "-skip qtlottie",
# "-skip qtenginio",
# "-skip qtquick1",
# "-skip qtwebkit",
]
QT_CONFIGURE_WIN_ARGS = [
*QT_CONFIGURE_COMMON_ARGS,
"-no-opengl",
]
QT_CONFIGURE_MAC_ARGS = [
*QT_CONFIGURE_COMMON_ARGS,
"-qt-zlib",
"-qt-libpng",
"-qt-libjpeg",
"-no-cups",
]
CMAKE_QT_COMMON_DEFS = [
"-DBUILD_STATIC_LIBS=TRUE",
"-DWITH_OpenSSL_EXTERNAL=ON",
"-DSUPPRESS_VERBOSE_OUTPUT=ON",
"-DCMAKE_BUILD_TYPE=Release",
"-DSKIP_DEFAULTS=ON",
"-DWITH_ZLIB=OFF",
"-DWITH_Freetype=OFF",
"-DWITH_JPEG=OFF",
"-DWITH_PNG=OFF",
"-DWITH_TIFF=OFF",
"-DWITH_SQLite3=OFF",
"-DWITH_PostgreSQL=OFF",
"-DWITH_WEBPDEMUX=OFF",
"-DWITH_WEBPMUX=OFF",
"-DWITH_WEBP=OFF",
"-DWITH_HarfBuzz=OFF",
"-DCREATE_CPACK_LIGHT=ON",
]
CMAKE_QT_WIN_DEFS = [
*CMAKE_QT_COMMON_DEFS,
cmake_qt_configure_definition(QT_CONFIGURE_WIN_ARGS),
]
CMAKE_QT_MAC_DEFS = [
*CMAKE_QT_COMMON_DEFS,
cmake_qt_configure_definition(QT_CONFIGURE_MAC_ARGS),
]
CMAKE_CONFIGURE_QT_WIN_ARGS = [
*CMAKE_QT_WIN_DEFS,
"-G",
"Visual Studio 16 2019",
"-A",
"x64",
]
CMAKE_CONFIGURE_QT_MAC_ARGS = [
*CMAKE_QT_MAC_DEFS,
"-DCMAKE_OSX_SYSROOT=" + MAC_OS_SDKS_PATH + "/MacOSX.sdk",
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + MAC_OS_MIN_VERSION,
]
# qt_without_openssl = False
# if qt_without_openssl:
# qt_args = [
# "-DBUILD_STATIC_LIBS=TRUE",
# "-DWITH_OpenSSL=OFF",
# "-DSUPPRESS_VERBOSE_OUTPUT=ON",
# "-DCMAKE_BUILD_TYPE=Release",
# "-DSKIP_DEFAULTS=ON",
# "-DQT_CONFIGURE_ARGS=-accessibility;-no-ssl;-no-opengl;-no-icu;-no-sql-sqlite;-no-qml-debug;-skip;qtactiveqt;-skip;qtlocation;-skip;qtmultimedia;-skip;qtserialport;-skip;qtsensors;-skip;qtquickcontrols;-skip;qtquickcontrols2;-skip;qt3d;-skip;qtconnectivity;-skip;qtandroidextras;-skip;qtcanvas3d;-skip;qtcharts;-skip;qtdatavis3d;-skip;qtgamepad;-skip;qtpurchasing;-skip;qtserialbus;-skip;qtspeech;-skip;qtvirtualkeyboard;-skip;qtwayland;-skip;qtwebchannel;-skip;qtwebengine;-skip;qtwebsockets;-skip;qtxmlpatterns;-skip;qtwebview;-no-feature-ftp;-no-feature-socks5",
# "-DWITH_ZLIB=OFF",
# "-DWITH_Freetype=OFF",
# "-DWITH_JPEG=OFF",
# "-DWITH_PNG=OFF",
# "-DWITH_SQLite3=OFF",
# "-DWITH_PostgreSQL=OFF",
# "-DCREATE_CPACK_LIGHT=ON",
# ]
CMAKE_CONFIGURE_QT_WIN_COMMAND = ["cmake", *CMAKE_CONFIGURE_QT_WIN_ARGS, ".."]
CMAKE_CONFIGURE_QT_MAC_COMMAND = ["cmake", *CMAKE_CONFIGURE_QT_MAC_ARGS, ".."]
CMAKE_BUILD_COMMAND = ["cmake", "--build", ".", "--config", "release"]
CMAKE_BUILD_QT_WIN_COMMAND = [*CMAKE_BUILD_COMMAND, "--", "/m:" + str(VM_CPU_COUNT)]
CMAKE_BUILD_QT_MAC_COMMAND = [*CMAKE_BUILD_COMMAND, "--", "-j" + str(VM_CPU_COUNT)]
# Build config
PLATFORMS = [
{
"name": "win",
"os": "win64",
"worker": "build-win-py3",
"repo_id": WIN64_REPO,
"env": {},
"cmake_configure_qt_command": CMAKE_CONFIGURE_QT_WIN_COMMAND,
"cmake_build_qt_command": CMAKE_BUILD_QT_WIN_COMMAND,
},
{
"name": "mac",
"os": "mac",
"worker": "build-mac-py3",
"repo_id": MACOS_REPO,
"env": {
"PATH": ["/usr/local/bin", "${PATH}"],
"MACOSX_DEPLOYMENT_TARGET": MAC_OS_MIN_VERSION,
},
"cmake_configure_qt_command": CMAKE_CONFIGURE_QT_MAC_COMMAND,
"cmake_build_qt_command": CMAKE_BUILD_QT_MAC_COMMAND,
},
]
c = {}
c["change_source"] = []
c["schedulers"] = []
c["builders"] = []
force_scheduler = schedulers.ForceScheduler(
name=PROJECT_NAME + "_force",
label="Make installer framework",
buttonName="Make installer framework",
builderNames=list(
map(lambda platform: f"{PROJECT_NAME}_{platform['name']}", PLATFORMS)
),
)
c["schedulers"].append(force_scheduler)
for platform in PLATFORMS:
qt_code_dir = os.path.join(WORK_DIR, "qt_code")
qt_build_dir = os.path.join(qt_code_dir, BUILD_SUBDIR_NAME)
build_factory = util.BuildFactory()
# Clone qt repository
build_factory.addStep(
steps.Git(
name="Clone Qt repository",
repourl=QT_GIT_URL,
mode="full",
method="clobber",
submodules=False,
shallow=True,
alwaysUseLatest=True,
workdir=qt_code_dir,
)
)
# Make build dir
build_factory.addStep(
steps.MakeDirectory(
name="Make Qt build directory",
dir=qt_build_dir,
)
)
# Configure qt via cmake
build_factory.addStep(
steps.ShellCommand(
command=platform["cmake_configure_qt_command"],
name="Configure Qt build",
haltOnFailure=True,
timeout=125 * 60,
workdir=qt_build_dir,
env=platform["env"],
)
)
# Build qt
build_factory.addStep(
steps.ShellCommand(
name="Build Qt",
command=platform["cmake_build_qt_command"],
haltOnFailure=True,
workdir=qt_build_dir,
env=platform["env"],
)
)
# Get uploader
build_factory.addStep(
steps.FileDownload(
name="Download Repka script for Qt",
mastersrc=os.path.join("worker", REPKA_SCRIPT_NAME),
workerdest=os.path.join("qt_code", REPKA_SCRIPT_NAME),
haltOnFailure=True,
)
)
# Send package to rm.nextgis
build_factory.addStep(
steps.ShellCommand(
name=f"Publish {QT_PACKAGE_NAME} to Repka",
command=[
"python3",
REPKA_SCRIPT_NAME,
"--repo_id",
platform["repo_id"],
"--asset_build_path",
BUILD_SUBDIR_NAME,
"--packet_name",
QT_PACKAGE_NAME,
"--login",
USERNAME,
"--password",
userkey,
],
haltOnFailure=True,
workdir=qt_code_dir,
env=platform["env"],
)
)
# 2. Build installer framework
installer_code_dir = os.path.join(WORK_DIR, "installer_code")
installer_build_dir = os.path.join(installer_code_dir, BUILD_SUBDIR_NAME)
# Clone NextGIS installer repository
build_factory.addStep(
steps.Git(
name="Clone installer repository",
repourl=INSTALLER_GIT_URL,
mode="full",
method="clobber",
submodules=False,
shallow=True,
alwaysUseLatest=True,
workdir=installer_code_dir,
)
)
# Create build directory
build_factory.addStep(
steps.MakeDirectory(
name="Make installer build directory",
dir=installer_build_dir,
)
)
build_installer_cmd = [
"python",
"build_installer_bb.py",
"--qtdir",
qt_build_dir,
"--make",
]
separator = "/"
if platform["name"] == "win":
separator = "\\"
build_installer_cmd.append("nmake")
elif platform["name"] == "mac":
build_installer_cmd.append("make")
build_factory.addStep(
steps.ShellCommand(
command=build_installer_cmd,
name="Build installer framework",
haltOnFailure=True,
workdir=os.path.join(installer_code_dir, "qtifw", "tools"),
env=platform["env"],
)
)
create_archive = [
"cmake",
"-E",
"tar",
"cfv",
"archive.zip",
"--format=zip",
"qtifw_build" + separator + "bin",
]
build_factory.addStep(
steps.ShellCommand(
command=create_archive,
name="Archive installer binaries",
haltOnFailure=True,
workdir=installer_code_dir,
env=platform["env"],
)
)
build_factory.addStep(
steps.StringDownload(
"0.0.0\nnow\narchive",
workerdest="version.str",
workdir=installer_code_dir,
name="Create version file",
)
)
# 3. Upload installer framework to rm.nextgis
build_factory.addStep(
steps.FileDownload(
name="Download Repka script for installer",
mastersrc=os.path.join("worker", REPKA_SCRIPT_NAME),
workerdest=os.path.join("installer_code", REPKA_SCRIPT_NAME),
haltOnFailure=True,
)
)
# Send inst_framework to rm.nextgis
build_factory.addStep(
steps.ShellCommand(
name=f"Publish {INSTALLER_PACKAGE_NAME} to Repka",
command=[
"python3",
REPKA_SCRIPT_NAME,
"--repo_id",
platform["repo_id"],
"--asset_build_path",
".",
"--packet_name",
INSTALLER_PACKAGE_NAME,
"--login",
USERNAME,
"--password",
userkey,
],
haltOnFailure=True,
workdir=installer_code_dir,
env=platform["env"],
)
)
builder = util.BuilderConfig(
name=PROJECT_NAME + "_" + platform["name"],
workernames=[platform["worker"]],
factory=build_factory,
description=f"{DESCRIPTION} [" + platform["name"] + "]",
tags=["installer", platform["os"]],
)
c["builders"].append(builder)