fn main() {
// `#[cfg]` in `build.rs` evaluates against the host (the machine running
// the build script), not the Cargo target being built. To gate behaviour
// on the target, inspect the `TARGET` env var that Cargo sets for us.
// The C wrappers contain 6502 inline assembly that only `mos-c64-clang`
// can compile, so we skip cc entirely on any other target (e.g. when
// running `cargo test` against the host triple).
let target = std::env::var("TARGET").expect("cargo always sets TARGET");
if target == "mos-c64-none" {
build_c();
}
}
fn build_c() {
cc::Build::new()
.compiler("mos-c64-clang")
.file("src/pac/basic.c")
.file("src/pac/irq.c")
.file("src/pac/kernal.c")
.file("src/pac/register.c")
.compile("asm");
println!("cargo:rerun-if-changed=src/pac/basic.c");
println!("cargo:rerun-if-changed=src/pac/irq.c");
println!("cargo:rerun-if-changed=src/pac/kernal.c");
println!("cargo:rerun-if-changed=src/pac/register.c");
}