cf672beb79
Signed-off-by: Jakub Doka <jakub.doka2@gmail.com>
32 lines
1.1 KiB
Rust
32 lines
1.1 KiB
Rust
#[cfg(feature = "std")]
|
|
fn main() {
|
|
use std::io::Write;
|
|
|
|
fn run(out: &mut Vec<u8>, warnings: &mut String) -> std::io::Result<()> {
|
|
let args = std::env::args().collect::<Vec<_>>();
|
|
let args = args.iter().map(String::as_str).collect::<Vec<_>>();
|
|
let resolvers = &[("ableos", hblang::ABLEOS_PATH_RESOLVER)];
|
|
let opts = hblang::Options::from_args(&args, out, resolvers)?;
|
|
let file = args.iter().filter(|a| !a.starts_with('-')).nth(1).copied().unwrap_or("main.hb");
|
|
|
|
hblang::run_compiler(file, opts, out, warnings)
|
|
}
|
|
|
|
log::set_logger(&hblang::fs::Logger).unwrap();
|
|
log::set_max_level(log::LevelFilter::Error);
|
|
|
|
let mut out = Vec::new();
|
|
let mut warnings = String::new();
|
|
match run(&mut out, &mut warnings) {
|
|
Ok(_) => {
|
|
std::io::stderr().write_all(warnings.as_bytes()).unwrap();
|
|
std::io::stdout().write_all(&out).unwrap()
|
|
}
|
|
Err(_) => {
|
|
std::io::stderr().write_all(warnings.as_bytes()).unwrap();
|
|
std::io::stderr().write_all(&out).unwrap();
|
|
std::process::exit(1);
|
|
}
|
|
}
|
|
}
|