Skip to content

Commit 25b1796

Browse files
committed
fixes linking errors
1 parent b7d3e88 commit 25b1796

File tree

10 files changed

+60
-30
lines changed

10 files changed

+60
-30
lines changed

builder/__init__.py

Lines changed: 50 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -241,21 +241,26 @@ def get_pycparser():
241241
sys.exit(result)
242242

243243

244-
def _busy_spinner(evnt):
244+
def _busy_spinner(evnt, spinner_lock):
245245
if 'GITHUB_RUN_ID' in os.environ:
246246
while not evnt.is_set():
247-
sys.stdout.write('.')
248-
sys.stdout.flush()
247+
with spinner_lock:
248+
sys.stdout.write('.')
249+
sys.stdout.flush()
249250
evnt.wait(2)
250-
sys.stdout.write('\n')
251-
sys.stdout.flush()
251+
252+
with spinner_lock:
253+
sys.stdout.write('\n')
254+
sys.stdout.flush()
252255
else:
253256
count = random.randint(1, 25)
254257
wait = random.randint(10, 100) * 0.001
255258
chars = '\\|/-'
256259
char_index = 0
257-
sys.stdout.write(chars[char_index] + '\r')
258-
sys.stdout.flush()
260+
261+
with spinner_lock:
262+
sys.stdout.write(chars[char_index] + '\r')
263+
sys.stdout.flush()
259264

260265
while not evnt.is_set():
261266
evnt.wait(wait)
@@ -264,15 +269,17 @@ def _busy_spinner(evnt):
264269
if char_index == 4:
265270
char_index = 0
266271

267-
sys.stdout.write(f'{chars[char_index]}\r')
268-
sys.stdout.flush()
272+
with spinner_lock:
273+
sys.stdout.write(f'{chars[char_index]}\r')
274+
sys.stdout.flush()
269275

270276
if count == 0:
271277
count = random.randint(1, 25)
272278
wait = random.randint(10, 100) * 0.001
273279

274-
sys.stdout.write('\r')
275-
sys.stdout.flush()
280+
with spinner_lock:
281+
sys.stdout.write('\r')
282+
sys.stdout.flush()
276283

277284

278285
def _convert_line(lne):
@@ -297,9 +304,9 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
297304
err_updated = False
298305

299306
event = threading.Event()
300-
307+
spinner_lock = threading.Lock()
301308
if spinner:
302-
t = threading.Thread(target=_busy_spinner, args=(event,))
309+
t = threading.Thread(target=_busy_spinner, args=(event, spinner_lock))
303310
t.daemon = True
304311
t.start()
305312
else:
@@ -319,10 +326,12 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
319326

320327
out_queue.put(line)
321328

322-
if not spinner and out_to_screen:
329+
if out_to_screen:
323330
if (
324331
cmpl and (
325332
line.startswith('[') or
333+
line.startswith('CC ') or
334+
line.startswith('MPY ') or
326335
(
327336
line.startswith('--') and
328337
len(line) <= 80
@@ -331,22 +340,36 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
331340
):
332341
if last_line_len != -1:
333342
sys.stdout.write('\r')
343+
sys.stdout.flush()
334344

335345
if len(line) < last_line_len:
336346
padding = ' ' * (last_line_len - len(line))
337347
else:
338348
padding = ''
339349

340350
sys.stdout.write(line + padding)
351+
sys.stdout.flush()
352+
341353
last_line_len = len(line)
342354
else:
343355
if last_line_len == -1:
344-
sys.stdout.write(line + '\n')
356+
if spinner:
357+
with spinner_lock:
358+
sys.stdout.write('\r' + line + '\n')
359+
sys.stdout.flush()
360+
else:
361+
sys.stdout.write(line + '\n')
362+
sys.stdout.flush()
345363
else:
346-
sys.stdout.write('\n' + line + '\n')
347-
last_line_len = -1
364+
if spinner:
365+
with spinner_lock:
366+
sys.stdout.write('\r' + line + '\n')
367+
sys.stdout.flush()
368+
else:
369+
sys.stdout.write('\n' + line + '\n')
370+
sys.stdout.flush()
348371

349-
sys.stdout.flush()
372+
last_line_len = -1
350373

351374
line = b''
352375

@@ -369,9 +392,14 @@ def process_output(myproc, out_to_screen, spinner, cmpl, out_queue):
369392
break
370393

371394
out_queue.put(err_line)
372-
if out_to_screen and not spinner:
373-
sys.stderr.write(err_line + '\n')
374-
sys.stderr.flush()
395+
if out_to_screen:
396+
if spinner:
397+
with spinner_lock:
398+
sys.stderr.write('\r' + err_line + '\n')
399+
sys.stdout.flush()
400+
else:
401+
sys.stderr.write(err_line + '\n')
402+
sys.stderr.flush()
375403

376404
err_line = b''
377405

@@ -499,7 +527,7 @@ def compile(): # NOQA
499527

500528

501529
def mpy_cross():
502-
return_code, _ = spawn(mpy_cross_cmd)
530+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
503531
if return_code != 0:
504532
sys.exit(return_code)
505533

builder/esp32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,6 +1056,6 @@ def find_esp32(chip):
10561056

10571057

10581058
def mpy_cross():
1059-
return_code, _ = spawn(mpy_cross_cmd)
1059+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
10601060
if return_code != 0:
10611061
sys.exit(return_code)

builder/macOS.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,6 @@ def mpy_cross():
265265
'make -C lib/micropython/mpy-cross'
266266
]
267267

268-
res, _ = spawn(_cmd)
268+
res, _ = spawn(_cmd, cmpl=True)
269269
if res:
270270
sys.exit(res)

builder/nrf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,6 @@ def compile(): # NOQA
104104

105105

106106
def mpy_cross():
107-
return_code, _ = spawn(mpy_cross_cmd)
107+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
108108
if return_code != 0:
109109
sys.exit(return_code)

builder/renesas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,6 @@ def compile(): # NOQA
8787

8888

8989
def mpy_cross():
90-
return_code, _ = spawn(mpy_cross_cmd)
90+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
9191
if return_code != 0:
9292
sys.exit(return_code)

builder/rp2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,6 @@ def compile(): # NOQA
169169

170170

171171
def mpy_cross():
172-
return_code, _ = spawn(mpy_cross_cmd)
172+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
173173
if return_code != 0:
174174
sys.exit(return_code)

builder/stm32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ def compile(): # NOQA
141141

142142

143143
def mpy_cross():
144-
return_code, _ = spawn(mpy_cross_cmd)
144+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
145145
if return_code != 0:
146146
sys.exit(return_code)

builder/unix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,6 @@ def mpy_cross():
266266
'make -C lib/micropython/mpy-cross'
267267
]
268268

269-
res, _ = spawn(_cmd)
269+
res, _ = spawn(_cmd, cmpl=True)
270270
if res:
271271
sys.exit(res)

builder/windows.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,6 @@ def _write_file(p, **kwargs):
453453

454454

455455
def mpy_cross():
456-
return_code, _ = spawn(mpy_cross_cmd)
456+
return_code, _ = spawn(mpy_cross_cmd, cmpl=True)
457457
if return_code != 0:
458458
sys.exit(return_code)

make.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from argparse import ArgumentParser
88

9+
if sys.platform.startswith('win'):
10+
raise RuntimeError('compiling on windows is not supported at this time')
911

1012
SCRIPT_DIR = os.path.abspath(os.path.dirname(sys.argv[0]))
1113
MPY_DIR = os.path.join(SCRIPT_DIR, 'micropython')

0 commit comments

Comments
 (0)