Skip to content

Touch up Setup.local handling in Tools/wasm/wasi #137051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Touch up Setup.local handling in Tools/wasm/wasi
The comment in the generated file is more self-explanatory. The checks for unexpected file contents are also strengthened.
  • Loading branch information
brettcannon committed Jul 23, 2025
commit 8f44e7863654700d5f99d70a79146ae640e9e57f
15 changes: 9 additions & 6 deletions Tools/wasm/wasi/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
BUILD_DIR = CROSS_BUILD_DIR / "build"

LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8")
LOCAL_SETUP_MARKER = ("# Generated by Tools/wasm/wasi .\n"
"# Required to statically build extension modules.").encode("utf-8")

WASMTIME_VAR_NAME = "WASMTIME"
WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}"
Expand Down Expand Up @@ -141,9 +142,12 @@ def build_python_is_pydebug():
def configure_build_python(context, working_dir):
"""Configure the build/host Python."""
if LOCAL_SETUP.exists():
print(f"👍 {LOCAL_SETUP} exists ...")
if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
print(f"👍 {LOCAL_SETUP} exists ...")
else:
print(f"⚠️ {LOCAL_SETUP} exists, but has unexpected contents")
else:
print(f"📝 Touching {LOCAL_SETUP} ...")
print(f"📝 Creating {LOCAL_SETUP} ...")
LOCAL_SETUP.write_bytes(LOCAL_SETUP_MARKER)

configure = [os.path.relpath(CHECKOUT / 'configure', working_dir)]
Expand Down Expand Up @@ -297,9 +301,8 @@ def clean_contents(context):
shutil.rmtree(CROSS_BUILD_DIR)

if LOCAL_SETUP.exists():
with LOCAL_SETUP.open("rb") as file:
if file.read(len(LOCAL_SETUP_MARKER)) == LOCAL_SETUP_MARKER:
print(f"🧹 Deleting generated {LOCAL_SETUP} ...")
if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
print(f"🧹 Deleting generated {LOCAL_SETUP} ...")


def main():
Expand Down
Loading