-
Notifications
You must be signed in to change notification settings - Fork 1
/
make.py
executable file
·94 lines (75 loc) · 2.84 KB
/
make.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
#!/usr/bin/env python3
import os
import sys
cwd = os.getcwd()
if not os.path.exists(os.path.join(cwd, 'no3')):
print("Please run this script from the root of the repository.")
sys.exit(1)
if os.name != 'posix':
print("This script is only supported on Unix-like systems.")
sys.exit(1)
# Check if Docker is installed
if os.system('docker --version') != 0:
print("Docker is not installed.")
sys.exit(1)
if '--clean-all' in sys.argv:
os.system('rm -rf .build build')
print("Cleaned all.")
sys.exit(0)
# Check if SNAP Build mode is enabled
if '--snap' in sys.argv:
# Check if snapcraft is installed
if os.system('snapcraft --version') != 0:
print("Snapcraft is not installed.")
sys.exit(1)
print("Building Snap package...")
if os.system('snapcraft') != 0:
print("Snap build failed.")
sys.exit(1)
print("Snap build complete.")
sys.exit(0)
print("Building Docker containers...")
# Build the debug env container
if os.system('docker build -t nitrate-debug:latest -f tools/Debug.Dockerfile .') != 0:
print("Debug build failed.")
sys.exit(1)
# def regenerate_runner():
# if os.system('docker build -t wesleyjones256/no3-dist:latest -f tools/no3-dist-container.Dockerfile .') != 0:
# print("Container build failed.")
# sys.exit(1)
# Build the release env container
if os.system('docker build -t nitrate-release:latest -f tools/Release.Dockerfile .') != 0:
print("Release build failed.")
sys.exit(1)
if '--release' in sys.argv:
print("Building release...")
if os.system('docker run -v {0}:/app --rm -it nitrate-release:latest'.format(cwd)) != 0:
print("Release build failed.")
sys.exit(1)
if '--strip' in sys.argv:
os.system('find build/bin -type f -exec strip {} \\;')
os.system('find build/lib -type f -iname "*.so" -exec strip {} \\;')
print("Stripped release binaries.")
if '--upx-best' in sys.argv:
raise Exception("Auto UPX packing is not implemented")
files = ['no3', 'qld', 'qcc']
for file in files:
if os.system('upx --best {0}'.format(os.path.join(cwd, 'build/bin/', file))) != 0:
print("Failed to UPX {0}".format(file))
sys.exit(1)
print("UPX'd release binaries.")
# regenerate_runner()
print("Release build complete.")
sys.exit(0)
if '--debug' in sys.argv:
print("Building debug...")
if os.system('docker run -v {0}:/app --rm -it nitrate-debug:latest'.format(cwd)) != 0:
print("Debug build failed.")
sys.exit(1)
if '--strip' in sys.argv:
os.system('find build/bin -type f -exec strip {} \\;')
os.system('find build/lib -type f -iname "*.so" -exec strip {} \\;')
print("Stripped debug binaries.")
print("Debug build complete.")
# regenerate_runner()
sys.exit(0)