mumu-sys 0.1.0

System calls and tools plugin for the Lava language
Documentation
use std::env;
use std::fs;
use std::os::unix::fs::symlink;
use std::path::PathBuf;

fn main() {
    let out_dir = env::var("OUT_DIR").unwrap();
    let target_dir = PathBuf::from(out_dir)
        .ancestors()
        .nth(3)
        .unwrap()
        .to_path_buf();

    let lib_name = "libmumusys.so";
    let link_name = "libsys.so";
    let lib_path = target_dir.join(lib_name);
    let link_path = target_dir.join(link_name);

    // Remove old symlink if exists
    let _ = fs::remove_file(&link_path);
    // Create new symlink
    #[cfg(unix)]
    {
        let _ = symlink(&lib_path, &link_path);
        println!("cargo:warning=Created symlink \"{}\" -> \"{}\"", link_name, lib_name);
    }
    #[cfg(windows)]
    {
        // No-op on Windows
    }
    #[cfg(all(not(windows), not(target_os = "macos")))]
    {
        // Handle other OSs if needed
    }
}