From 0cddccb13a2ef11bd3ac8040485716aacef4a093 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 22 Jul 2020 22:10:11 -0700 Subject: [PATCH] Support spaces in python executable in .bat launcher scripts (#11691) Fixes: #11638 --- em++.bat | 11 ++++------- em-config.bat | 11 ++++------- emar.bat | 11 ++++------- embuilder.bat | 11 ++++------- emcc.bat | 11 ++++------- emcmake.bat | 11 ++++------- emconfigure.bat | 11 ++++------- emmake.bat | 11 ++++------- emranlib.bat | 11 ++++------- emrun.bat | 11 ++++------- emscons.bat | 11 ++++------- emsize.bat | 11 ++++------- tools/run_python.bat | 11 ++++------- tools/system_libs.py | 2 +- 14 files changed, 53 insertions(+), 92 deletions(-) diff --git a/em++.bat b/em++.bat index baf39797170dd..970765d860d8a 100644 --- a/em++.bat +++ b/em++.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/em-config.bat b/em-config.bat index baf39797170dd..970765d860d8a 100644 --- a/em-config.bat +++ b/em-config.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emar.bat b/emar.bat index baf39797170dd..970765d860d8a 100644 --- a/emar.bat +++ b/emar.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/embuilder.bat b/embuilder.bat index baf39797170dd..970765d860d8a 100644 --- a/embuilder.bat +++ b/embuilder.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emcc.bat b/emcc.bat index baf39797170dd..970765d860d8a 100644 --- a/emcc.bat +++ b/emcc.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emcmake.bat b/emcmake.bat index baf39797170dd..970765d860d8a 100644 --- a/emcmake.bat +++ b/emcmake.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emconfigure.bat b/emconfigure.bat index baf39797170dd..970765d860d8a 100644 --- a/emconfigure.bat +++ b/emconfigure.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emmake.bat b/emmake.bat index baf39797170dd..970765d860d8a 100644 --- a/emmake.bat +++ b/emmake.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emranlib.bat b/emranlib.bat index baf39797170dd..970765d860d8a 100644 --- a/emranlib.bat +++ b/emranlib.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emrun.bat b/emrun.bat index baf39797170dd..970765d860d8a 100644 --- a/emrun.bat +++ b/emrun.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emscons.bat b/emscons.bat index baf39797170dd..970765d860d8a 100644 --- a/emscons.bat +++ b/emscons.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/emsize.bat b/emsize.bat index baf39797170dd..970765d860d8a 100644 --- a/emsize.bat +++ b/emsize.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tools/run_python.bat b/tools/run_python.bat index baf39797170dd..970765d860d8a 100644 --- a/tools/run_python.bat +++ b/tools/run_python.bat @@ -3,12 +3,9 @@ :: To modify this file, edit `tools/run_python.bat` and then run :: `tools/create_entry_points.py` -@IF "%PYTHON%"=="" ( - @SET PYTHON=%EMSDK_PYTHON% +set EM_PY=%EMSDK_PYTHON% +if "%EM_PY%"=="" ( + set EM_PY=python ) -@IF "%PYTHON%"=="" ( - @SET PYTHON=python -) - -%PYTHON% "%~dp0\%~n0.py" %* +"%EM_PY%" "%~dp0\%~n0.py" %* diff --git a/tools/system_libs.py b/tools/system_libs.py index 9107d360cd552..46775e0be2a21 100755 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -68,7 +68,7 @@ def get_cflags(force_object_files=False): def run_one_command(cmd): # Helper function used by run_build_commands. if shared.EM_BUILD_VERBOSE: - print(' '.join(cmd)) + print(shared.shlex_join(cmd)) # building system libraries and ports should be hermetic in that it is not # affected by things like EMMAKEN_CFLAGS which the user may have set safe_env = os.environ.copy()