29
29
import os
30
30
import subprocess
31
31
32
+ sys .path .append (os .path .join (os .path .dirname (__file__ ), '../mpy-cross' ))
33
+ import mpy_cross
34
+
32
35
import manifestfile
33
36
34
37
VARS = {}
@@ -173,7 +176,7 @@ def main():
173
176
str_paths = []
174
177
mpy_files = []
175
178
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 ():
177
180
if kind == manifestfile .KIND_FREEZE_AS_STR :
178
181
str_paths .append ((full_path , target_path ,))
179
182
ts_outfile = timestamp
@@ -183,14 +186,11 @@ def main():
183
186
if timestamp >= ts_outfile :
184
187
print ("MPY" , target_path )
185
188
mkdir (outfile )
186
- res , out = system (
187
- [MPY_CROSS ]
188
- + args .mpy_cross_flags .split ()
189
- + ["-o" , outfile , "-s" , target_path , "-O{}" .format (opt ), full_path ]
190
- )
191
- if res != 0 :
192
- print ("error compiling {}:" .format (infile ))
193
- sys .stdout .buffer .write (out )
189
+ try :
190
+ mpy_cross .compile (full_path , dest = outfile , src_path = target_path , mpy_cross = MPY_CROSS , extra_args = args .mpy_cross_flags .split ())
191
+ except mpy_cross .CrossCompileError as ex :
192
+ print ("error compiling {}:" .format (target_path ))
193
+ print (ex .args [0 ])
194
194
raise SystemExit (1 )
195
195
ts_outfile = get_timestamp (outfile )
196
196
mpy_files .append (outfile )
0 commit comments