20
20
21
21
CROSS_BUILD_DIR = CHECKOUT / "cross-build"
22
22
BUILD_DIR = CROSS_BUILD_DIR / "build"
23
- HOST_TRIPLE = "wasm32-wasi"
24
- HOST_DIR = CROSS_BUILD_DIR / HOST_TRIPLE
25
23
26
24
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
27
25
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/wasi.py\n " .encode ("utf-8" )
@@ -63,12 +61,17 @@ def subdir(working_dir, *, clean_ok=False):
63
61
def decorator (func ):
64
62
@functools .wraps (func )
65
63
def wrapper (context ):
64
+ nonlocal working_dir
65
+
66
+ if callable (working_dir ):
67
+ working_dir = working_dir (context )
66
68
try :
67
69
tput_output = subprocess .check_output (["tput" , "cols" ],
68
70
encoding = "utf-8" )
69
- terminal_width = int (tput_output .strip ())
70
71
except subprocess .CalledProcessError :
71
72
terminal_width = 80
73
+ else :
74
+ terminal_width = int (tput_output .strip ())
72
75
print ("⎯" * terminal_width )
73
76
print ("📁" , working_dir )
74
77
if (clean_ok and getattr (context , "clean" , False ) and
@@ -193,7 +196,7 @@ def wasi_sdk_env(context):
193
196
return env
194
197
195
198
196
- @subdir (HOST_DIR , clean_ok = True )
199
+ @subdir (lambda context : CROSS_BUILD_DIR / context . host_triple , clean_ok = True )
197
200
def configure_wasi_python (context , working_dir ):
198
201
"""Configure the WASI/host build."""
199
202
if not context .wasi_sdk_path or not context .wasi_sdk_path .exists ():
@@ -238,7 +241,7 @@ def configure_wasi_python(context, working_dir):
238
241
# to find the stdlib due to Python not recognizing that it's being
239
242
# executed from within a checkout.
240
243
configure = [os .path .relpath (CHECKOUT / 'configure' , working_dir ),
241
- f"--host={ HOST_TRIPLE } " ,
244
+ f"--host={ context . host_triple } " ,
242
245
f"--build={ build_platform ()} " ,
243
246
f"--with-build-python={ build_python } " ]
244
247
if pydebug :
@@ -258,7 +261,7 @@ def configure_wasi_python(context, working_dir):
258
261
sys .stdout .flush ()
259
262
260
263
261
- @subdir (HOST_DIR )
264
+ @subdir (lambda context : CROSS_BUILD_DIR / context . host_triple )
262
265
def make_wasi_python (context , working_dir ):
263
266
"""Run `make` for the WASI/host build."""
264
267
call (["make" , "--jobs" , str (cpu_count ()), "all" ],
@@ -343,6 +346,9 @@ def main():
343
346
help = "Command template for running the WASI host "
344
347
"(default designed for wasmtime 14 or newer: "
345
348
f"`{ default_host_runner } `)" )
349
+ for subcommand in build , configure_host , make_host :
350
+ subcommand .add_argument ("--host-triple" , action = "store" , default = "wasm32-wasi" ,
351
+ help = "The target triple for the WASI host build" )
346
352
347
353
context = parser .parse_args ()
348
354
0 commit comments