-
Notifications
You must be signed in to change notification settings - Fork 80
/
build.py
executable file
·676 lines (581 loc) · 30.3 KB
/
build.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
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
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
#!/usr/bin/env python3
#
# Author: Andreas Pohl
import os, argparse, sys, shutil, glob, subprocess, zipfile, locale, ssl, json
from urllib import request
lastLogMsgLen = 0
preferredEncoding = locale.getpreferredencoding()
def log(msg, newLine=True):
global lastLogMsgLen
end = ''
if lastLogMsgLen > 0:
clearStr = ' ' * lastLogMsgLen
print('\r' + clearStr + '\r', end='')
if newLine:
end = '\n'
lastLogMsgLen = 0
else:
lastLogMsgLen = len(msg)
print(msg, end=end)
def execute(cmd):
log('>>> ' + cmd)
if os.system(cmd) != 0:
sys.exit(1)
def execute2(cmd, filterOutput=None, successString=None, failureString=None, errLog=None):
log('>>> ' + ' '.join(cmd))
success = False
failure = False
checkRc = False
if successString is None:
checkRc = True
allOutput = []
with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as p:
for l in iter(p.stdout.readline, b''):
l = l.decode(preferredEncoding).rstrip()
if filterOutput is None:
log(l)
else:
allOutput.append(l)
if filterOutput in l:
log(l)
if successString is not None and successString in l:
success = True
if failureString is not None and failureString in l:
failure = True
p.wait()
if checkRc:
success = p.returncode == 0
if not success or failure:
log("!!! command failed: returncode={}, success={}, failure={}".format(p.returncode, success, failure))
if errLog is not None:
with open(errLog, 'w', encoding=preferredEncoding) as f:
for l in allOutput:
f.write(l + '\n')
log('... (see ' + errLog + ' for the full log)')
for l in allOutput[-20:]:
log(l)
else:
for l in allOutput:
log(l)
sys.exit(1)
elif p.returncode != 0:
log("warning: process returned {}".format(p.returncode))
def executeReadOutput(cmd):
log('>>> ' + cmd)
return subprocess.run(cmd.split(' '), stdout=subprocess.PIPE).stdout.decode(preferredEncoding).rstrip()
def getPlatform(args=None):
if args is not None and 'platform' in vars(args) and args.platform is not None:
return args.platform
if sys.platform == 'darwin':
return 'macos'
elif sys.platform in ('linux', 'linux2'):
return 'linux'
elif sys.platform == 'win32':
return 'windows'
def getArch(args):
if args is not None and 'arch' in vars(args) and args.arch is not None:
return args.arch
platform = getPlatform(args)
if platform in ('macos', 'linux'):
return executeReadOutput('uname -m')
else:
return 'x86_64'
def getPlatformArch(args):
platform = getPlatform(args)
s = platform
if platform == 'macos' and args is not None and 'macostarget' in vars(args):
s += '-' + args.macostarget
s += '-' + getArch(args)
return s
def getBuildDir(args):
if args.builddir is not None:
return args.builddir
else:
return 'build-' + getPlatformArch(args)
def getDebugSymDir(args):
return getBuildDir(args) + '/debug'
def getDepsDir(args):
depsDir = args.depsroot
if depsDir is None or not os.path.isdir(depsDir):
depsDir = os.environ.get('AG_DEPS_ROOT')
if depsDir is None or not os.path.isdir(depsDir):
log('error: missing dependencies root, use --deps-root')
exit(1)
return os.path.abspath(depsDir).replace('\\', '/') + '/' + getPlatformArch(args)
def getSDKsDir(args):
sdksDir = args.sdksroot
if sdksDir is None or not os.path.isdir(sdksDir):
sdksDir = os.environ.get('AG_SDKS_ROOT')
if sdksDir is None or not os.path.isdir(sdksDir):
return None
return os.path.abspath(sdksDir).replace('\\', '/')
def getVersion():
if not os.path.isfile('package/VERSION'):
if getPlatform(None) == 'macos':
execute('package/setversion.sh')
else:
log('can only set version from macos')
return 'dev-build'
with open('package/VERSION') as f:
return f.readline().rstrip()
return ''
def getMacToolchain(args):
toolchain = ''
if args.macostarget in ('10.7', '10.8', '10.9'):
toolchain = '/Library/Developer/10/CommandLineTools'
elif args.macostarget == '11.1':
toolchain = '/Library/Developer/13/CommandLineTools'
return toolchain
def setMacToolchain(args, toolchain=None):
newToolchain = getMacToolchain(args)
if toolchain is not None:
newToolchain = toolchain
lastToolchain = executeReadOutput('xcode-select -p')
if newToolchain != lastToolchain and os.path.isdir(newToolchain):
log('required toolchain not selected, trying xcode-select')
execute('sudo xcode-select -s ' + newToolchain)
else:
newToolchain = lastToolchain
log('Using toolchain: ' + newToolchain)
sdk = '/SDKs/MacOSX.sdk'
if args.macostarget == '11.1':
sdk = '/SDKs/MacOSX11.1.sdk'
return (newToolchain, lastToolchain, newToolchain + sdk)
def formatCode(args):
for line in subprocess.run(['git', 'status'], stdout=subprocess.PIPE).stdout.decode('utf8').split('\n'):
if ('modified:' in line or 'new file:' in line) and \
(line.endswith('.cpp') or line.endswith('.hpp')):
fname = line.split('\t')[1][12:]
execute("dos2unix " + fname)
execute("clang-format --verbose -i " + fname)
def conf(args, sysroot):
cmake_params = []
platform = getPlatform(args)
buildDir = getBuildDir(args)
depsDir = getDepsDir(args)
sdksDir = getSDKsDir(args)
if os.path.isdir(buildDir):
shutil.rmtree(buildDir, ignore_errors=True)
os.makedirs(buildDir + '/bin', exist_ok=True)
cmake_params.append('-B ' + buildDir)
cmake_params.append('-DAG_DEPS_ROOT=' + depsDir)
if sdksDir is not None:
cmake_params.append('-DAG_SDKS_ROOT=' + sdksDir)
cmake_params.append('-DAG_VST2_PLUGIN_ENABLED=ON')
if platform in ('macos', 'windows'):
cmake_params.append('-DAG_AAX_PLUGIN_ENABLED=ON')
if platform in ('macos', 'linux'):
cmake_params.append('-DCMAKE_BUILD_TYPE=' + args.buildtype)
shutil.copy(depsDir + '/bin/crashpad_handler', buildDir + '/bin')
if platform == 'macos':
cmake_params.append('-DCMAKE_OSX_ARCHITECTURES=' + getArch(args))
cmake_params.append('-DCMAKE_OSX_SYSROOT=' + sysroot)
cmake_params.append('-DAG_MACOS_TARGET=' + args.macostarget)
if not args.nosigning:
execute('codesign --force --sign AudioGridder --timestamp=none ' + buildDir + '/bin/crashpad_handler')
if args.withasan:
cmake_params.append('-DAG_ENABLE_ASAN=ON')
if platform == 'windows':
cmake_params.append('-A x64')
shutil.copy(depsDir + '/bin/crashpad_handler.exe', buildDir + '/bin')
if args.sentrydsn is not None:
cmake_params.append('-DAG_ENABLE_SENTRY=ON')
cmake_params.append('-DAG_SENTRY_DSN=' + args.sentrydsn)
if args.nosigning:
cmake_params.append('-DAG_ENABLE_CODE_SIGNING=OFF')
if args.disablecopystep:
cmake_params.append('-DAG_ENABLE_DEBUG_COPY_STEP=OFF')
if args.withtests:
cmake_params.append('-DAG_WITH_TESTS=ON')
cmake_command = 'cmake ' + ' '.join(cmake_params)
if args.vscode:
os.makedirs('.vscode', exist_ok=True)
settings = dict()
with open('.vscode/settings.json', 'r') as f:
settings = json.load(f)
settings['cmake.buildDirectory'] = '${workspaceFolder}/' + buildDir
settings['cmake.configureSettings'] = dict()
for p in cmake_params:
if p.startswith('-D') and not p.startswith('-DCMAKE_BUILD_TYPE'):
(name, val) = p[2:].split('=')
if val == 'ON':
val = True
elif val == 'OFF':
val = False
settings['cmake.configureSettings'][name] = val
log('updating vscode settings...')
with open('.vscode/settings.json', 'w') as f:
json.dump(settings, f, indent=4)
else:
execute(cmake_command)
def build(args):
cmake_params = []
platform = getPlatform(args)
buildDir = getBuildDir(args)
cmake_params.append('--build ' + buildDir)
if platform == 'windows':
cmake_params.append('--config ' + args.buildtype)
if args.parallel:
cmake_params.append('--parallel')
elif args.jobs > 0:
cmake_params.append('-j ' + str(args.jobs))
if not args.target is None:
for t in args.target:
cmake_params.append('--target ' + t)
if args.clean:
cmake_params.append('--clean-first')
if args.verbose:
cmake_params.append('--verbose')
cmake_command = 'cmake ' + ' '.join(cmake_params)
execute(cmake_command)
def packs(args):
version = getVersion()
macPackages = []
macBuildDirs = []
for p in args.platforms.split(','):
platform = None
arch = None
macosTarget = None
buildDir = None
parts = p.split('-')
platform = parts[0]
if len(parts) < 3:
arch = parts[1]
buildDir = 'build-' + platform + '-' + arch
else:
macosTarget = parts[1]
arch = parts[2]
buildDir = 'build-' + platform + '-' + macosTarget + '-' + arch
packReal(platform, arch, version, buildDir, macosTarget)
if args.macosarchives:
serverName = 'package/build/AudioGridderServer_' + version + '_macOS'
pluginName = 'package/build/AudioGridderPlugin_' + version + '_macOS'
if macosTarget == '10.7':
serverName += '-10.7'
pluginName += '-10.7'
serverName += '-' + arch + '.pkg'
pluginName += '-' + arch + '.pkg'
macPackages.append(serverName)
macPackages.append(pluginName)
macBuildDirs.append(buildDir)
if args.macosarchives:
execute('zip -j -9 package/build/AudioGridder_' + version + '-MacOS-Installers.zip ' + ' '.join(macPackages))
execute('zip -r -9 package/build/AudioGridder_' + version + '-MacOS.zip ' + ' '.join(macBuildDirs) + \
' -i "*/bin/*" "*/lib/*" -x "*.a"')
def pack(args):
packReal(getPlatform(args), getArch(args), getVersion(), getBuildDir(args), args.macostarget)
def packReal(platform, arch, version, buildDir, macosTarget):
if platform == 'macos':
if arch == 'universal':
execute('package/createUniversalBinaries.sh')
serverProject = 'package/AudioGridderServer-'
serverTarget = 'package/build/AudioGridderServer_' + version + '_macOS'
pluginProject = 'package/AudioGridderPlugin-'
pluginTarget = 'package/build/AudioGridderPlugin_' + version + '_macOS'
if macosTarget == '10.7':
serverProject += '10.7-'
serverTarget += '-10.7'
pluginProject += '10.7-'
pluginTarget += '-10.7'
serverProject += arch + '.pkgproj'
serverTarget += '-' + arch + '.pkg'
pluginProject += arch + '.pkgproj'
pluginTarget += '-' + arch + '.pkg'
execute('packagesbuild --package-version "' + version + '" ' + serverProject)
execute('packagesbuild --package-version "' + version + '" ' + pluginProject)
os.rename('package/build/AudioGridderServer.pkg', serverTarget)
os.rename('package/build/AudioGridderPlugin.pkg', pluginTarget)
elif platform == 'windows':
os.chdir('package')
execute('"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /Obuild AudioGridderServer.iss')
execute('"C:\Program Files (x86)\Inno Setup 6\ISCC.exe" /Obuild AudioGridderPlugin.iss')
log('creating installers archive...')
os.chdir('build')
with zipfile.ZipFile('AudioGridder_' + version + '-Windows-Installers.zip', 'w',
compression=zipfile.ZIP_DEFLATED) as zf:
zf.write('AudioGridderServer_' + version + '.exe')
zf.write('AudioGridderPlugin_' + version + '.exe')
zf.close()
log('creating no-installers archive...')
os.chdir('../../' + buildDir)
with zipfile.ZipFile('../package/build/AudioGridder_' + version + '-Windows.zip', 'w',
compression=zipfile.ZIP_DEFLATED) as zf:
for f in glob.glob('lib/*/*.dll') + \
glob.glob('lib/*/*.vst3') + \
glob.glob('lib/*/*.aaxplugin') + \
glob.glob('bin/*.exe'):
zf.write(f)
zf.close()
elif platform == 'linux':
installers = []
instName = 'package/build/AudioGridderPlugin_' + version + '-Linux.sh'
installers.append(instName)
instDir = buildDir + '/inst'
if os.path.isdir(instDir):
shutil.rmtree(instDir)
vst2Dir = instDir + '/vst'
vst3Dir = instDir + '/vst3'
binDir = instDir + '/bin'
os.makedirs(vst2Dir)
os.makedirs(vst3Dir)
os.makedirs(binDir)
configureFile('package/install_linux_plugin.sh', instDir + '/install_linux_plugin.sh',
{'version': version})
os.chmod(instDir + '/install_linux_plugin.sh', 0o755)
for p in ['AudioGridder', 'AudioGridderInst', 'AudioGridderMidi']:
shutil.copyfile(buildDir + '/lib/lib' + p + '.so', vst2Dir + '/' + p + '.so')
vst3So = p + '.so'
vst3Bundle = vst3Dir + '/' + p + '.vst3/Contents/x86_64-linux'
os.makedirs(vst3Bundle)
shutil.copyfile(buildDir + '/lib/' + vst3So, vst3Bundle + '/' + vst3So)
for f in ['AudioGridderPluginTray', 'crashpad_handler']:
shutil.copyfile(buildDir + '/bin/' + f, binDir + '/' + f)
execute('bash package/makeself.sh --bzip2 ' + instDir + ' ' + instName + ' "installer files" ./install_linux_plugin.sh')
shutil.rmtree(instDir)
instName = 'package/build/AudioGridderServer_' + version + '-Linux.sh'
installers.append(instName)
instDir = buildDir + '/inst'
if os.path.isdir(instDir):
shutil.rmtree(instDir)
binDir = instDir + '/bin'
resDir = instDir + '/resources'
os.makedirs(binDir)
os.makedirs(resDir)
configureFile('package/install_linux_server.sh', instDir + '/install_linux_server.sh',
{'version': version})
os.chmod(instDir + '/install_linux_server.sh', 0o755)
for f in ['AudioGridderServer', 'crashpad_handler']:
shutil.copyfile(buildDir + '/bin/' + f, binDir + '/' + f)
shutil.copyfile('Server/Resources/icon64.png', resDir + '/icon64.png')
shutil.copyfile('package/audiogridderserver.desktop', resDir + '/audiogridderserver.desktop')
execute('bash package/makeself.sh --bzip2 ' + instDir + ' ' + instName + ' "installer files" ./install_linux_server.sh')
shutil.rmtree(instDir)
execute('zip -j -9 package/build/AudioGridder_' + version + '-Linux-Installers.zip ' + ' '.join(installers))
execute('zip -r -9 package/build/AudioGridder_' + version + '-Linux.zip ' + buildDir + \
' -i "*/bin/*" "*/lib/*" -x "*.a" "*/JUCE/*"')
def configureFile(inFile, outFile, variables):
with open(inFile, 'r') as ifile:
with open(outFile, 'w') as ofile:
for l in ifile.readlines():
for k in variables.keys():
l = l.replace('#' + k + '#', variables[k])
ofile.write(l)
def upload(args):
sentry_params = []
sentry_params.append('--auth-token ' + args.sentryauth)
sentry_params.append('upload-dif -o e47 -p audiogridder')
sentry_params.append(getDebugSymDir(args))
sentry_command = 'sentry-cli ' + ' '.join(sentry_params)
execute(sentry_command)
def archive(args):
platform = getPlatform(args)
version = getVersion()
targetDir = args.dest + '/Builds/' + version
if not os.path.isdir(targetDir):
os.makedirs(targetDir)
debSymDir = getDebugSymDir(args)
if not os.path.isdir(debSymDir):
log('error: ' + debSymDir + ' does not exists')
exit(1)
log('copying ' + debSymDir + ' -> ' + targetDir + ' ...')
if os.path.isdir(targetDir + '/' + debSymDir):
shutil.rmtree(targetDir + '/' + debSymDir)
shutil.copytree(debSymDir, targetDir + '/' + debSymDir)
def downloadFile(url, target):
log('-> downloading ' + target)
# disable ssl verify
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
with request.urlopen(url, context=ctx) as u, open(target, 'wb') as f:
f.write(u.read())
def extractFile(f):
log('-> extracting ' + f)
with zipfile.ZipFile(f, 'r') as zf:
zf.extractall(os.path.dirname(f))
def tests(args):
buildDir = getBuildDir(args)
platform = getPlatform(args)
if not os.path.isdir('TestsData'):
log('downloading tests data...')
os.mkdir('TestsData')
os.mkdir('TestsData/macos')
os.mkdir('TestsData/windows')
downloadFile('http://stone-voices.ru/download.php?file=dreverb_1.0_mac_86_64.zip',
'TestsData/macos/dreverb_1.0_mac_86_64.zip')
downloadFile('http://stone-voices.ru/download.php?file=dreverb_1.0_win_86_64.zip',
'TestsData/windows/dreverb_1.0_win_86_64.zip')
downloadFile('https://3fef17d2-0d9a-400d-abff-458b86c18a2a.usrfiles.com/archives/3fef17_50d7b255dbd34b3ca8c99c4e4db85bca.zip',
'TestsData/macos/2rulessynth1.1-mac.zip')
downloadFile('https://3fef17d2-0d9a-400d-abff-458b86c18a2a.usrfiles.com/archives/3fef17_26e379c8b1734ac4bd485cd2596ac970.zip',
'TestsData/windows/2rulessynth1.1-win.zip')
downloadFile('https://pluginguru.net/wp-content/uploads/2022/01/LoudMax_v1_41_Mac.zip', 'TestsData/macos/LoudMax_v1_41_Mac.zip')
downloadFile('https://www.dropbox.com/s/t5pqcl7xnj6mwn8/LoudMax_v1_41_WIN_VST3.zip?dl=1', 'TestsData/windows/LoudMax_v1_41_WIN_VST3.zip')
log('extracting tests data...')
for f in glob.glob('TestsData/**/*.zip'):
extractFile(f)
for t in ['testrunner-server', 'testrunner-fx']:
if platform == 'windows':
t = t + '.exe'
filterOutput = '|testrunner|'
errLog = 'tests-' + getPlatformArch(args) + '.log'
if args.verbose:
filterOutput = None
errLog = None
if os.path.isfile(buildDir + '/bin/' + t):
if platform == 'windows':
if shutil.which("gdb.exe"):
execute2(['gdb', '.\\' + buildDir + '\\bin\\' + t, '--batch', '--ex', 'run', '--ex', 'thread apply all bt'],
filterOutput=filterOutput, errLog=errLog)
else:
execute2(['.\\' + buildDir + '\\bin\\' + t], filterOutput=filterOutput, errLog=errLog)
elif platform == 'macos':
execute2(['lldb', buildDir + '/bin/' + t , '-o', 'run', '-o', 'bt all', '-o', 'exit'],
filterOutput=filterOutput, successString='exited with status = 0', errLog=errLog)
else:
execute2(['gdb', buildDir + '/bin/' + t, '--batch', '--ex', 'run', '--ex', 'thread apply all bt'],
filterOutput=filterOutput, successString='exited normally', errLog=errLog)
else:
log('error: unit test runner ' + t + ' missing')
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description='AudioGridder Build Script.')
subparsers = parser.add_subparsers(title='Commands', dest='mode',
help='Available commands, use <command> -h for more info')
defaultPlatform = getPlatform(None)
defaultArch = getArch(None)
if defaultPlatform == 'macos':
parser.add_argument('-k', '--unlock-keychain', dest='keychainPass', metavar='PASSWORD', type=str, default=None,
help='Unlock the default keychain on macOS using the given password')
parser_conf = subparsers.add_parser('conf', help='Configure the build system')
parser_conf.add_argument('-t', '--type', dest='buildtype', metavar='TYPE', type=str, default='RelWithDebInfo',
help='Build type (default: %(default)s)')
parser_conf.add_argument('-b', '--build-dir', dest='builddir', metavar='DIR', type=str, default=None,
help='Override the build directory (default: %(default)s)')
parser_conf.add_argument('--vscode', dest='vscode', action='store_true', default=False,
help='Do not run cmake, just prepare the build directory and update the VSCode settings (default: %(default)s)')
parser_conf.add_argument('--platform', dest='platform', metavar='PLATFORM', type=str, default=defaultPlatform,
choices=['macos', 'windows', 'linux'],
help='OS platform (default: %(default)s)')
parser_conf.add_argument('--arch', dest='arch', metavar='ARCH', type=str, default=defaultArch,
help='Processor architecture (default: %(default)s)')
parser_conf.add_argument('--macos-target', dest='macostarget', metavar='TRGT', type=str, default='10.8',
help='MacOS deplyoment target (default: %(default)s)')
parser_conf.add_argument('--macos-toolchain', dest='macostoolchain', metavar='TC', type=str, default=None,
help='Use specific MacOS build toolchain (default: %(default)s)')
parser_conf.add_argument('--sentry-dsn', dest='sentrydsn', metavar='DSN', type=str, default=None,
help='Sentry DSN for crash reporting (default: %(default)s)')
parser_conf.add_argument('--disable-signing', dest='nosigning', action='store_true', default=False,
help='Disable code signing (default: %(default)s)')
parser_conf.add_argument('--disable-copy-step', dest='disablecopystep', action='store_true', default=False,
help='Disable copying plugins into plugin folders in Debug mode on MacOS (default: %(default)s)')
parser_conf.add_argument('--enable-tests', dest='withtests', action='store_true', default=False,
help='Enable unit tests (default: %(default)s)')
parser_conf.add_argument('--enable-asan', dest='withasan', action='store_true', default=False,
help='Enable Clangs AddressSanitizer for the server on macOS (only with -t Debug, default: %(default)s)')
parser_conf.add_argument('--deps-root', dest='depsroot', type=str, default='audiogridder-deps',
help='Dependencies root directory (git clone https://github.com/apohl79/audiogridder-deps.git)')
parser_conf.add_argument('--sdks-root', dest='sdksroot', type=str, default='audiogridder-sdks',
help='AAX & VST2 SDK root directory (Non public, git clone https://github.com/apohl79/audiogridder-sdks.git)')
parser_build = subparsers.add_parser('build', help='Build the binaries')
parser_build.add_argument('-t', '--type', dest='buildtype', metavar='TYPE', type=str, default='RelWithDebInfo',
help='Build type for Windows builds (default: %(default)s)')
parser_build.add_argument('-b', '--build-dir', dest='builddir', metavar='DIR', type=str, default=None,
help='Override the build directory (default: %(default)s)')
parser_build.add_argument('--platform', dest='platform', metavar='PLATFORM', type=str, default=defaultPlatform,
choices=['macos', 'windows', 'linux'],
help='OS platform (default: %(default)s)')
parser_build.add_argument('--arch', dest='arch', metavar='ARCH', type=str, default=defaultArch,
help='Processor architecture (default: %(default)s)')
parser_build.add_argument('--macos-target', dest='macostarget', metavar='TRGT', type=str, default='10.8',
help='MacOS deplyoment target (default: %(default)s)')
parser_build.add_argument('--target', dest='target', type=str, action='append',
help='Set a specific build target')
parser_build.add_argument('-c', '--clean', dest='clean', action='store_true', default=False,
help='Run cleanup before building')
parser_build.add_argument('-p', '--parallel', dest='parallel', action='store_true', default=False,
help='Use multiple CPU cores (default: %(default)s)')
parser_build.add_argument('-j', '--jobs', dest='jobs', metavar='N', type=int, default=0,
help='Use N CPU cores')
parser_build.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False,
help='Show compile/link commands (default: %(default)s)')
parser_pack = subparsers.add_parser('pack', help='Create installer packages')
parser_pack.add_argument('-b', '--build-dir', dest='builddir', metavar='DIR', type=str, default=None,
help='Override the build directory (default: %(default)s)')
parser_pack.add_argument('--platform', dest='platform', metavar='PLATFORM', type=str, default=defaultPlatform,
choices=['macos', 'windows', 'linux'],
help='OS platform (default: %(default)s)')
parser_pack.add_argument('--arch', dest='arch', metavar='ARCH', type=str, default=defaultArch,
help='Processor architecture (default: %(default)s)')
parser_pack.add_argument('--macos-target', dest='macostarget', metavar='TRGT', type=str, default='10.8',
help='MacOS deplyoment target (default: %(default)s)')
parser_packs = subparsers.add_parser('packs', help='Create installer packages for multiple platforms')
parser_packs.add_argument('--platforms', dest='platforms', metavar='PLATFORMS', type=str, required=True,
help='List of OS platforms in the form <os>[-version]-<arch> separated by comma')
parser_packs.add_argument('--create-macos-archives', dest='macosarchives', action='store_true', default=False,
help='Create archives for all MacOS targets')
parser_upload = subparsers.add_parser('upload', help='Upload debug symbols to sentry')
parser_upload.add_argument('-b', '--build-dir', dest='builddir', metavar='DIR', type=str, default=None,
help='Override the build directory (default: %(default)s)')
parser_upload.add_argument('--platform', dest='platform', metavar='PLATFORM', type=str, default=defaultPlatform,
choices=['macos', 'windows', 'linux'],
help='OS platform (default: %(default)s)')
parser_upload.add_argument('--arch', dest='arch', metavar='ARCH', type=str, default=defaultArch,
help='Processor architecture (default: %(default)s)')
parser_upload.add_argument('--macos-target', dest='macostarget', metavar='TRGT', type=str, default='10.8',
help='MacOS deplyoment target (default: %(default)s)')
parser_upload.add_argument('--sentry-auth-token', dest='sentryauth', metavar='AUTH', type=str, required=True,
help='Sentry API auth token')
parser_archive = subparsers.add_parser('archive', help='Archive binaries and debug symbols')
parser_archive.add_argument('-b', '--build-dir', dest='builddir', metavar='DIR', type=str, default=None,
help='Override the build directory (default: %(default)s)')
parser_archive.add_argument('--platform', dest='platform', metavar='PLATFORM', type=str, default=defaultPlatform,
choices=['macos', 'windows', 'linux'],
help='OS platform (default: %(default)s)')
parser_archive.add_argument('--arch', dest='arch', metavar='ARCH', type=str, default=defaultArch,
help='Processor architecture (default: %(default)s)')
parser_archive.add_argument('--macos-target', dest='macostarget', metavar='TRGT', type=str, default='10.8',
help='MacOS deplyoment target (default: %(default)s)')
parser_archive.add_argument('--dest', dest='dest', metavar='DIR', type=str, required=True,
help='Destination directory')
parser_tests = subparsers.add_parser('tests', help='Run the unit tests')
parser_tests.add_argument('-b', '--build-dir', dest='builddir', type=str, default=None,
help='Build directory, if not set it will be "build-<platform>-<arch>"')
parser_tests.add_argument('--arch', dest='arch', type=str, default='x86_64',
help='CPU architecture (default: %(default)s)')
parser_tests.add_argument('-v', '--verbose', dest='verbose', action='store_true', default=False,
help='Show tests log (default: %(default)s)')
parser_format = subparsers.add_parser('format', help='Format C++ files that changed')
args = parser.parse_args()
newToolchain = ''
lastToolchain = ''
sysroot = ''
if getPlatform(args) == 'macos':
if 'arch' in vars(args) and args.arch == 'arm64':
args.macostarget = '11.1'
if args.mode == 'conf':
(newToolchain, lastToolchain, sysroot) = setMacToolchain(args, args.macostoolchain)
if 'keychainPass' in vars(args) and args.keychainPass is not None:
execute('security unlock -p ' + args.keychainPass)
if args.mode == 'conf':
conf(args, sysroot)
elif args.mode == 'build':
build(args)
elif args.mode == 'pack':
pack(args)
elif args.mode == 'packs':
packs(args)
elif args.mode == 'upload':
upload(args)
elif args.mode == 'archive':
archive(args)
elif args.mode == 'tests':
tests(args)
elif args.mode == 'format':
formatCode(args)
else:
parser.print_usage()
if getPlatform(args) == 'macos' and newToolchain != lastToolchain:
execute('sudo xcode-select -s ' + lastToolchain)
if __name__ == "__main__":
main()