use std::{ borrow::Borrow, env, ffi::OsStr, fs, path::{Path, PathBuf}, process::Command, }; fn main() { let we_created = if !Path::new("r8brain/LICENSE").exists() { eprintln!("Setting up submodules"); run_command_or_fail(".", "git", &["clone", "https://github.com/avaneev/r8brain-free-src.git", "r8brain"]); run_command_or_fail("r8brain", "git", &["checkout", "234e71462f781032c078e8f197cd427ec3c2dfb9"]); true } else { false }; if !Path::new("r8brain/LICENSE").exists() { panic!("Submodules not found"); } let mut dst = cmake::Config::new(".").build_target("r8brain").build(); println!("cargo:rustc-link-search=native={}", dst.display()); dst.push("build"); println!("cargo:rustc-link-search=native={}", dst.display()); dst.push(env::var("PROFILE").expect("Profile must be specified")); println!("cargo:rustc-link-search=native={}", dst.display()); println!("cargo:rustc-link-lib=static=r8brain"); let target = env::var("TARGET").unwrap(); if target.contains("apple") { println!("cargo:rustc-link-lib=dylib=c++"); } else if target.contains("linux") { println!("cargo:rustc-link-lib=dylib=stdc++"); } if we_created { fs::remove_dir_all("r8brain").expect("Failed to remove r8brain"); } } // thank you rdkafka-sys for this code fn run_command_or_fail
(dir: &str, cmd: P, args: &[S])
where P: AsRef