-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_vm.py
More file actions
57 lines (45 loc) · 1.26 KB
/
build_vm.py
File metadata and controls
57 lines (45 loc) · 1.26 KB
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
from pathlib import Path
import shutil
import platform
import subprocess
from rich import print
import os
import sys
if '-r' in sys.argv:
debug = False
else:
debug = True
print('[b]Debug mode')
def run(cmd):
print(f'[d green]Running: [b]{cmd}')
code = subprocess.call(cmd, shell=True)
if code != 0:
raise RuntimeError(f'Command failed: {cmd}')
def build_rust():
run(f'cd kovm && cargo build{" -r" if not debug else ""}')
os.makedirs('dist', exist_ok=True)
if platform.system() == 'Windows':
if Path('dist\\vm.exe').exists():
os.remove('dist\\vm.exe')
shutil.move(
f'kovm\\target\\{"debug" if debug else "release"}\\kovm.exe',
'dist\\kovm.exe',
)
else:
shutil.move(
f'kovm/target/{"debug" if debug else "release"}/kovm', 'dist/kovm'
)
def run_task(task):
print(f'[b green]Running task {task.__name__}')
task()
print(f'[b green]Finished task {task.__name__}')
def main():
try:
build_rust()
print('[green b u]Build completed! Result in dist/')
except* Exception as e:
print('[red b]Build failed:')
for ex in e.exceptions:
print(f' [red b]{e}')
if __name__ == '__main__':
main()