use std::{env, path::Path};
use assembly::{
    diagnostics::{IntoDiagnostic, Result},
    Assembler, Library, LibraryNamespace,
};
const ASM_DIR_PATH: &str = "asm";
const ASL_DIR_PATH: &str = "assets";
fn main() -> Result<()> {
            println!("cargo:rerun-if-changed=asm");
    println!("cargo:rerun-if-changed=../assembly/src");
    let manifest_dir = env!("CARGO_MANIFEST_DIR");
    let asm_dir = Path::new(manifest_dir).join(ASM_DIR_PATH);
    let assembler = Assembler::default().with_debug_mode(cfg!(feature = "with-debug-info"));
    let namespace = "std".parse::<LibraryNamespace>().expect("invalid base namespace");
    let stdlib = Library::from_dir(asm_dir, namespace, assembler)?;
        let build_dir = env::var("OUT_DIR").unwrap();
    let build_dir = Path::new(&build_dir);
    let output_file = build_dir
        .join(ASL_DIR_PATH)
        .join("std")
        .with_extension(Library::LIBRARY_EXTENSION);
    stdlib.write_to_file(output_file).into_diagnostic()?;
    Ok(())
}