Skip to content

Commit ec7fad7

Browse files
authored
Touch up Setup.local handling in Tools/wasm/wasi (GH-137051)
The comment in the generated file is now more self-explanatory. The checks for unexpected file contents are also strengthened.
1 parent a10235e commit ec7fad7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Tools/wasm/wasi/__main__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
BUILD_DIR = CROSS_BUILD_DIR / "build"
2424

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

2829
WASMTIME_VAR_NAME = "WASMTIME"
2930
WASMTIME_HOST_RUNNER_VAR = f"{{{WASMTIME_VAR_NAME}}}"
@@ -141,9 +142,12 @@ def build_python_is_pydebug():
141142
def configure_build_python(context, working_dir):
142143
"""Configure the build/host Python."""
143144
if LOCAL_SETUP.exists():
144-
print(f"👍 {LOCAL_SETUP} exists ...")
145+
if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
146+
print(f"👍 {LOCAL_SETUP} exists ...")
147+
else:
148+
print(f"⚠️ {LOCAL_SETUP} exists, but has unexpected contents")
145149
else:
146-
print(f"📝 Touching {LOCAL_SETUP} ...")
150+
print(f"📝 Creating {LOCAL_SETUP} ...")
147151
LOCAL_SETUP.write_bytes(LOCAL_SETUP_MARKER)
148152

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

299303
if LOCAL_SETUP.exists():
300-
with LOCAL_SETUP.open("rb") as file:
301-
if file.read(len(LOCAL_SETUP_MARKER)) == LOCAL_SETUP_MARKER:
302-
print(f"🧹 Deleting generated {LOCAL_SETUP} ...")
304+
if LOCAL_SETUP.read_bytes() == LOCAL_SETUP_MARKER:
305+
print(f"🧹 Deleting generated {LOCAL_SETUP} ...")
303306

304307

305308
def main():

0 commit comments

Comments
 (0)