Skip to content

Conversation

@aheejin
Copy link
Member

@aheejin aheejin commented Mar 18, 2021

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 ^).

After emscripten-core#13498, `test_asyncify_onlylist_a` and `test_asyncify_onlylist_b`
started to failing. emscripten-core#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 `^)`.
@aheejin aheejin requested review from juj and sbc100 March 18, 2021 13:13
Copy link
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, pretty crazy looking syntax.

Can you end tools/run_python_compiler.bat and ru-run tools/create_entry_points.py?

@aheejin
Copy link
Member Author

aheejin commented Mar 18, 2021

Done. Didn't know they are copied from a template..

@aheejin aheejin merged commit 42cd632 into emscripten-core:main Mar 20, 2021
@aheejin aheejin deleted the fix_windows_paren branch March 20, 2021 02:56
aheejin added a commit to aheejin/emscripten that referenced this pull request Mar 20, 2021
This issue was attempted to fix in emscripten-core#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.
aheejin added a commit that referenced this pull request Mar 22, 2021
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants