From 1404dc6813819f644eae20902a5a919d83b2603e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 5 Jun 2026 10:56:36 -0700 Subject: [PATCH] Don't use a launcher for bootstrap.py. NFC This script is only supposed to be run by folks using emscripten via a git checkout. Since the boostrap script it self creates all the launcher programs we have chicken and egg situation where we would need to keep these launchers in source control just for this one script. Instead, I think we can just say that using emscripten from git checkout requires the running on the python a script. --- .circleci/config.yml | 2 +- .github/workflows/ci.yml | 4 +- .gitignore | 1 - bootstrap | 33 ------------ bootstrap.bat | 86 ------------------------------ bootstrap.py | 2 +- tools/maint/create_entry_points.py | 5 -- tools/maint/post-checkout | 2 +- 8 files changed, 5 insertions(+), 130 deletions(-) delete mode 100755 bootstrap delete mode 100644 bootstrap.bat diff --git a/.circleci/config.yml b/.circleci/config.yml index a15021754d835..474c00e156779 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -57,7 +57,7 @@ commands: bootstrap: description: "bootstrap" steps: - - run: ./bootstrap + - run: "$EMSDK_PYTHON ./bootstrap.py" pip-install: description: "pip install" parameters: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be9dfcd59af6f..c3a1cf2d56c7f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,7 +60,7 @@ jobs: # Uncomment this like to pull the rebaseline_tests.py from the # current branch: # git checkout - ./tools/maint/rebaseline_tests.py - ./bootstrap + ./bootstrap.py if ! ./tools/maint/rebaseline_tests.py --check-only; then echo "" echo "Test expectations are out-of-date on the target branch." @@ -83,7 +83,7 @@ jobs: # since it doesn't recognise it. git checkout ${{ github.sha }} git rev-parse HEAD - ./bootstrap + ./bootstrap.py if ! ./tools/maint/rebaseline_tests.py --check-only --clear-cache; then echo "Test expectations are out-of-date on the PR branch." echo "You can run './tools/maint/rebaseline_tests.py' to" diff --git a/.gitignore b/.gitignore index f2394642782cb..234517cc97797 100644 --- a/.gitignore +++ b/.gitignore @@ -91,7 +91,6 @@ test/runner.bat tools/file_packager.bat tools/webidl_binder.bat -bootstrap.exe em++.exe emcc.exe em-config.exe diff --git a/bootstrap b/bootstrap deleted file mode 100755 index 7e507c13ba9c1..0000000000000 --- a/bootstrap +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Copyright 2020 The Emscripten Authors. All rights reserved. -# Emscripten is available under two separate licenses, the MIT license and the -# University of Illinois/NCSA Open Source License. Both these licenses can be -# 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. -unset _PYTHON_SYSCONFIGDATA_NAME - -_EM_PY=$EMSDK_PYTHON - -if [ -z "$_EM_PY" ]; then - _EM_PY=$(command -v python3 2> /dev/null) -fi - -if [ -z "$_EM_PY" ]; then - _EM_PY=$(command -v python 2> /dev/null) -fi - -if [ -z "$_EM_PY" ]; then - echo 'unable to find python in $PATH' - exit 1 -fi - -exec "$_EM_PY" -E "$0.py" "$@" diff --git a/bootstrap.bat b/bootstrap.bat deleted file mode 100644 index e9080623b77f0..0000000000000 --- a/bootstrap.bat +++ /dev/null @@ -1,86 +0,0 @@ -:: Entry point for running python scripts on windows systems. -:: -:: Automatically generated by `create_entry_points.py`; DO NOT EDIT. -:: -:: To make modifications to this file, edit `tools\run_python.bat` and then run -:: `tools\maint\create_entry_points.py` - -:: N.b. In Windows .bat scripts, the ':' character cannot appear inside any if () blocks, -:: or there will be a parsing error. - -:: All env. vars specified in this file are to be local only to this script. -@setlocal -:: -E will not ignore _PYTHON_SYSCONFIGDATA_NAME an internal -:: of cpython used in cross compilation via setup.py. -@set _PYTHON_SYSCONFIGDATA_NAME= -@set _EM_PY=%EMSDK_PYTHON% -@if "%_EM_PY%"=="" ( - set _EM_PY=python -) - -:: Work around Windows bug https://github.com/microsoft/terminal/issues/15212 : If this -:: script is invoked via enclosing the invocation in quotes via PATH lookup, then %~f0 and -:: %~dp0 expansions will not work. -:: So first try if %~dp0 might work, and if not, manually look up this script from PATH. -@if exist "%~f0" ( - set "MYDIR=%~dp0" - goto FOUND_MYDIR -) -@for %%I in (%~n0.bat) do ( - @if exist %%~$PATH:I ( - set MYDIR=%%~dp$PATH:I - ) else ( - echo Fatal Error! Due to a Windows bug, we are unable to locate the path to %~n0.bat. - echo To help this issue, try removing unnecessary quotes in the invocation of emcc, - echo or add Emscripten directory to PATH. - echo See github.com/microsoft/terminal/issues/15212 and - echo github.com/emscripten-core/emscripten/issues/19207 for more details. - ) -) -:FOUND_MYDIR - -:: 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 -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* -@exit %ERRORLEVEL% - -:MUTE_STDIN -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL -@exit /b %ERRORLEVEL% - -:MUTE_STDIN_EXIT -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* < NUL -@exit %ERRORLEVEL% - -:NORMAL -@"%_EM_PY%" -E "%MYDIR%%~n0.py" %* diff --git a/bootstrap.py b/bootstrap.py index 777fee3fa99df..00375cac33724 100755 --- a/bootstrap.py +++ b/bootstrap.py @@ -61,7 +61,7 @@ def check_deps(name, deps): def check(): for name, deps, _ in actions: if not check_deps(name, deps): - utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run `bootstrap` to update') + utils.exit_with_error(f'emscripten setup is not complete ("{name}" is out-of-date). Run `bootstrap.py` to update') def main(args): diff --git a/tools/maint/create_entry_points.py b/tools/maint/create_entry_points.py index 0cc033132c2c3..8f210706c2a68 100755 --- a/tools/maint/create_entry_points.py +++ b/tools/maint/create_entry_points.py @@ -26,7 +26,6 @@ '''.split() entry_points = ''' -bootstrap emar embuilder emcmake @@ -115,10 +114,6 @@ def generate_entry_points(cmd, path): make_executable(launcher) if do_windows: - if entry_point != 'bootstrap': - # The bootstrap.bat file is checked into source control so we - # don't want to delete it. - maybe_remove(launcher + '.bat') maybe_remove(launcher + '.ps1') maybe_remove(launcher + '.exe') if use_bat_file: diff --git a/tools/maint/post-checkout b/tools/maint/post-checkout index c4838f1ac1940..f18b7dd6b01d2 100755 --- a/tools/maint/post-checkout +++ b/tools/maint/post-checkout @@ -10,4 +10,4 @@ # Test for the existence of the bootstrap script itself to handle branches # that predate its existence. -test -f ./bootstrap && exec ./bootstrap +test -f ./bootstrap.py && exec ./bootstrap.py