Skip to content

Commit dc8a6fd

Browse files
authored
feat(ngspice): save stdout and stderr to file ngspice.out (#616)
1 parent 9ca3cf9 commit dc8a6fd

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

tools/ngspice/src/lib.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use spice::netlist::{
2424
};
2525
use spice::Spice;
2626
use substrate::context::Installation;
27-
use substrate::execute::Executor;
27+
use substrate::execute::{ExecOpts, Executor, LogOutput};
2828
use substrate::schematic::schema::Schema;
2929
use substrate::simulation::{SimulationContext, Simulator};
3030
use templates::{write_run_script, RunScriptContext};
@@ -297,6 +297,7 @@ struct CachedSimState {
297297
input: Vec<Input>,
298298
netlist: PathBuf,
299299
output_file: PathBuf,
300+
stdout_path: PathBuf,
300301
log: PathBuf,
301302
err_log: PathBuf,
302303
run_script: PathBuf,
@@ -317,6 +318,7 @@ impl CacheableWithState<CachedSimState> for CachedSim {
317318
input,
318319
netlist,
319320
output_file,
321+
stdout_path,
320322
log,
321323
err_log,
322324
run_script,
@@ -343,7 +345,13 @@ impl CacheableWithState<CachedSimState> for CachedSim {
343345
let mut command = std::process::Command::new("/bin/bash");
344346
command.arg(&run_script).current_dir(&work_dir);
345347
executor
346-
.execute(command, Default::default())
348+
.execute(
349+
command,
350+
ExecOpts {
351+
logs: LogOutput::File(stdout_path),
352+
..Default::default()
353+
},
354+
)
347355
.map_err(|_| Error::NgspiceError)?;
348356

349357
let contents = std::fs::read(&output_file)?;
@@ -431,6 +439,7 @@ impl Ngspice {
431439

432440
let output_file = ctx.work_dir.join("data.raw");
433441
let log = ctx.work_dir.join("ngspice.log");
442+
let stdout_path = ctx.work_dir.join("ngspice.out");
434443
let err_log = ctx.work_dir.join("ngspice.err");
435444
let run_script = ctx.work_dir.join("simulate.sh");
436445
let work_dir = ctx.work_dir.clone();
@@ -448,6 +457,7 @@ impl Ngspice {
448457
input,
449458
netlist,
450459
output_file,
460+
stdout_path,
451461
log,
452462
err_log,
453463
run_script,

0 commit comments

Comments
 (0)