-
Notifications
You must be signed in to change notification settings - Fork 4
/
crossrelease.py
executable file
·95 lines (79 loc) · 2.5 KB
/
crossrelease.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
#!/usr/bin/env python3
import json
import os
import shutil
import sys
import timeit
OS_OVERRIDES = {
'macos': { # https://github.com/tpoechtrager/osxcross
'CC': 'x86_64-apple-darwin19-clang',
'CXX': 'x86_64-apple-darwin19-clang++-libc++',
'STRIP': 'x86_64-apple-darwin19-strip'
},
'windows': { # sudo apt install gcc-mingw-w64 g++-mingw-w64
'CC': 'x86_64-w64-mingw32-gcc',
'CXX': 'x86_64-w64-mingw32-g++',
'STRIP': 'x86_64-w64-mingw32-strip'
}
}
TARGETS = ['Linux', 'macOS', 'Windows']
SHORTLANDS = {
'Linux': 'lin',
'macOS': 'mac',
'Windows': 'win'
}
class SomethingWentWrong(Exception):
pass
def do(command):
# os.system(command)
# return
code = os.system('{} >/dev/null 2>&1'.format(command))
if code:
raise SomethingWentWrong()
def build(target):
overrides = OS_OVERRIDES.get(target, {})
for key, value in overrides.items():
os.environ[key] = value
if target == 'linux':
os.environ['WORKING_DIR'] = os.getcwd()
# vcv-plugin-builder.sh is a script which should cd to the
# vcv-plugin-builder-linux directory and run ./build.sh
# You can get it at https://github.com/cschol/vcv-plugin-builder-linux
# It's required to easily compile plugin for the old glibc (2.23)
# to make it compatible with old Linux distributions.
do('vcv-plugin-builder.sh')
else:
do('make clean')
do('make -j{} dist'.format(os.cpu_count()))
with open('plugin.json', 'r') as fd:
manifest = json.load(fd)
slug = manifest.get('slug')
version = manifest.get('version')
destination = '{}-{}'.format(slug, version)
os.makedirs(destination, exist_ok=True)
total_time = 0
for target in TARGETS:
print('Building {} for {}...'.format(slug, target), end=' ')
sys.stdout.flush()
start = timeit.default_timer()
try:
build(target.lower())
except SomethingWentWrong:
print('Something went wrong when building {} for {}!'.format(slug, target))
sys.exit(1)
archive_name = '{}-{}-{}.zip'.format(
slug,
version,
SHORTLANDS.get(target)
)
shutil.copy(
'dist/{}'.format(archive_name),
'{}/{}'.format(destination, archive_name)
)
end = timeit.default_timer()
elapsed = end - start
total_time += elapsed
print('{}s'.format(round(elapsed, 1)))
print('Total time: {}s'.format(round(total_time, 1)))
print('Done! Release files are in {} folder.'.format(destination))
print('')