From b9d67eadbb814b565cfa7fd59ef7ce8211ec85e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Mon, 27 Sep 2021 17:32:55 +0300 Subject: [PATCH 1/8] Avoid sharing the parent process's stdin handle to python when invoking python via emcc.bat script, to prevent a rare python deadlock hang. --- emcc.bat | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/emcc.bat b/emcc.bat index 800fad8ac3f78..31ef53fc54166 100644 --- a/emcc.bat +++ b/emcc.bat @@ -19,4 +19,8 @@ set CMD=ccache "%~dp0\%~n0.bat" ) -@%CMD% %* +:: Python Windows bug https://bugs.python.org/issue34780: If emcc.bat was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@%CMD% %* < NUL From 1efc051df7a794bc11c9cc55353256444ed10a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 10:43:56 +0300 Subject: [PATCH 2/8] Fix Windows .bat scripts from leaking set env. vars. Work around a Windows 7 batch script exit code issue. Work around a Windows Python spawn issue: https://bugs.python.org/issue34780 --- ChangeLog.md | 7 +++++++ em++.bat | 27 ++++++++++++++++++++++++--- em-config.bat | 22 +++++++++++++++++++++- emar.bat | 22 +++++++++++++++++++++- embuilder.bat | 22 +++++++++++++++++++++- emcc.bat | 26 ++++++++++++++++++++++---- emcmake.bat | 22 +++++++++++++++++++++- emconfigure.bat | 22 +++++++++++++++++++++- emdump.bat | 22 +++++++++++++++++++++- emdwp.bat | 22 +++++++++++++++++++++- emmake.bat | 22 +++++++++++++++++++++- emnm.bat | 22 +++++++++++++++++++++- emprofile.bat | 22 +++++++++++++++++++++- emranlib.bat | 22 +++++++++++++++++++++- emrun.bat | 22 +++++++++++++++++++++- emscons.bat | 22 +++++++++++++++++++++- emsize.bat | 22 +++++++++++++++++++++- tests/runner.bat | 22 +++++++++++++++++++++- tests/test_other.py | 13 +++++++++++-- tools/file_packager.bat | 22 +++++++++++++++++++++- tools/run_python.bat | 22 +++++++++++++++++++++- tools/run_python_compiler.bat | 27 ++++++++++++++++++++++++--- tools/webidl_binder.bat | 22 +++++++++++++++++++++- 23 files changed, 466 insertions(+), 30 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 5684036c63a37..1c9beb99c4201 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -43,6 +43,13 @@ See docs/process.md for more on how version tagging works. 2.0.30 - 09/14/2021 ------------------- +- Fixed launcher batch script issues on Windows, and added two env. vars + EM_WORKAROUND_PYTHON_BUG_34780 and EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG that + can be enabled to work around a Windows Python issue + https://bugs.python.org/issue34780 , and a Windows 7 exit code issue (#15146) + +2.0.30 +------ - Bug fixes 2.0.29 - 08/26/2021 diff --git a/em++.bat b/em++.bat index 800fad8ac3f78..8276eb6d75997 100644 --- a/em++.bat +++ b/em++.bat @@ -5,18 +5,39 @@ :: To make modifications to this file, edit `tools/run_python_compiler.bat` and :: then run `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. +@setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) +:: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver. +:: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled. @if "%_EMCC_CCACHE%"=="" ( - :: Do regular invocation of the python compiler driver set CMD="%EM_PY%" "%~dp0\%~n0.py" ) else ( - :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= set CMD=ccache "%~dp0\%~n0.bat" ) -@%CMD% %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + %CMD% %* +) else ( + %CMD% %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/em-config.bat b/em-config.bat index f9ce949e613f0..eea89171a7720 100644 --- a/em-config.bat +++ b/em-config.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emar.bat b/emar.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emar.bat +++ b/emar.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/embuilder.bat b/embuilder.bat index f9ce949e613f0..eea89171a7720 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emcc.bat b/emcc.bat index 31ef53fc54166..db856dbf2aaff 100644 --- a/emcc.bat +++ b/emcc.bat @@ -5,22 +5,40 @@ :: To make modifications to this file, edit `tools/run_python_compiler.bat` and :: then run `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. +@setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) +:: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver. +:: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled. @if "%_EMCC_CCACHE%"=="" ( - :: Do regular invocation of the python compiler driver set CMD="%EM_PY%" "%~dp0\%~n0.py" ) else ( - :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= set CMD=ccache "%~dp0\%~n0.bat" ) -:: Python Windows bug https://bugs.python.org/issue34780: If emcc.bat was invoked via a +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in :: a certain state, running python.exe might hang here. To work around this, invoke python :: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@%CMD% %* < NUL +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + %CMD% %* +) else ( + %CMD% %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +:: Note that when th +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emcmake.bat b/emcmake.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emconfigure.bat b/emconfigure.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emdump.bat b/emdump.bat index 769cd236d7fa8..5234b93e127d4 100644 --- a/emdump.bat +++ b/emdump.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\tools\emdump.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* +) else ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emdwp.bat b/emdwp.bat index b16d072111f81..5f872a5e28251 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\tools\emdwp.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* +) else ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emmake.bat b/emmake.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emmake.bat +++ b/emmake.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emnm.bat b/emnm.bat index 2f350f34a8f24..a314d85d72c7d 100644 --- a/emnm.bat +++ b/emnm.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\tools\emnm.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* +) else ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emprofile.bat b/emprofile.bat index 74dbf0c99e3aa..edd10501ce6df 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\tools\emprofile.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* +) else ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emranlib.bat b/emranlib.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emrun.bat b/emrun.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emrun.bat +++ b/emrun.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emscons.bat b/emscons.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emscons.bat +++ b/emscons.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/emsize.bat b/emsize.bat index f9ce949e613f0..eea89171a7720 100644 --- a/emsize.bat +++ b/emsize.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/tests/runner.bat b/tests/runner.bat index f9ce949e613f0..eea89171a7720 100644 --- a/tests/runner.bat +++ b/tests/runner.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/tests/test_other.py b/tests/test_other.py index 724bf7f4b3797..83c30a29544c9 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -7613,7 +7613,7 @@ def test_standalone_system_headers(self): for directory, headers in directories.items(): print('dir: ' + directory) - for header in headers: + for header in headers: if not header.endswith('.h'): continue print('header: ' + header) @@ -7636,7 +7636,7 @@ def test_standalone_system_headers(self): create_file('a.c', inc) create_file('b.c', inc) for std in [[], ['-std=c89']]: - self.run_process([EMCC] + std + ['-Werror', '-Wall', '-pedantic', 'a.c', 'b.c']) + self.run_process([EMCC] + std + ['-Werror', '-Wall', '-pedantic', 'a.c', 'b.c']) @is_slow_test def test_single_file(self): @@ -11076,3 +11076,12 @@ def test_emscripten_set_timeout(self): @node_pthreads def test_emscripten_set_timeout_loop(self): self.do_runf(test_file('emscripten_set_timeout_loop.c'), args=['-s', 'USE_PTHREADS', '-s', 'PROXY_TO_PTHREAD']) + + # Verify that we are able to successfully compile a script when the Windows 7 + # and Python workaround env. vars are enabled. + # See https://bugs.python.org/issue34780 + @with_env_modify({'EM_WORKAROUND_PYTHON_BUG_34780': '1', + 'EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG': '1'}) + def test_windows_batch_script_workaround(self): + self.run_process([EMCC, test_file('hello_world.c')]) + self.assertExists('a.out.js') diff --git a/tools/file_packager.bat b/tools/file_packager.bat index f9ce949e613f0..eea89171a7720 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/tools/run_python.bat b/tools/run_python.bat index f9ce949e613f0..eea89171a7720 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index 800fad8ac3f78..8276eb6d75997 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -5,18 +5,39 @@ :: To make modifications to this file, edit `tools/run_python_compiler.bat` and :: then run `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. +@setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) +:: If _EMCC_CCACHE is not set, do a regular invocation of the python compiler driver. +:: Otherwise remove the ccache env. var, and then reinvoke this script with ccache enabled. @if "%_EMCC_CCACHE%"=="" ( - :: Do regular invocation of the python compiler driver set CMD="%EM_PY%" "%~dp0\%~n0.py" ) else ( - :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= set CMD=ccache "%~dp0\%~n0.bat" ) -@%CMD% %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + %CMD% %* +) else ( + %CMD% %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index f9ce949e613f0..eea89171a7720 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -5,10 +5,30 @@ :: To make modifications to this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` +:: All env. vars specified in this file are to be local only to this script. @setlocal + @set EM_PY=%EMSDK_PYTHON% @if "%EM_PY%"=="" ( set EM_PY=python ) -@"%EM_PY%" "%~dp0\%~n0.py" %* +:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a +:: shared stdin handle from the parent process, and that parent process stdin handle is in +:: a certain state, running python.exe might hang here. To work around this, invoke python +:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* +) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL +) + +:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, +:: even when the python executable above did succeed and quit with errorlevel 0 above. +:: On Windows 8 and newer, this issue has not been observed. It is possible that this +:: issue is related to the above python bug, but this has not been conclusively confirmed, +:: so using a separate env. var to enable the known workaround this issue, which is to +:: explicitly quit the calling process with the previous errorlevel from the above command. +@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + exit %ERRORLEVEL% +) From 28e26ebf61559ea4c94f28ff5539ab76b58de6e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 11:04:40 +0300 Subject: [PATCH 3/8] Do not let anything come between python subprocess spawn and the exit statement (an if() statement would taint the 0 variable) --- em++.bat | 32 +++++++++++++++++++++----------- em-config.bat | 32 +++++++++++++++++++++----------- emar.bat | 32 +++++++++++++++++++++----------- embuilder.bat | 32 +++++++++++++++++++++----------- emcc.bat | 33 +++++++++++++++++++++------------ emcmake.bat | 32 +++++++++++++++++++++----------- emconfigure.bat | 32 +++++++++++++++++++++----------- emdump.bat | 32 +++++++++++++++++++++----------- emdwp.bat | 32 +++++++++++++++++++++----------- emmake.bat | 32 +++++++++++++++++++++----------- emnm.bat | 32 +++++++++++++++++++++----------- emprofile.bat | 32 +++++++++++++++++++++----------- emranlib.bat | 32 +++++++++++++++++++++----------- emrun.bat | 32 +++++++++++++++++++++----------- emscons.bat | 32 +++++++++++++++++++++----------- emsize.bat | 32 +++++++++++++++++++++----------- tests/runner.bat | 32 +++++++++++++++++++++----------- tools/file_packager.bat | 32 +++++++++++++++++++++----------- tools/run_python.bat | 32 +++++++++++++++++++++----------- tools/run_python_compiler.bat | 32 +++++++++++++++++++++----------- tools/webidl_binder.bat | 32 +++++++++++++++++++++----------- 21 files changed, 441 insertions(+), 232 deletions(-) diff --git a/em++.bat b/em++.bat index 8276eb6d75997..f3b2818b7eac7 100644 --- a/em++.bat +++ b/em++.bat @@ -24,20 +24,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - %CMD% %* -) else ( - %CMD% %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* + ) else ( + %CMD% %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* < NUL + ) else ( + %CMD% %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/em-config.bat b/em-config.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/em-config.bat +++ b/em-config.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emar.bat b/emar.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emar.bat +++ b/emar.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/embuilder.bat b/embuilder.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emcc.bat b/emcc.bat index db856dbf2aaff..f3b2818b7eac7 100644 --- a/emcc.bat +++ b/emcc.bat @@ -24,21 +24,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - %CMD% %* -) else ( - %CMD% %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -:: Note that when th -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* + ) else ( + %CMD% %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* < NUL + ) else ( + %CMD% %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emcmake.bat b/emcmake.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emconfigure.bat b/emconfigure.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emdump.bat b/emdump.bat index 5234b93e127d4..8d4c5d27bf607 100644 --- a/emdump.bat +++ b/emdump.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* -) else ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* + ) else ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emdwp.bat b/emdwp.bat index 5f872a5e28251..19d0d958e6f8e 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* -) else ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* + ) else ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emmake.bat b/emmake.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emmake.bat +++ b/emmake.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emnm.bat b/emnm.bat index a314d85d72c7d..a1c31dd658b66 100644 --- a/emnm.bat +++ b/emnm.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* -) else ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* + ) else ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emprofile.bat b/emprofile.bat index edd10501ce6df..72436c7edde8f 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* -) else ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* + ) else ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emranlib.bat b/emranlib.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emrun.bat b/emrun.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emrun.bat +++ b/emrun.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emscons.bat b/emscons.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emscons.bat +++ b/emscons.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/emsize.bat b/emsize.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/emsize.bat +++ b/emsize.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/tests/runner.bat b/tests/runner.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/tests/runner.bat +++ b/tests/runner.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/tools/file_packager.bat b/tools/file_packager.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/tools/run_python.bat b/tools/run_python.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index 8276eb6d75997..f3b2818b7eac7 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -24,20 +24,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - %CMD% %* -) else ( - %CMD% %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* + ) else ( + %CMD% %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + %CMD% %* < NUL + ) else ( + %CMD% %* < NUL + exit %ERRORLEVEL% + ) ) diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index eea89171a7720..88ebdfedc13bc 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -15,20 +15,30 @@ :: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a :: shared stdin handle from the parent process, and that parent process stdin handle is in -:: a certain state, running python.exe might hang here. To work around this, invoke python -:: with '< NUL' stdin to avoid sharing the parent's stdin handle to it, avoiding the hang. -@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* -) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL -) +:: a certain state, running python.exe might hang here. To work around this, if +:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid +:: sharing the parent's stdin handle to it, avoiding the hang. :: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel, :: even when the python executable above did succeed and quit with errorlevel 0 above. :: On Windows 8 and newer, this issue has not been observed. It is possible that this :: issue is related to the above python bug, but this has not been conclusively confirmed, -:: so using a separate env. var to enable the known workaround this issue, which is to -:: explicitly quit the calling process with the previous errorlevel from the above command. -@if not "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - exit %ERRORLEVEL% +:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known +:: workaround this issue, which is to explicitly quit the calling process with the previous +:: errorlevel from the above command. + +@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* + exit %ERRORLEVEL% + ) +) else ( + @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + ) else ( + "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + exit %ERRORLEVEL% + ) ) From 556c793be3af6a2d96a9a8f7fe0895489bc9c54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 11:09:39 +0300 Subject: [PATCH 4/8] Fix bad automerge --- tests/test_other.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_other.py b/tests/test_other.py index 83c30a29544c9..30fc182e437fb 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -7613,7 +7613,7 @@ def test_standalone_system_headers(self): for directory, headers in directories.items(): print('dir: ' + directory) - for header in headers: + for header in headers: if not header.endswith('.h'): continue print('header: ' + header) @@ -7636,7 +7636,7 @@ def test_standalone_system_headers(self): create_file('a.c', inc) create_file('b.c', inc) for std in [[], ['-std=c89']]: - self.run_process([EMCC] + std + ['-Werror', '-Wall', '-pedantic', 'a.c', 'b.c']) + self.run_process([EMCC] + std + ['-Werror', '-Wall', '-pedantic', 'a.c', 'b.c']) @is_slow_test def test_single_file(self): From b0e19350bbb42c57624fab79c099576f5575555e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 15:31:17 +0300 Subject: [PATCH 5/8] Avoid dispatching emcc from within an if() block in .bat file --- em++.bat | 31 +++++++++++++++++++++++++------ em-config.bat | 31 +++++++++++++++++++++++++------ emar.bat | 31 +++++++++++++++++++++++++------ embuilder.bat | 31 +++++++++++++++++++++++++------ emcc.bat | 31 +++++++++++++++++++++++++------ emcmake.bat | 31 +++++++++++++++++++++++++------ emconfigure.bat | 31 +++++++++++++++++++++++++------ emdump.bat | 31 +++++++++++++++++++++++++------ emdwp.bat | 31 +++++++++++++++++++++++++------ emmake.bat | 31 +++++++++++++++++++++++++------ emnm.bat | 31 +++++++++++++++++++++++++------ emprofile.bat | 31 +++++++++++++++++++++++++------ emranlib.bat | 31 +++++++++++++++++++++++++------ emrun.bat | 31 +++++++++++++++++++++++++------ emscons.bat | 31 +++++++++++++++++++++++++------ emsize.bat | 31 +++++++++++++++++++++++++------ tests/runner.bat | 31 +++++++++++++++++++++++++------ tools/file_packager.bat | 31 +++++++++++++++++++++++++------ tools/run_python.bat | 31 +++++++++++++++++++++++++------ tools/run_python_compiler.bat | 31 +++++++++++++++++++++++++------ tools/webidl_binder.bat | 31 +++++++++++++++++++++++++------ 21 files changed, 525 insertions(+), 126 deletions(-) diff --git a/em++.bat b/em++.bat index f3b2818b7eac7..4d87e9abe7c97 100644 --- a/em++.bat +++ b/em++.bat @@ -36,18 +36,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* + goto NORMAL ) else ( - %CMD% %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* < NUL + goto MUTE_STDIN ) else ( - %CMD% %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@%CMD% %* +@goto END + +:NORMAL_EXIT +@%CMD% %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@%CMD% %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@%CMD% %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/em-config.bat b/em-config.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/em-config.bat +++ b/em-config.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emar.bat b/emar.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emar.bat +++ b/emar.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/embuilder.bat b/embuilder.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emcc.bat b/emcc.bat index f3b2818b7eac7..4d87e9abe7c97 100644 --- a/emcc.bat +++ b/emcc.bat @@ -36,18 +36,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* + goto NORMAL ) else ( - %CMD% %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* < NUL + goto MUTE_STDIN ) else ( - %CMD% %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@%CMD% %* +@goto END + +:NORMAL_EXIT +@%CMD% %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@%CMD% %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@%CMD% %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emcmake.bat b/emcmake.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emconfigure.bat b/emconfigure.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emdump.bat b/emdump.bat index 8d4c5d27bf607..ca301ed1a25f6 100644 --- a/emdump.bat +++ b/emdump.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emdump.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\tools\emdump.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emdwp.bat b/emdwp.bat index 19d0d958e6f8e..d632c7d93621c 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emmake.bat b/emmake.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emmake.bat +++ b/emmake.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emnm.bat b/emnm.bat index a1c31dd658b66..429dbd6612699 100644 --- a/emnm.bat +++ b/emnm.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emnm.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\tools\emnm.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emprofile.bat b/emprofile.bat index 72436c7edde8f..79b9f8d8598a0 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emprofile.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\tools\emprofile.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emranlib.bat b/emranlib.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emrun.bat b/emrun.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emrun.bat +++ b/emrun.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emscons.bat b/emscons.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emscons.bat +++ b/emscons.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/emsize.bat b/emsize.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/emsize.bat +++ b/emsize.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/tests/runner.bat b/tests/runner.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/tests/runner.bat +++ b/tests/runner.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/tools/file_packager.bat b/tools/file_packager.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/tools/run_python.bat b/tools/run_python.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index f3b2818b7eac7..4d87e9abe7c97 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -36,18 +36,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* + goto NORMAL ) else ( - %CMD% %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - %CMD% %* < NUL + goto MUTE_STDIN ) else ( - %CMD% %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@%CMD% %* +@goto END + +:NORMAL_EXIT +@%CMD% %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@%CMD% %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@%CMD% %* < NUL +@exit %ERRORLEVEL% + +:END diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index 88ebdfedc13bc..3d9107e8187f2 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -27,18 +27,37 @@ :: workaround this issue, which is to explicitly quit the calling process with the previous :: errorlevel from the above command. +:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from +:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that +:: would throw off the parsing of the cmdline arg. @if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* + goto NORMAL ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* - exit %ERRORLEVEL% + goto NORMAL_EXIT ) ) else ( @if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL + goto MUTE_STDIN ) else ( - "%EM_PY%" "%~dp0\%~n0.py" %* < NUL - exit %ERRORLEVEL% + goto MUTE_STDIN_EXIT ) ) + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* +@goto END + +:NORMAL_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* +@exit %ERRORLEVEL% + +:MUTE_STDIN +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@goto END + +:MUTE_STDIN_EXIT +@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL +@exit %ERRORLEVEL% + +:END From 82851433a49a0910d68c5c6313ad9bcd3b30f6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 16:04:25 +0300 Subject: [PATCH 6/8] Always use exit in .bat scripts to avoid goto tainting ERRORLEVEL --- em++.bat | 6 ++---- em-config.bat | 6 ++---- emar.bat | 6 ++---- embuilder.bat | 6 ++---- emcc.bat | 6 ++---- emcmake.bat | 6 ++---- emconfigure.bat | 6 ++---- emdump.bat | 6 ++---- emdwp.bat | 6 ++---- emmake.bat | 6 ++---- emnm.bat | 6 ++---- emprofile.bat | 6 ++---- emranlib.bat | 6 ++---- emrun.bat | 6 ++---- emscons.bat | 6 ++---- emsize.bat | 6 ++---- tests/runner.bat | 6 ++---- tools/file_packager.bat | 6 ++---- tools/run_python.bat | 6 ++---- tools/run_python_compiler.bat | 6 ++---- tools/webidl_binder.bat | 6 ++---- 21 files changed, 42 insertions(+), 84 deletions(-) diff --git a/em++.bat b/em++.bat index 4d87e9abe7c97..420eed432a14d 100644 --- a/em++.bat +++ b/em++.bat @@ -55,7 +55,7 @@ :NORMAL @%CMD% %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @%CMD% %* @@ -63,10 +63,8 @@ :MUTE_STDIN @%CMD% %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/em-config.bat b/em-config.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/em-config.bat +++ b/em-config.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emar.bat b/emar.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emar.bat +++ b/emar.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/embuilder.bat b/embuilder.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emcc.bat b/emcc.bat index 4d87e9abe7c97..420eed432a14d 100644 --- a/emcc.bat +++ b/emcc.bat @@ -55,7 +55,7 @@ :NORMAL @%CMD% %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @%CMD% %* @@ -63,10 +63,8 @@ :MUTE_STDIN @%CMD% %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emcmake.bat b/emcmake.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emconfigure.bat b/emconfigure.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emdump.bat b/emdump.bat index ca301ed1a25f6..29de88f2cfb59 100644 --- a/emdump.bat +++ b/emdump.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\tools\emdump.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emdump.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emdwp.bat b/emdwp.bat index d632c7d93621c..f4ced47901fdc 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\tools\emdwp.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emdwp.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emmake.bat b/emmake.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emmake.bat +++ b/emmake.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emnm.bat b/emnm.bat index 429dbd6612699..48ad152a13d31 100644 --- a/emnm.bat +++ b/emnm.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\tools\emnm.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emnm.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emprofile.bat b/emprofile.bat index 79b9f8d8598a0..6992b5a1727e0 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\tools\emprofile.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emprofile.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emranlib.bat b/emranlib.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emrun.bat b/emrun.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emrun.bat +++ b/emrun.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emscons.bat b/emscons.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emscons.bat +++ b/emscons.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/emsize.bat b/emsize.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/emsize.bat +++ b/emsize.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/tests/runner.bat b/tests/runner.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/tests/runner.bat +++ b/tests/runner.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/tools/file_packager.bat b/tools/file_packager.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/tools/run_python.bat b/tools/run_python.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index 4d87e9abe7c97..420eed432a14d 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -55,7 +55,7 @@ :NORMAL @%CMD% %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @%CMD% %* @@ -63,10 +63,8 @@ :MUTE_STDIN @%CMD% %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% - -:END diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index 3d9107e8187f2..4a463cc89d6a9 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -46,7 +46,7 @@ :NORMAL @"%EM_PY%" "%~dp0\%~n0.py" %* -@goto END +@exit /b %ERRORLEVEL% :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @@ -54,10 +54,8 @@ :MUTE_STDIN @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL -@goto END +@exit /b %ERRORLEVEL% :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% - -:END From 5367f944eacaf8ce37e46afdadf563d2342d9907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 18:11:11 +0300 Subject: [PATCH 7/8] Fix bad merge in Changelog --- ChangeLog.md | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 1c9beb99c4201..b445747ac0b38 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -36,6 +36,10 @@ See docs/process.md for more on how version tagging works. `__syscall22`) to name-based (e.g. `__syscall_open`). This should not be a visible change except for folks trying to intercept/implement syscalls in native code (#15202). +- Fixed launcher batch script issues on Windows, and added two env. vars + EM_WORKAROUND_PYTHON_BUG_34780 and EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG that + can be enabled to work around a Windows Python issue + https://bugs.python.org/issue34780 , and a Windows 7 exit code issue (#15146) 2.0.31 - 10/01/2021 ------------------- @@ -43,13 +47,6 @@ See docs/process.md for more on how version tagging works. 2.0.30 - 09/14/2021 ------------------- -- Fixed launcher batch script issues on Windows, and added two env. vars - EM_WORKAROUND_PYTHON_BUG_34780 and EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG that - can be enabled to work around a Windows Python issue - https://bugs.python.org/issue34780 , and a Windows 7 exit code issue (#15146) - -2.0.30 ------- - Bug fixes 2.0.29 - 08/26/2021 From dbb87eb52a54e0620037322c56f9098fea6539e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jukka=20Jyl=C3=A4nki?= Date: Wed, 6 Oct 2021 18:53:10 +0300 Subject: [PATCH 8/8] Move :NORMAL last in the batch scripts --- em++.bat | 7 +++---- em-config.bat | 7 +++---- emar.bat | 7 +++---- embuilder.bat | 7 +++---- emcc.bat | 7 +++---- emcmake.bat | 7 +++---- emconfigure.bat | 7 +++---- emdump.bat | 7 +++---- emdwp.bat | 7 +++---- emmake.bat | 7 +++---- emnm.bat | 7 +++---- emprofile.bat | 7 +++---- emranlib.bat | 7 +++---- emrun.bat | 7 +++---- emscons.bat | 7 +++---- emsize.bat | 7 +++---- tests/runner.bat | 7 +++---- tools/file_packager.bat | 7 +++---- tools/run_python.bat | 7 +++---- tools/run_python_compiler.bat | 7 +++---- tools/webidl_binder.bat | 7 +++---- 21 files changed, 63 insertions(+), 84 deletions(-) diff --git a/em++.bat b/em++.bat index 420eed432a14d..9de276dadece8 100644 --- a/em++.bat +++ b/em++.bat @@ -53,10 +53,6 @@ ) ) -:NORMAL -@%CMD% %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @%CMD% %* @exit %ERRORLEVEL% @@ -68,3 +64,6 @@ :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@%CMD% %* diff --git a/em-config.bat b/em-config.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/em-config.bat +++ b/em-config.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emar.bat b/emar.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emar.bat +++ b/emar.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/embuilder.bat b/embuilder.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emcc.bat b/emcc.bat index 420eed432a14d..9de276dadece8 100644 --- a/emcc.bat +++ b/emcc.bat @@ -53,10 +53,6 @@ ) ) -:NORMAL -@%CMD% %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @%CMD% %* @exit %ERRORLEVEL% @@ -68,3 +64,6 @@ :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@%CMD% %* diff --git a/emcmake.bat b/emcmake.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emconfigure.bat b/emconfigure.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emdump.bat b/emdump.bat index 29de88f2cfb59..ed920be000483 100644 --- a/emdump.bat +++ b/emdump.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\tools\emdump.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emdump.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emdump.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emdump.py" %* diff --git a/emdwp.bat b/emdwp.bat index f4ced47901fdc..29d98d66cce7f 100644 --- a/emdwp.bat +++ b/emdwp.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\tools\emdwp.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emdwp.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emdwp.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emdwp.py" %* diff --git a/emmake.bat b/emmake.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emmake.bat +++ b/emmake.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emnm.bat b/emnm.bat index 48ad152a13d31..9415f162435ee 100644 --- a/emnm.bat +++ b/emnm.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\tools\emnm.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emnm.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emnm.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emnm.py" %* diff --git a/emprofile.bat b/emprofile.bat index 6992b5a1727e0..c9e327a82637a 100644 --- a/emprofile.bat +++ b/emprofile.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\tools\emprofile.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\tools\emprofile.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\tools\emprofile.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\tools\emprofile.py" %* diff --git a/emranlib.bat b/emranlib.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emrun.bat b/emrun.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emrun.bat +++ b/emrun.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emscons.bat b/emscons.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emscons.bat +++ b/emscons.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emsize.bat b/emsize.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/emsize.bat +++ b/emsize.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tests/runner.bat b/tests/runner.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/tests/runner.bat +++ b/tests/runner.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tools/file_packager.bat b/tools/file_packager.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/tools/file_packager.bat +++ b/tools/file_packager.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tools/run_python.bat b/tools/run_python.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index 420eed432a14d..9de276dadece8 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -53,10 +53,6 @@ ) ) -:NORMAL -@%CMD% %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @%CMD% %* @exit %ERRORLEVEL% @@ -68,3 +64,6 @@ :MUTE_STDIN_EXIT @%CMD% %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@%CMD% %* diff --git a/tools/webidl_binder.bat b/tools/webidl_binder.bat index 4a463cc89d6a9..2d981b1168899 100644 --- a/tools/webidl_binder.bat +++ b/tools/webidl_binder.bat @@ -44,10 +44,6 @@ ) ) -:NORMAL -@"%EM_PY%" "%~dp0\%~n0.py" %* -@exit /b %ERRORLEVEL% - :NORMAL_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* @exit %ERRORLEVEL% @@ -59,3 +55,6 @@ :MUTE_STDIN_EXIT @"%EM_PY%" "%~dp0\%~n0.py" %* < NUL @exit %ERRORLEVEL% + +:NORMAL +@"%EM_PY%" "%~dp0\%~n0.py" %*