From 1a66865922bfb12e25236ab62f91e7fa1bf3d93e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Thu, 18 Mar 2021 05:52:11 -0700 Subject: [PATCH 1/2] Fix parentheses mix-up in batch files in Windows After #13498, `test_asyncify_onlylist_a` and `test_asyncify_onlylist_b` started to failing. #13498 introduced `if ( ... ) else ( ... )` in emcc/em++.bat, and it turns out the parentheses inside the command line can be mixed with those `if`-`else`'s parentheses themselves. This does not cause errors for every command line that contain parentheses, but when there are both a comma and parentheses, this can trigger errors. For example, `test_asyncify_onlylist_a`'s argument contains something like this: ``` 'ASYNCIFY_ONLY=["main",...,"foo(int,double)",...]' ``` Here the comma between `int` and `double` is mistaken as an item separator within the list, and `)` after `double` is consequently mistaken as ending `if`, because the whole body is within an `if`. This PR fixes the problem by assigning those argument `%*` into a variable `ARGS`, and within `if` and `else`, use it with a substitution of `)` with the escaped end-paren `^)`. --- em++.bat | 5 +++-- emcc.bat | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/em++.bat b/em++.bat index 068b9e7dc6e7c..a90c4915d8c71 100644 --- a/em++.bat +++ b/em++.bat @@ -8,11 +8,12 @@ set EM_PY=python ) +@set ARGS=%* @if "%_EMCC_CCACHE%"=="" ( :: Do regular invocation of em++.py compiler - "%EM_PY%" "%~dp0\%~n0.py" %* + "%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)% ) else ( :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= - ccache "%~dp0\%~n0.bat" %* + ccache "%~dp0\%~n0.bat" %ARGS:)=^)% ) diff --git a/emcc.bat b/emcc.bat index 068b9e7dc6e7c..a90c4915d8c71 100644 --- a/emcc.bat +++ b/emcc.bat @@ -8,11 +8,12 @@ set EM_PY=python ) +@set ARGS=%* @if "%_EMCC_CCACHE%"=="" ( :: Do regular invocation of em++.py compiler - "%EM_PY%" "%~dp0\%~n0.py" %* + "%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)% ) else ( :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= - ccache "%~dp0\%~n0.bat" %* + ccache "%~dp0\%~n0.bat" %ARGS:)=^)% ) From 14ee985e5362c5ce32cb6e13c08400adb52c4489 Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Thu, 18 Mar 2021 14:03:33 -0700 Subject: [PATCH 2/2] Fix run_python_compiler.bat --- em++.bat | 2 +- emcc.bat | 2 +- tools/run_python_compiler.bat | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/em++.bat b/em++.bat index a90c4915d8c71..4f495e4781d5c 100644 --- a/em++.bat +++ b/em++.bat @@ -1,5 +1,5 @@ :: Entry point for running python scripts on windows systems. -:: To modify this file, edit `tools/run_python.bat` and then run +:: To modify this file, edit `tools/run_python_compiler.bat` and then run :: `tools/create_entry_points.py` @setlocal diff --git a/emcc.bat b/emcc.bat index a90c4915d8c71..4f495e4781d5c 100644 --- a/emcc.bat +++ b/emcc.bat @@ -1,5 +1,5 @@ :: Entry point for running python scripts on windows systems. -:: To modify this file, edit `tools/run_python.bat` and then run +:: To modify this file, edit `tools/run_python_compiler.bat` and then run :: `tools/create_entry_points.py` @setlocal diff --git a/tools/run_python_compiler.bat b/tools/run_python_compiler.bat index 068b9e7dc6e7c..4f495e4781d5c 100644 --- a/tools/run_python_compiler.bat +++ b/tools/run_python_compiler.bat @@ -1,5 +1,5 @@ :: Entry point for running python scripts on windows systems. -:: To modify this file, edit `tools/run_python.bat` and then run +:: To modify this file, edit `tools/run_python_compiler.bat` and then run :: `tools/create_entry_points.py` @setlocal @@ -8,11 +8,12 @@ set EM_PY=python ) +@set ARGS=%* @if "%_EMCC_CCACHE%"=="" ( :: Do regular invocation of em++.py compiler - "%EM_PY%" "%~dp0\%~n0.py" %* + "%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)% ) else ( :: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch. set _EMCC_CCACHE= - ccache "%~dp0\%~n0.bat" %* + ccache "%~dp0\%~n0.bat" %ARGS:)=^)% )