forked from majoson-chen/micropython-urouter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto_build.py
More file actions
37 lines (27 loc) · 712 Bytes
/
auto_build.py
File metadata and controls
37 lines (27 loc) · 712 Bytes
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
#!/usr/bin/python
# Build this project automaticly.
import os
from pathlib import Path
import shutil
import mpy_cross
cwd = Path('.')
# check mpy-corss
assert not os.system('mpy-cross'), "mpy-cross not found!"
# backup source
shutil.copy(
src = cwd / 'urouter',
dst = cwd / 'urouter_bak'
)
# compile code
for file in (cwd / 'urouter').iterdir():
file: Path
if file.name == '__init__.py':
continue
# skip
else:
new_file: Path = (file.parent / (file.stem() + ".mpy"))
cmd = f'mpy-cross -s {file.absolute()}'
os.system(cmd)
assert new_file.exists(), f"Compile Failed: {new_file}"
os.remove(file)
# build dist