Add new testcases with cc65 support
Some checks failed
Cargo Build & Test / Rust project - latest (stable) (push) Failing after 8s
Some checks failed
Cargo Build & Test / Rust project - latest (stable) (push) Failing after 8s
This commit is contained in:
78
build.rs
78
build.rs
@@ -1,4 +1,31 @@
|
||||
use std::{io::Read, process::Stdio};
|
||||
use std::{
|
||||
fmt::Arguments,
|
||||
io::Read,
|
||||
process::{Command, Stdio},
|
||||
};
|
||||
|
||||
fn run(name: Arguments, cmd: &mut Command) {
|
||||
let mut proc = cmd
|
||||
.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 run {name}\n=== STDOUT ===\n{stdout}\n=== STDERR ===\n{stderr}");
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("cargo::rerun-if-changed=src/test_roms/");
|
||||
@@ -16,30 +43,31 @@ fn main() {
|
||||
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("./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}"
|
||||
);
|
||||
}
|
||||
run(
|
||||
format_args!("asm6f {file_name}"),
|
||||
Command::new("./asm6f")
|
||||
.arg(file.file_name())
|
||||
.arg(format!("{name}/{file_name}.nes")),
|
||||
);
|
||||
} else if let Some(file_name) = file_name.strip_suffix(".s") {
|
||||
run(
|
||||
format_args!("ca65 {file_name}"),
|
||||
Command::new("/home/matthew/cc65/bin/ca65")
|
||||
.arg("-I")
|
||||
.arg("common")
|
||||
.arg("-o")
|
||||
.arg(format!("{name}/{file_name}.o"))
|
||||
.arg(file.file_name()),
|
||||
);
|
||||
run(
|
||||
format_args!("ld65 {file_name}"),
|
||||
Command::new("/home/matthew/cc65/bin/ld65")
|
||||
.arg("-C")
|
||||
.arg("nes.cfg")
|
||||
.arg("-o")
|
||||
.arg(format!("{name}/{file_name}.nes"))
|
||||
.arg(format!("{name}/{file_name}.o"))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user