palladium-runtime 0.5.0

High-performance multi-core actor runtime for Palladium
Documentation
fn main() {
    println!("cargo:rerun-if-changed=src/core.zig");

    let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
    let out_dir = std::env::var("OUT_DIR").unwrap();

    // Attempt to compile core.zig with the Zig toolchain.
    let status = std::process::Command::new("zig")
        .args([
            "build-lib",
            "src/core.zig",
            "-O",
            "ReleaseFast",
            "--name",
            "pdcore",
            &format!("-femit-bin={}/libpdcore.a", out_dir),
            "-lc",
        ])
        .current_dir(&manifest_dir)
        .status();

    match status {
        Ok(s) if s.success() => {
            // Link freshly compiled library.
            println!("cargo:rustc-link-search=native={}", out_dir);
            println!("cargo:rustc-link-lib=static=pdcore");
        }
        _ => {
            // Zig not available; fall back to the pre-compiled library
            // checked into the source tree.  Note: if core.zig was changed,
            // the pre-compiled library may lack new exports until rebuilt.
            println!(
                "cargo:warning=Zig compilation failed; using pre-compiled libpdcore.a from source tree."
            );
            println!("cargo:rustc-link-search=native={}", manifest_dir);
            println!("cargo:rustc-link-lib=static=pdcore");
        }
    }
}