Skip to content

Commit 4c1d07d

Browse files
authored
Add launcher script for emsymbolizer (#16554)
1 parent 0f00d97 commit 4c1d07d

File tree

4 files changed

+94
-2
lines changed

4 files changed

+94
-2
lines changed

emsymbolizer

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
# Copyright 2020 The Emscripten Authors. All rights reserved.
3+
# Emscripten is available under two separate licenses, the MIT license and the
4+
# University of Illinois/NCSA Open Source License. Both these licenses can be
5+
# found in the LICENSE file.
6+
#
7+
# Entry point for running python scripts on UNIX systems.
8+
#
9+
# Automatically generated by `create_entry_points.py`; DO NOT EDIT.
10+
#
11+
# To make modifications to this file, edit `tools/run_python.sh` and then run
12+
# `tools/create_entry_points.py`
13+
14+
if [ -z "$PYTHON" ]; then
15+
PYTHON=$EMSDK_PYTHON
16+
fi
17+
18+
if [ -z "$PYTHON" ]; then
19+
PYTHON=$(command -v python3 2> /dev/null)
20+
fi
21+
22+
if [ -z "$PYTHON" ]; then
23+
PYTHON=$(command -v python 2> /dev/null)
24+
fi
25+
26+
if [ -z "$PYTHON" ]; then
27+
echo 'unable to find python in $PATH'
28+
exit 1
29+
fi
30+
31+
exec "$PYTHON" "$0.py" "$@"

emsymbolizer.bat

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
:: Entry point for running python scripts on windows systems.
2+
::
3+
:: Automatically generated by `create_entry_points.py`; DO NOT EDIT.
4+
::
5+
:: To make modifications to this file, edit `tools/run_python.bat` and then run
6+
:: `tools/create_entry_points.py`
7+
8+
:: All env. vars specified in this file are to be local only to this script.
9+
@setlocal
10+
11+
@set EM_PY=%EMSDK_PYTHON%
12+
@if "%EM_PY%"=="" (
13+
set EM_PY=python
14+
)
15+
16+
:: Python Windows bug https://bugs.python.org/issue34780: If this script was invoked via a
17+
:: shared stdin handle from the parent process, and that parent process stdin handle is in
18+
:: a certain state, running python.exe might hang here. To work around this, if
19+
:: EM_WORKAROUND_PYTHON_BUG_34780 is defined, invoke python with '< NUL' stdin to avoid
20+
:: sharing the parent's stdin handle to it, avoiding the hang.
21+
22+
:: On Windows 7, the compiler batch scripts are observed to exit with a non-zero errorlevel,
23+
:: even when the python executable above did succeed and quit with errorlevel 0 above.
24+
:: On Windows 8 and newer, this issue has not been observed. It is possible that this
25+
:: issue is related to the above python bug, but this has not been conclusively confirmed,
26+
:: so using a separate env. var EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG to enable the known
27+
:: workaround this issue, which is to explicitly quit the calling process with the previous
28+
:: errorlevel from the above command.
29+
30+
:: Also must use goto to jump to the command dispatch, since we cannot invoke emcc from
31+
:: inside a if() block, because if a cmdline param would contain a char '(' or ')', that
32+
:: would throw off the parsing of the cmdline arg.
33+
@if "%EM_WORKAROUND_PYTHON_BUG_34780%"=="" (
34+
@if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" (
35+
goto NORMAL
36+
) else (
37+
goto NORMAL_EXIT
38+
)
39+
) else (
40+
@if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" (
41+
goto MUTE_STDIN
42+
) else (
43+
goto MUTE_STDIN_EXIT
44+
)
45+
)
46+
47+
:NORMAL_EXIT
48+
@"%EM_PY%" "%~dp0\%~n0.py" %*
49+
@exit %ERRORLEVEL%
50+
51+
:MUTE_STDIN
52+
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
53+
@exit /b %ERRORLEVEL%
54+
55+
:MUTE_STDIN_EXIT
56+
@"%EM_PY%" "%~dp0\%~n0.py" %* < NUL
57+
@exit %ERRORLEVEL%
58+
59+
:NORMAL
60+
@"%EM_PY%" "%~dp0\%~n0.py" %*

tests/test_other.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
emconfig = shared.bat_suffix(path_from_root('em-config'))
4949
emsize = shared.bat_suffix(path_from_root('emsize'))
5050
emprofile = shared.bat_suffix(path_from_root('emprofile'))
51+
emsymbolizer = shared.bat_suffix(path_from_root('emsymbolizer'))
5152
wasm_opt = Path(building.get_binaryen_bin(), 'wasm-opt')
5253

5354

@@ -8379,8 +8380,7 @@ def test_emsymbolizer(self):
83798380

83808381
def get_addr(address):
83818382
return self.run_process(
8382-
[PYTHON, path_from_root('emsymbolizer.py'), 'test_dwarf.wasm', address],
8383-
stdout=PIPE).stdout
8383+
[emsymbolizer, 'test_dwarf.wasm', address], stdout=PIPE).stdout
83848384

83858385
# Check a location in foo(), not inlined.
83868386
self.assertIn('test_dwarf.c:6:3', get_addr('0x101'))

tools/create_entry_points.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
emdwp
3939
emnm
4040
emstrip
41+
emsymbolizer
4142
tools/file_packager
4243
tools/webidl_binder
4344
tests/runner

0 commit comments

Comments
 (0)