7117b927f3
interface for build tools - updated editor and build tooling to use new system
34 lines
862 B
Rust
34 lines
862 B
Rust
use std::path::{Path, PathBuf};
|
|
|
|
use common::{build::Builder, logging::log};
|
|
use compiler::Compiler;
|
|
|
|
fn main() {
|
|
// read from input file: syntax "c_compiler <src.c> [output.dsa]"
|
|
let args: Vec<String> = std::env::args().collect();
|
|
if args.len() < 2 {
|
|
eprintln!("Usage: c_compiler <src.dsc> [output.dsa]");
|
|
return;
|
|
}
|
|
|
|
let input_file = &args[1];
|
|
let output_file = if args.len() > 2 {
|
|
&args[2]
|
|
} else {
|
|
"output.dsa"
|
|
};
|
|
|
|
{
|
|
let mut builder = Compiler::new(PathBuf::from(input_file));
|
|
builder.start();
|
|
let result = builder.output().unwrap();
|
|
|
|
std::fs::write(output_file, &result).expect("Failed to write output");
|
|
|
|
log(&format!(
|
|
"Compilation Successful ✅ \n\tSource: {}\n\tOutput: {}\n",
|
|
input_file, output_file,
|
|
));
|
|
}
|
|
}
|