Merge branch 'bugfix/msys_cancel_idfpy_v3.1' into 'release/v3.1'
tools: re-run idf.py in MSYS with winpty (backport v3.1) See merge request idf/esp-idf!4455
This commit is contained in:
commit
5fb9aaa377
1 changed files with 14 additions and 1 deletions
13
tools/idf.py
13
tools/idf.py
|
@ -454,6 +454,19 @@ def main():
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
try:
|
try:
|
||||||
|
# On MSYS2 we need to run idf.py with "winpty" in order to be able to cancel the subprocesses properly on
|
||||||
|
# keyboard interrupt (CTRL+C).
|
||||||
|
# Using an own global variable for indicating that we are running with "winpty" seems to be the most suitable
|
||||||
|
# option as os.environment['_'] contains "winpty" only when it is run manually from console.
|
||||||
|
WINPTY_VAR = 'WINPTY'
|
||||||
|
WINPTY_EXE = 'winpty'
|
||||||
|
if ('MSYSTEM' in os.environ) and (not os.environ['_'].endswith(WINPTY_EXE) and WINPTY_VAR not in os.environ):
|
||||||
|
os.environ[WINPTY_VAR] = '1' # the value is of no interest to us
|
||||||
|
# idf.py calls itself with "winpty" and WINPTY global variable set
|
||||||
|
ret = subprocess.call([WINPTY_EXE, sys.executable] + sys.argv, env=os.environ)
|
||||||
|
if ret:
|
||||||
|
raise SystemExit(ret)
|
||||||
|
else:
|
||||||
main()
|
main()
|
||||||
except FatalError as e:
|
except FatalError as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
Loading…
Reference in a new issue