-
Notifications
You must be signed in to change notification settings - Fork 1
/
build-release.py
executable file
·61 lines (45 loc) · 1.69 KB
/
build-release.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
#!/usr/bin/env python
import os
import sys
import time
import subprocess
ARTIFACT = "notify-hook"
PROJDIR = os.path.dirname(os.path.realpath(__file__))
BINDIR = os.path.join(PROJDIR, 'bin')
BINDIR_32 = os.path.join(BINDIR, '32')
BINDIR_64 = os.path.join(BINDIR, '64')
# Tweak targets as needed
TARGETS = [
#(architecture, environment, artifact-output-dir)
("i686", 'gnu', BINDIR_32),
("x86_64", 'musl', BINDIR_64),
]
class CmdError(Exception):
pass
def cmd(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
for line in iter(proc.stdout.readline, ''):
sys.stdout.write(line)
while proc.poll() is None:
time.sleep(0.5)
if proc.returncode != 0:
raise CmdError("Command: {} exited with status: {}".format(args, proc.returncode))
def mkdir(p):
return cmd(['mkdir', '-p', p])
def main(args):
print("** Building release artifacts for: {} **".format(ARTIFACT))
mkdir(BINDIR_32)
mkdir(BINDIR_64)
print("\n** START BUILD OUTPUT **")
print(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
for arch, env, bin_dir in TARGETS:
target_name = "{}-unknown-linux-{}".format(arch, env)
print("** Building release artifact for {} **".format(target_name))
cmd(["cross", "build", "--release", "--target", target_name])
artifact = os.path.join(PROJDIR, "target", target_name, "release", ARTIFACT)
cmd(["cp", artifact, bin_dir])
print("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
print("** END BUILD OUTPUT **\n")
print("** Release artifacts copied to {}".format(BINDIR))
if __name__ == '__main__':
main(sys.argv[1:])