Skip to content

Commit 533d712

Browse files
authored
Correctly fix windows parentheses mix-up (#13723)
This issue was attempted to fix in #13698 by escaping `)` but it turned out to be an incomplete fix, because it fixed the breaking tests then but broke other ones instead depending on their syntax. This PR tries to fix it correctly by using `enabledelayedexpansion` feature of batch files. We can enable delayed expansion of variables within a batch file by ``` @SETLOCAL enabledelayedexpansion ``` And if you use variables not by the usual syntax `%VAR%` but `!VAR!`, it is expanded in a delayed manner, after all parentheses for `if`s and `else`s are expanded.
1 parent 7cecaba commit 533d712

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

em++.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:: To modify this file, edit `tools/run_python_compiler.bat` and then run
33
:: `tools/create_entry_points.py`
44

5-
@setlocal
5+
@setlocal enabledelayedexpansion
66
@set EM_PY=%EMSDK_PYTHON%
77
@if "%EM_PY%"=="" (
88
set EM_PY=python
@@ -11,9 +11,9 @@
1111
@set ARGS=%*
1212
@if "%_EMCC_CCACHE%"=="" (
1313
:: Do regular invocation of em++.py compiler
14-
"%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)%
14+
"%EM_PY%" "%~dp0\%~n0.py" !ARGS!
1515
) else (
1616
:: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch.
1717
set _EMCC_CCACHE=
18-
ccache "%~dp0\%~n0.bat" %ARGS:)=^)%
18+
ccache "%~dp0\%~n0.bat" !ARGS!
1919
)

emcc.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:: To modify this file, edit `tools/run_python_compiler.bat` and then run
33
:: `tools/create_entry_points.py`
44

5-
@setlocal
5+
@setlocal enabledelayedexpansion
66
@set EM_PY=%EMSDK_PYTHON%
77
@if "%EM_PY%"=="" (
88
set EM_PY=python
@@ -11,9 +11,9 @@
1111
@set ARGS=%*
1212
@if "%_EMCC_CCACHE%"=="" (
1313
:: Do regular invocation of em++.py compiler
14-
"%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)%
14+
"%EM_PY%" "%~dp0\%~n0.py" !ARGS!
1515
) else (
1616
:: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch.
1717
set _EMCC_CCACHE=
18-
ccache "%~dp0\%~n0.bat" %ARGS:)=^)%
18+
ccache "%~dp0\%~n0.bat" !ARGS!
1919
)

tools/run_python_compiler.bat

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
:: To modify this file, edit `tools/run_python_compiler.bat` and then run
33
:: `tools/create_entry_points.py`
44

5-
@setlocal
5+
@setlocal enabledelayedexpansion
66
@set EM_PY=%EMSDK_PYTHON%
77
@if "%EM_PY%"=="" (
88
set EM_PY=python
@@ -11,9 +11,9 @@
1111
@set ARGS=%*
1212
@if "%_EMCC_CCACHE%"=="" (
1313
:: Do regular invocation of em++.py compiler
14-
"%EM_PY%" "%~dp0\%~n0.py" %ARGS:)=^)%
14+
"%EM_PY%" "%~dp0\%~n0.py" !ARGS!
1515
) else (
1616
:: Remove the ccache env. var, invoke ccache and re-enter this script to take the above branch.
1717
set _EMCC_CCACHE=
18-
ccache "%~dp0\%~n0.bat" %ARGS:)=^)%
18+
ccache "%~dp0\%~n0.bat" !ARGS!
1919
)

0 commit comments

Comments
 (0)