10000 tools/makemanifest.py: Update to use mpy_cross module. · lowfatcode/micropython@6bd0ec7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6bd0ec7

Browse files
committed
tools/makemanifest.py: Update to use mpy_cross module.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent e428095 commit 6bd0ec7

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

tools/makemanifest.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import os
3030
import subprocess
3131

32+
sys.path.append(os.path.join(os.path.dirname(__file__), "../mpy-cross"))
33+
import mpy_cross
34+
3235
import manifestfile
3336

3437
VARS = {}
@@ -173,7 +176,7 @@ def main():
173176
str_paths = []
174177
mpy_files = []
175178
ts_newest = 0
176-
for full_path, target_path, timestamp, kind, version, opt in manifest.files():
179+
for _file_type, full_path, target_path, timestamp, kind, version, opt in manifest.files():
177180
if kind == manifestfile.KIND_FREEZE_AS_STR:
178181
str_paths.append(
179182
(
@@ -188,14 +191,18 @@ def main():
188191
if timestamp >= ts_outfile:
189192
print("MPY", target_path)
190193
mkdir(outfile)
191-
res, out = system(
192-
[MPY_CROSS]
193-
+ args.mpy_cross_flags.split()
194-
+ ["-o", outfile, "-s", target_path, "-O{}".format(opt), full_path]
195-
)
196-
if res != 0:
197-
print("error compiling {}:".format(infile))
198-
sys.stdout.buffer.write(out)
194+
try:
195+
mpy_cross.compile(
196+
full_path,
197+
dest=outfile,
198+
src_path=target_path,
199+
opt=opt,
200+
mpy_cross=MPY_CROSS,
201+
extra_args=args.mpy_cross_flags.split(),
202+
)
203+
except mpy_cross.CrossCompileError as ex:
204+
print("error compiling {}:".format(target_path))
205+
print(ex.args[0])
199206
raise SystemExit(1)
200207
ts_outfile = get_timestamp(outfile)
201208
mpy_files.append(outfile)

0 commit comments

Comments
 (0)
0