-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist
executable file
·50 lines (37 loc) · 1.21 KB
/
dist
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
#!/usr/bin/env python3
import argparse
import shlex
import shutil
import subprocess
import sys
from pathlib import Path
def run(args, **kwargs):
print("\t>", shlex.join(str(a) for a in args), flush=True)
r = subprocess.run(args, **kwargs, check=False)
if r.returncode != 0:
sys.exit(r.returncode)
return r
def main():
parser = argparse.ArgumentParser()
parser.add_argument("builddir", nargs="?", type=Path, default="build", help="build directory")
args = parser.parse_args()
base_dist_dir = args.builddir / "dist"
shutil.rmtree(base_dist_dir, True)
install_dir = base_dist_dir / "install"
run(["cmake", "--install", args.builddir, "--strip", f"--prefix={install_dir}"])
bin_dir = install_dir / "bin"
dist_name = "komankondi"
dist_dir = base_dist_dir / dist_name
shutil.move(bin_dir, dist_dir)
if sys.platform == "win32":
run(["windeployqt", "--qmldir=src/ui", dist_dir / "komankondi.exe"])
shutil.make_archive(
str(args.builddir / dist_name),
"zip" if sys.platform == "win32" else "xztar",
base_dist_dir,
dist_name,
owner="root",
group="root",
)
if __name__ == "__main__":
sys.exit(main())