mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
output name specifier
This commit is contained in:
parent
5c2e3048df
commit
26dd4f53e1
|
@ -1,4 +1,4 @@
|
||||||
use std::{fs, io::Write, process::Command};
|
use std::{fs, io::Write, process::Command, path::PathBuf};
|
||||||
|
|
||||||
use clap::Parser as ArgParser;
|
use clap::Parser as ArgParser;
|
||||||
|
|
||||||
|
@ -94,10 +94,7 @@ fn main() {
|
||||||
logif!(0, "Successfully generated code.");
|
logif!(0, "Successfully generated code.");
|
||||||
|
|
||||||
// Write code to file
|
// Write code to file
|
||||||
let output_path = match output {
|
let output_path: PathBuf = file_name.with_extension("cpp").file_name().unwrap().to_os_string().into();
|
||||||
Some(output) => output,
|
|
||||||
None => file_name.with_extension("cpp").file_name().unwrap().to_os_string().into(),
|
|
||||||
};
|
|
||||||
let mut file = fs::File::create(&output_path).expect("Failed to create file");
|
let mut file = fs::File::create(&output_path).expect("Failed to create file");
|
||||||
file.write_all(codegen.emitted.as_bytes()).expect("Failed to write to file");
|
file.write_all(codegen.emitted.as_bytes()).expect("Failed to write to file");
|
||||||
|
|
||||||
|
@ -105,6 +102,16 @@ fn main() {
|
||||||
let compiler = &config.compiler.compiler;
|
let compiler = &config.compiler.compiler;
|
||||||
Command::new(compiler)
|
Command::new(compiler)
|
||||||
.arg(&output_path)
|
.arg(&output_path)
|
||||||
|
.arg(format!("-o{}", match output {
|
||||||
|
Some(o) => o.display().to_string(),
|
||||||
|
None => file_name
|
||||||
|
.with_extension("out")
|
||||||
|
.file_name()
|
||||||
|
.unwrap()
|
||||||
|
.to_str()
|
||||||
|
.unwrap()
|
||||||
|
.to_string(),
|
||||||
|
}))
|
||||||
.spawn()
|
.spawn()
|
||||||
.expect("Failed to run compiler");
|
.expect("Failed to run compiler");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue