-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.py
111 lines (102 loc) · 3.12 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
##\package build
# \brief Builds binaries and installer for MS Windows
#
# Vegard Fiksdal (C) 2024
#
import PyInstaller.__main__
import shutil,sys
from common import *
def preclean():
print('Deleting old build environment')
try:
shutil.rmtree('build')
except:
pass
try:
shutil.rmtree('dist')
except:
pass
def build_bin():
print('Building v'+App.getVersion())
PyInstaller.__main__.run(['qmbtester.py','--onefile','--noconsole','--icon','extras/mbtester.ico','--name','qmbtester'])
PyInstaller.__main__.run(['mbtester.py','--onefile','--name','mbtester'])
print('Copying accompanying files')
shutil.copy('extras/mbtester.ico','dist')
shutil.copy('README.md','dist')
shutil.copy('LICENSE','dist')
for file in os.listdir('.'):
if file.upper().endswith('.JSON'):
shutil.copy(file,'dist')
def build_zip():
print('Archiving output files')
shutil.make_archive('mbtester-'+App.getVersion(), 'zip', 'dist')
#shutil.move('mbtester-binaries-'+App.getVersion()+'.zip','dist')
def build_installer():
print('Making installer')
nsispath = os.environ.get("PROGRAMFILES(X86)")+'\\NSIS\\makensis.exe'
if os.path.exists(nsispath):
shutil.copy('extras\\mbtester.nsi','dist')
os.system('"'+nsispath+'"'+' /NOCD dist\\mbtester.nsi')
shutil.move('mbtester.exe','mbtester-installer-'+App.getVersion()+'.exe')
#shutil.move('mbtester-installer-'+App.getVersion()+'.exe','dist')
else:
print('Could not find NSIS -- Skipping')
def postclean():
print('Cleaning intermediary files')
for file in os.listdir('.'):
if file.upper().endswith('.SPEC'):
os.unlink(file)
def mrproper():
os.system('git clean -d -x -n')
if input('Type yes to confirm: ').upper()=='YES':
os.system('git clean -d -x -f')
else:
print('Deep clean was skipped')
print('Ivalid build parameter: '+arg)
print('Use '+sys.argv[0]+' --help for usage information')
if len(sys.argv)==2:
arg=sys.argv[1]
else:
print('Ivalid build parameters: '+str(sys.argv[1:]))
print('')
arg='--help'
if arg=='--build':
preclean()
build_bin()
postclean()
elif arg=='--archive':
preclean()
build_bin()
build_zip()
postclean()
elif arg=='--release':
preclean()
build_bin()
build_installer()
postclean()
elif arg=='--all':
preclean()
build_bin()
build_zip()
build_installer()
postclean()
elif arg=='--clean':
preclean()
postclean()
elif arg=='--mrproper':
mrproper()
elif arg=='--help':
print('MBTester build script')
print('Usage: '+sys.argv[0]+' SWITCH')
print('')
print('Switches:')
print('\t--build\t\tBuild windows binaries')
print('\t--release\tBuild windows installer')
print('\t--archive\tBuild windows binaries and zip them')
print('\t--all\t\tBuild windows installer and zip archive')
print('\t--clean\t\tClean build directories')
print('\t--mrproper\tClean up repo')
print('')
else:
print('Ivalid build parameter: '+arg)
print('Use '+sys.argv[0]+' --help for usage information')