process-mumu 0.1.2

Proces tools plugin for the Mumu ecosphere
Documentation
// process/build.rs
use std::env;
use std::fs;
use std::path::PathBuf;

fn main() {
    // Only on Unix-like OS, make a symlink for compatibility
    #[cfg(all(not(windows), not(target_os = "macos")))]
    {
        let out_dir = env::var("OUT_DIR").unwrap();
        let target = PathBuf::from(&out_dir)
            .ancestors()
            .nth(3) // target/{debug,release}/deps/../..
            .unwrap()
            .to_path_buf();
        let so = target.join("libmumuprocess.so");
        let symlink = target.join("libprocess.so");
        if so.exists() {
            // Remove the old symlink if it exists
            let _ = fs::remove_file(&symlink);
            if std::os::unix::fs::symlink(&so, &symlink).is_ok() {
                println!("cargo:warning=process@0.1.0: Created symlink \"libprocess.so\" -> \"libmumuprocess.so\"");
            }
        }
    }

    // On macOS, you might want to do something similar with dylibs
    #[cfg(target_os = "macos")]
    {
        let out_dir = env::var("OUT_DIR").unwrap();
        let target = PathBuf::from(&out_dir)
            .ancestors()
            .nth(3)
            .unwrap()
            .to_path_buf();
        let dylib = target.join("libmumuprocess.dylib");
        let symlink = target.join("libprocess.dylib");
        if dylib.exists() {
            let _ = fs::remove_file(&symlink);
            if std::os::unix::fs::symlink(&dylib, &symlink).is_ok() {
                println!("cargo:warning=process@0.1.0: Created symlink \"libprocess.dylib\" -> \"libmumuprocess.dylib\"");
            }
        }
    }
}