2020-07-11 00:06:41 +03:00
|
|
|
:: Entry point for running python scripts on windows systems.
|
2021-03-22 21:43:02 +03:00
|
|
|
::
|
|
|
|
:: Automatically generated by `create_entry_points.py`; DO NOT EDIT.
|
|
|
|
::
|
|
|
|
:: To make modifications to this file, edit `tools/run_python_compiler.bat` and
|
|
|
|
:: then run `tools/create_entry_points.py`
|
2020-04-15 20:27:21 +03:00
|
|
|
|
2021-10-06 21:11:45 +03:00
|
|
|
:: All env. vars specified in this file are to be local only to this script.
|
|
|
|
@setlocal
|
|
|
|
|
2020-11-15 22:43:04 +03:00
|
|
|
@set EM_PY=%EMSDK_PYTHON%
|
|
|
|
@if "%EM_PY%"=="" (
|
2020-07-23 08:10:11 +03:00
|
|
|
set EM_PY=python
|
2020-07-11 00:06:41 +03:00
|
|
|
)
|
|
|
|
|
2021-10-06 21:11:45 +03:00
|
|
|
:: 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.
|
2021-03-17 15:13:16 +03:00
|
|
|
@if "%_EMCC_CCACHE%"=="" (
|
2021-05-22 07:54:51 +03:00
|
|
|
set CMD="%EM_PY%" "%~dp0\%~n0.py"
|
2021-03-16 21:58:34 +03:00
|
|
|
) else (
|
2021-03-17 15:13:16 +03:00
|
|
|
set _EMCC_CCACHE=
|
2021-05-22 07:54:51 +03:00
|
|
|
set CMD=ccache "%~dp0\%~n0.bat"
|
2021-03-16 21:58:34 +03:00
|
|
|
)
|
2021-05-22 07:54:51 +03:00
|
|
|
|
2021-10-06 21:11:45 +03:00
|
|
|
:: 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, 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 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.
|
|
|
|
|
|
|
|
:: 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%"=="" (
|
|
|
|
goto NORMAL
|
|
|
|
) else (
|
|
|
|
goto NORMAL_EXIT
|
|
|
|
)
|
|
|
|
) else (
|
|
|
|
@if "%EM_WORKAROUND_WIN7_BAD_ERRORLEVEL_BUG%"=="" (
|
|
|
|
goto MUTE_STDIN
|
|
|
|
) else (
|
|
|
|
goto MUTE_STDIN_EXIT
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
:NORMAL_EXIT
|
|
|
|
@%CMD% %*
|
|
|
|
@exit %ERRORLEVEL%
|
|
|
|
|
|
|
|
:MUTE_STDIN
|
|
|
|
@%CMD% %* < NUL
|
|
|
|
@exit /b %ERRORLEVEL%
|
|
|
|
|
|
|
|
:MUTE_STDIN_EXIT
|
|
|
|
@%CMD% %* < NUL
|
|
|
|
@exit %ERRORLEVEL%
|
|
|
|
|
|
|
|
:NORMAL
|
2021-05-22 07:54:51 +03:00
|
|
|
@%CMD% %*
|