assistant_daemon 0.1.0

Daemon program for providing many features.
use std::{env, path::Path};

fn main() {
    let dir = env::var("CARGO_MANIFEST_DIR").unwrap();

    std::process::Command::new("cronus_cli")
        .arg(&dir)
        .output()
        .expect("failed to generate API");

    #[cfg(target_os = "macos")]
    {
        let clamshell_dir = "lib/clamshell";

        // Run the "build.sh" script in the "lib/clamshell" directory
        let output = std::process::Command::new("sh")
            .arg("-c")
            .arg(format!("cd {} && ./build.sh", clamshell_dir))
            .output()
            .expect("Failed to execute build.sh");

        // Check if the script ran successfully
        if !output.status.success() {
            // Print the error if the script failed
            eprintln!(
                "Error running build.sh: {}",
                String::from_utf8_lossy(&output.stderr)
            );
            // Exit the build script with an error
            std::process::exit(1);
        }

        let lib_path: std::path::PathBuf = Path::new(&dir).join("lib/clamshell/build");
        println!("cargo:rustc-link-lib=framework=IOKit");
        println!("cargo:rustc-link-lib=framework=Foundation");
        println!("cargo:rustc-link-lib=static=StaticClamShell");
        println!("cargo:rustc-link-search=native={}", lib_path.display());
        println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_path.display());
    }
}