10000 GH-121634: have `wasi.py` accept the host target triple as an argumen… · miss-islington/cpython@b15b81e · GitHub
[go: up one dir, main page]

Skip to content

Commit b15b81e

Browse files
authored
pythonGH-121634: have wasi.py accept the host target triple as an argument (pythonGH-123030)
1 parent e001027 commit b15b81e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allow for specifying the target compile triple for WASI.

Tools/wasm/wasi.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020

2121
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
2222
BUILD_DIR = CROSS_BUILD_DIR / "build"
23-
HOST_TRIPLE = "wasm32-wasi"
24-
HOST_DIR = CROSS_BUILD_DIR / HOST_TRIPLE
2523

2624
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
2725
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n".encode("utf-8")
@@ -63,12 +61,17 @@ def subdir(working_dir, *, clean_ok=False):
6361
def decorator(func):
6462
@functools.wraps(func)
6563
def wrapper(context):
64+
nonlocal working_dir
65+
66+
if callable(working_dir):
67+
working_dir = working_dir(context)
6668
try:
6769
tput_output = subprocess.check_output(["tput", "cols"],
6870
encoding="utf-8")
69-
terminal_width = int(tput_output.strip())
7071
except subprocess.CalledProcessError:
7172
terminal_width = 80
73+
else:
74+
terminal_width = int(tput_output.strip())
7275
print("⎯" * terminal_width)
7376
print("📁", working_dir)
7477
if (clean_ok and getattr(context, "clean", False) and
@@ -193,7 +196,7 @@ def wasi_sdk_env(context):
193196
return env
194197

195198

196-
@subdir(HOST_DIR, clean_ok=True)
199+
@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple, clean_ok=True)
197200
def configure_wasi_python(context, working_dir):
198201
"""Configure the WASI/host build."""
199202
if not context.wasi_sdk_path or not context.wasi_sdk_path.exists():
@@ -238,7 +241,7 @@ def configure_wasi_python(context, working_dir):
238241
# to find the stdlib due to Python not recognizing that it's being
239242
# executed from within a checkout.
240243
configure = [os.path.relpath(CHECKOUT / 'configure', working_dir),
241-
f"--host={HOST_TRIPLE}",
244+
f"--host={context.host_triple}",
242245
f"--build={build_platform()}",
243246
f"--with-build-python={build_python}"]
244247
if pydebug:
@@ -258,7 +261,7 @@ def configure_wasi_python(context, working_dir):
258261
sys.stdout.flush()
259262

260263

261-
@subdir(HOST_DIR)
264+
@subdir(lambda context: CROSS_BUILD_DIR / context.host_triple)
262265
def make_wasi_python(context, working_dir):
263266
"""Run `make` for the WASI/host build."""
264267
call(["make", "--jobs", str(cpu_count()), "all"],
@@ -342,6 +345,9 @@ def main():
342345
help="Command template for running the WASI host "
343346
"(default designed for wasmtime 14 or newer: "
344347
f"`{default_host_runner}`)")
348+
for subcommand in build, configure_host, make_host:
349+
subcommand.add_argument("--host-triple", action="store", default="wasm32-wasi",
350+
help="The target triple for the WASI host build")
345351

346352
context = parser.parse_args()
347353

0 commit comments

Comments
 (0)
0