@@ -93,18 +93,25 @@ def wrapper(context):
93
93
return decorator
94
94
95
95
96
- def call (command , * , quiet , ** kwargs ):
96
+ def call (command , * , context = None , quiet = False , logdir = None , ** kwargs ):
97
97
"""Execute a command.
98
98
99
99
If 'quiet' is true, then redirect stdout and stderr to a temporary file.
100
100
"""
101
+ if context is not None :
102
+ quiet = context .quiet
103
+ logdir = context .logdir
104
+ elif quiet and logdir is None :
105
+ raise ValueError ("When quiet is True, logdir must be specified" )
106
+
101
107
print ("❯" , " " .join (map (str , command )))
102
108
if not quiet :
103
109
stdout = None
104
110
stderr = None
105
111
else :
106
112
stdout = tempfile .NamedTemporaryFile ("w" , encoding = "utf-8" ,
107
113
delete = False ,
114
+ dir = logdir ,
108
115
prefix = "cpython-wasi-" ,
109
116
suffix = ".log" )
110
117
stderr = subprocess .STDOUT
@@ -156,14 +163,14 @@ def configure_build_python(context, working_dir):
156
163
if context .args :
157
164
configure .extend (context .args )
158
165
159
- call (configure , quiet = context . quiet )
166
+ call (configure , context = context )
160
167
161
168
162
169
@subdir (BUILD_DIR )
163
170
def make_build_python (context , working_dir ):
164
171
"""Make/build the build Python."""
165
172
call (["make" , "--jobs" , str (cpu_count ()), "all" ],
166
- quiet = context . quiet )
173
+ context = context )
167
174
168
175
binary = build_python_path ()
169
176
cmd = [binary , "-c" ,
@@ -275,7 +282,7 @@ def configure_wasi_python(context, working_dir):
275
282
configure .extend (context .args )
276
283
call (configure ,
277
284
env = updated_env (env_additions | wasi_sdk_env (context )),
278
- quiet = context . quiet )
285
+ context = context )
279
286
280
287
python_wasm = working_dir / "python.wasm"
281
288
exec_script = working_dir / "python.sh"
@@ -291,7 +298,7 @@ def make_wasi_python(context, working_dir):
291
298
"""Run `make` for the WASI/host build."""
292
299
call (["make" , "--jobs" , str (cpu_count ()), "all" ],
293
300
env = updated_env (),
294
- quiet = context . quiet )
301
+ context = context )
295
302
296
303
exec_script = working_dir / "python.sh"
297
304
call ([exec_script , "--version" ], quiet = False )
@@ -333,6 +340,7 @@ def main():
333
340
"--dir {HOST_DIR}::{GUEST_DIR} "
334
341
# Set PYTHONPATH to the sysconfig data.
335
342
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}" )
343
+ default_logdir = pathlib .Path (tempfile .gettempdir ())
336
344
337
345
parser = argparse .ArgumentParser ()
338
346
subcommands = parser .add_subparsers (dest = "subcommand" )
@@ -355,6 +363,9 @@ def main():
355
363
subcommand .add_argument ("--quiet" , action = "store_true" , default = False ,
356
364
dest = "quiet" ,
357
365
help = "Redirect output from subprocesses to a log file" )
366
+ subcommand .add_argument ("--logdir" , type = pathlib .Path , default = default_logdir ,
367
+ help = "Directory to store log files; "
368
+ f"defaults to { default_logdir } " )
358
369
for subcommand in configure_build , configure_host :
359
370
subcommand .add_argument ("--clean" , action = "store_true" , default = False ,
360
371
dest = "clean" ,
0 commit comments