Skip to content

Commit 0953200

Browse files
authored
GH-137484: Have Tools/wasm/wasi use the build triple instead of "build" (GH-37485)
This should help prevent issuse where something like a container is used to do one build and then someone tries to build again locally.
1 parent ffb5a53 commit 0953200

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Have ``Tools/wasm/wasi`` put the build Python into a directory named after
2+
the build triple instead of "build".

Tools/wasm/wasi/__main__.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
assert (CHECKOUT / "configure").is_file(), "Please update the location of the file"
2121

2222
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
23-
BUILD_DIR = CROSS_BUILD_DIR / "build"
23+
# Build platform can also be found via `config.guess`.
24+
BUILD_DIR = CROSS_BUILD_DIR / sysconfig.get_config_var("BUILD_GNU_TYPE")
2425

2526
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
2627
LOCAL_SETUP_MARKER = ("# Generated by Tools/wasm/wasi .\n"
@@ -80,7 +81,7 @@ def wrapper(context):
8081
print("📁", working_dir)
8182
if (clean_ok and getattr(context, "clean", False) and
8283
working_dir.exists()):
83-
print(f"🚮 Deleting directory (--clean)...")
84+
print("🚮 Deleting directory (--clean)...")
8485
shutil.rmtree(working_dir)
8586

8687
working_dir.mkdir(parents=True, exist_ok=True)
@@ -120,12 +121,6 @@ def call(command, *, context=None, quiet=False, logdir=None, **kwargs):
120121
subprocess.check_call(command, **kwargs, stdout=stdout, stderr=stderr)
121122

122123

123-
def build_platform():
124-
"""The name of the build/host platform."""
125-
# Can also be found via `config.guess`.
126-
return sysconfig.get_config_var("BUILD_GNU_TYPE")
127-
128-
129124
def build_python_path():
130125
"""The path to the build Python binary."""
131126
binary = BUILD_DIR / "python"
@@ -274,7 +269,7 @@ def configure_wasi_python(context, working_dir):
274269
# executed from within a checkout.
275270
configure = [os.path.relpath(CHECKOUT / 'configure', working_dir),
276271
f"--host={context.host_triple}",
277-
f"--build={build_platform()}",
272+
f"--build={BUILD_DIR.name}",
278273
f"--with-build-python={build_python}"]
279274
if build_python_is_pydebug():
280275
configure.append("--with-pydebug")
@@ -357,8 +352,8 @@ def main():
357352
"Python)")
358353
make_host = subcommands.add_parser("make-host",
359354
help="Run `make` for the host/WASI")
360-
clean = subcommands.add_parser("clean", help="Delete files and directories "
361-
"created by this script")
355+
subcommands.add_parser("clean", help="Delete files and directories "
356+
"created by this script")
362357
for subcommand in build, configure_build, make_build, configure_host, make_host:
363358
subcommand.add_argument("--quiet", action="store_true", default=False,
364359
dest="quiet",

0 commit comments

Comments
 (0)