1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +03:00

Resolve Windows path problems (#8860)

Moved up os.makedirs for ./core/ directory.
Strange problem creating files with file paths with spaces.
Strange that "create file" would work when the path did not contain spaces and the last folder of the path hadn't been created.

Added try/except on main to commit print buffer on traceback for context.

Additional issues with diacritics and locale character encoding for shell vs source code.
build.opt is written with the same encoding as the shell; however, the data read from the Sketch.ino.global.h is UTF-8.

Tested on Windows 10 (en-US) with Arduino IDE 2.0.3 Under an
account with a diacritic character in the user ID path.

Needs testing on Japanese Windows
This commit is contained in:
M Hightower
2023-02-22 09:46:25 -08:00
committed by GitHub
parent d7cd4bef6c
commit 71a51b1113
2 changed files with 92 additions and 12 deletions

View File

@ -21,9 +21,20 @@ import argparse
import os
import subprocess
import sys
import locale
sys.stdout = sys.stderr
# retrieve *system* encoding, not the one used by python internally
if sys.version_info >= (3, 11):
def get_encoding():
return locale.getencoding()
else:
def get_encoding():
return locale.getdefaultlocale()[1]
def get_segment_sizes(elf, path, mmu):
iram_size = 0
iheap_size = 0
@ -73,7 +84,7 @@ def get_segment_sizes(elf, path, mmu):
)
cmd = [os.path.join(path, "xtensa-lx106-elf-size"), "-A", elf]
with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True) as proc:
with subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True, encoding=get_encoding()) as proc:
lines = proc.stdout.readlines()
for line in lines:
words = line.split()