Cross compile source files into bytecode using mpy-cross.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
amora/lib/*
|
||||
build
|
||||
*.uf2
|
||||
mpy-cross*
|
||||
|
||||
34
build.py
Normal file
34
build.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import glob
|
||||
from subprocess import PIPE, Popen
|
||||
from os import listdir, makedirs
|
||||
from os.path import join, splitext, isfile
|
||||
from shutil import copytree, copy
|
||||
SRC = 'src'
|
||||
OUT = 'build'
|
||||
|
||||
|
||||
def lib_files(s: str):
|
||||
name, ext = splitext(s)
|
||||
if name not in ("code", "boot") and ext == ".py" and isfile(s):
|
||||
return name
|
||||
return None
|
||||
|
||||
|
||||
makedirs(OUT, exist_ok=True)
|
||||
|
||||
for entry in listdir(SRC):
|
||||
if name := lib_files(entry):
|
||||
Popen([
|
||||
join(".", glob.glob("mpy-cross.static*")[0]),
|
||||
join(SRC, entry),
|
||||
"-o",
|
||||
join(OUT, f'{name}.mpy')
|
||||
],
|
||||
stdout=PIPE
|
||||
).communicate()
|
||||
elif isfile(join(SRC, entry)):
|
||||
copy(join(SRC, entry),
|
||||
join(OUT, entry))
|
||||
else:
|
||||
copytree(join(SRC, entry),
|
||||
join(OUT, entry))
|
||||
Reference in New Issue
Block a user