diff --git a/bootstrap.py b/bootstrap.py index 7ed6823571fd8..db8feeedfd601 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -104,7 +104,8 @@ def run_cmd(cmd): 'tools/maint/create_entry_points.py', 'tools/pylauncher/pylauncher.exe', 'tools/maint/run_python.bat', - 'tools/maint/run_python.sh', + 'tools/run_python.sh', + 'tools/run_python_compiler.sh', 'tools/maint/run_python.ps1', ], [sys.executable, 'tools/maint/create_entry_points.py']), ('git submodules', [ diff --git a/tools/maint/create_entry_points.py b/tools/maint/create_entry_points.py index ead15389b2eda..ebc8b6ea52d35 100755 --- a/tools/maint/create_entry_points.py +++ b/tools/maint/create_entry_points.py @@ -6,10 +6,8 @@ """Tool for creating/maintaining the python launcher scripts for emscripten tools. -This tool makes copies or `run_python.sh/.bat` and `run_python_compiler.sh/.bat` -script for each entry point. On UNIX we previously used symbolic links for -simplicity but this breaks MINGW users on windows who want to use the shell script -launcher but don't have symlink support. +This tool creates symbolic links (on UNIX) or executables/batch scripts (on Windows) +for each entry point. """ import os @@ -95,13 +93,13 @@ def main(all_platforms, use_bat_file): do_unix = all_platforms or not is_windows or is_msys2 do_windows = all_platforms or is_windows - def generate_entry_points(cmd, path): - sh_file = path + '.sh' - bat_file = path + '.bat' - ps1_file = path + '.ps1' - sh_file = read_file(sh_file) - bat_file = read_file(bat_file) - ps1_file = read_file(ps1_file) + def generate_entry_points(cmd, name): + sh_file_path = os.path.join(__rootdir__, 'tools', name + '.sh') + bat_file_path = os.path.join(__scriptdir__, name + '.bat') + ps1_file_path = os.path.join(__scriptdir__, name + '.ps1') + sh_file = read_file(sh_file_path) + bat_file = read_file(bat_file_path) + ps1_file = read_file(ps1_file_path) for entry_point in cmd: sh_data = sh_file @@ -114,8 +112,13 @@ def generate_entry_points(cmd, path): launcher = os.path.join(__rootdir__, entry_point) if do_unix: - write_file(launcher, sh_data) - make_executable(launcher) + if entry_point in entry_remap: + write_file(launcher, sh_data) + make_executable(launcher) + else: + target = os.path.relpath(sh_file_path, os.path.dirname(launcher)) + maybe_remove(launcher) + os.symlink(target, launcher) if do_windows: maybe_remove(launcher + '.ps1') @@ -126,8 +129,8 @@ def generate_entry_points(cmd, path): else: shutil.copyfile(windows_exe, launcher + '.exe') - generate_entry_points(entry_points, os.path.join(__scriptdir__, 'run_python')) - generate_entry_points(compiler_entry_points, os.path.join(__scriptdir__, 'run_python_compiler')) + generate_entry_points(entry_points, 'run_python') + generate_entry_points(compiler_entry_points, 'run_python_compiler') if __name__ == '__main__': diff --git a/tools/maint/run_python.sh b/tools/run_python.sh similarity index 80% rename from tools/maint/run_python.sh rename to tools/run_python.sh index 7e507c13ba9c1..5b7c50af8e608 100755 --- a/tools/maint/run_python.sh +++ b/tools/run_python.sh @@ -5,11 +5,6 @@ # found in the LICENSE file. # # Entry point for running python scripts on UNIX systems. -# -# Automatically generated by `create_entry_points.py`; DO NOT EDIT. -# -# To make modifications to this file, edit `tools/run_python.sh` and then run -# `tools/maint/create_entry_points.py` # python -E does not ignore _PYTHON_SYSCONFIGDATA_NAME, an internal of cpython # used in cross compilation via setup.py, so we unset it explicitly here. diff --git a/tools/maint/run_python_compiler.sh b/tools/run_python_compiler.sh old mode 100644 new mode 100755 similarity index 80% rename from tools/maint/run_python_compiler.sh rename to tools/run_python_compiler.sh index 32a246021a805..fe5cbecc1b25b --- a/tools/maint/run_python_compiler.sh +++ b/tools/run_python_compiler.sh @@ -5,11 +5,6 @@ # found in the LICENSE file. # # Entry point for running python scripts on UNIX systems. -# -# Automatically generated by `create_entry_points.py`; DO NOT EDIT. -# -# To make modifications to this file, edit `tools/maint/run_python_compiler.sh` and -# then run `tools/maint/create_entry_points.py` # python -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal # of cpython used in cross compilation via setup.py.