Initial commit

This commit is contained in:
2025-12-07 11:34:37 -06:00
commit d97a8559ec
17 changed files with 8387 additions and 0 deletions

45
build.rs Normal file
View File

@@ -0,0 +1,45 @@
use std::{io::Read, process::Stdio};
fn main() {
println!("cargo::rerun-if-changed=src/test_roms/");
println!("cargo::rerun-if-changed=build.rs");
let name = format!(
"{}/test-roms",
std::env::var("OUT_DIR").expect("Need OUT_DIR env var")
);
std::fs::create_dir_all(&name).expect("Failed to create rom output dir");
println!("cargo::rustc-env=ROM_DIR={name}");
for file in std::fs::read_dir("./src/test_roms").expect("Failed to read directory") {
let file = file.expect("test");
let file_name = file.file_name();
let file_name = file_name.to_str().unwrap();
if let Some(file_name) = file_name.strip_suffix(".asm") {
let mut proc = std::process::Command::new("/home/matthew/asm6f/asm6f")
.arg(file.file_name())
.arg(format!("{name}/{file_name}.nes"))
.current_dir("src/test_roms")
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
.expect("Failed to start process");
let rc = proc.wait();
if rc.is_err() || rc.is_ok_and(|s| !s.success()) {
let mut stdout = String::new();
proc.stdout
.unwrap()
.read_to_string(&mut stdout)
.expect("Failed to read stdout");
let mut stderr = String::new();
proc.stderr
.unwrap()
.read_to_string(&mut stderr)
.expect("Failed to read stderr");
panic!(
"Failed to compile {file_name}\n=== STDOUT ===\n{stdout}\n=== STDERR ===\n{stderr}"
);
}
}
}
}