@@ -91,18 +91,25 @@ def wrapper(context):
91
91
return decorator
92
92
93
93
94
- def call (command , * , quiet , ** kwargs ):
94
+ def call (command , * , context = None , quiet = False , logdir = None , ** kwargs ):
95
95
"""Execute a command.
96
96
97
97
If 'quiet' is true, then redirect stdout and stderr to a temporary file.
98
98
"""
99
+ if context is not None :
100
+ quiet = context .quiet
101
+ logdir = context .logdir
102
+ elif quiet and logdir is None :
103
+ raise ValueError ("When quiet is True, logdir must be specified" )
104
+
99
105
print ("❯" , " " .join (map (str , command )))
100
106
if not quiet :
101
107
stdout = None
102
108
stderr = None
103
109
else :
104
110
stdout = tempfile .NamedTemporaryFile ("w" , encoding = "utf-8" ,
105
111
delete = False ,
112
+ dir = logdir ,
106
113
prefix = "cpython-wasi-" ,
107
114
suffix = ".log" )
108
115
stderr = subprocess .STDOUT
@@ -154,14 +161,14 @@ def configure_build_python(context, working_dir):
154
161
if context .args :
155
162
configure .extend (context .args )
156
163
157
- call (configure , quiet = context . quiet )
164
+ call (configure , context = context )
158
165
159
166
160
167
@subdir (BUILD_DIR )
161
168
def make_build_python (context , working_dir ):
162
169
"""Make/build the build Python."""
163
170
call (["make" , "--jobs" , str (cpu_count ()), "all" ],
164
- quiet = context . quiet )
171
+ context = context )
165
172
166
173
binary = build_python_path ()
167
174
cmd = [binary , "-c" ,
@@ -261,7 +268,7 @@ def configure_wasi_python(context, working_dir):
261
268
configure .extend (context .args )
262
269
call (configure ,
263
270
env = updated_env (env_additions | wasi_sdk_env (context )),
264
- quiet = context . quiet )
271
+ context = context )
265
272
266
273
python_wasm = working_dir / "python.wasm"
267
274
exec_script = working_dir / "python.sh"
@@ -277,7 +284,7 @@ def make_wasi_python(context, working_dir):
277
284
"""Run `make` for the WASI/host build."""
278
285
call (["make" , "--jobs" , str (cpu_count ()), "all" ],
279
286
env = updated_env (),
280
- quiet = context . quiet )
287
+ context = context )
281
288
282
289
exec_script = working_dir / "python.sh"
283
290
call ([exec_script , "--version" ], quiet = False )
@@ -317,6 +324,7 @@ def main():
317
324
"--dir {HOST_DIR}::{GUEST_DIR} "
318
325
# Set PYTHONPATH to the sysconfig data.
319
326
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}" )
327
+ default_logdir = pathlib .Path (tempfile .gettempdir ())
320
328
321
329
parser = argparse .ArgumentParser ()
322
330
subcommands = parser .add_subparsers (dest = "subcommand" )
@@ -339,6 +347,9 @@ def main():
339
347
subcommand .add_argument ("--quiet" , action = "store_true" , default = False ,
340
348
dest = "quiet" ,
341
349
help = "Redirect output from subprocesses to a log file" )
350
+ subcommand .add_argument ("--logdir" , type = pathlib .Path , default = default_logdir ,
351
+ help = "Directory to store log files; "
352
+ f"defaults to { default_logdir } " )
342
353
for subcommand in configure_build , configure_host :
343
354
subcommand .add_argument ("--clean" , action = "store_true" , default = False ,
344
355
dest = "clean" ,
0 commit comments