-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
59 lines (46 loc) · 1.55 KB
/
build.py
File metadata and controls
59 lines (46 loc) · 1.55 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
58
59
"""
This script is still not fully working. If one of the steps error out, the other process doesn't stop, and is still attached to your terminal.
I'll fix it later
"""
from pathlib import Path
import shutil
import platform
from rich import print
import os
import asyncio
async def run(cmd):
print(f'[d green]Running: [b]{cmd}')
proc = await asyncio.create_subprocess_shell(cmd)
code = await proc.wait()
if code != 0:
raise RuntimeError(f'Command failed: {cmd}')
async def build_rust():
await run('cd kovm && cargo build -r')
os.makedirs('dist', exist_ok=True)
if platform.system() == 'Windows':
if Path('dist\\vm.exe').exists():
os.remove('dist\\vm.exe')
shutil.move('kovm\\target\\release\\kovm.exe', 'dist\\kovm.exe')
else:
shutil.move('kovm/target/release/kovm', 'dist/kovm')
async def build_py():
if platform.system() == 'Windows':
await run('pyinstaller win.spec')
else:
await run('pyinstaller unix.spec')
async def run_task(task):
print(f'[b green]Running task {task.__name__}')
await task()
print(f'[b green]Finished task {task.__name__}')
async def main():
try:
async with asyncio.TaskGroup() as tg:
tg.create_task(run_task(build_rust))
tg.create_task(run_task(build_py))
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]{ex}')
if __name__ == '__main__':
asyncio.run(main())