#[cfg(feature = "guile")] use std::env; #[cfg(feature = "guile")] use std::process::Command; // cargo build has to be run twice for some reason. fn build_guile() { const LIBGUILE_INCLUDE_PATH: &str = "/usr/include/guile/3.0/"; const GUILEDEFS_SRC: &str = "src/guile/guiledefs.c"; const GUILEDEFS_TARGET_OBJ: &str = "guiledefs.o"; const GUILEDEFS_TARGET_ARCHIVE: &str = "libguiledefs.a"; let out_dir = env::var("OUT_DIR").unwrap(); Command::new("gcc") .arg("-c") .arg("-I") .arg(LIBGUILE_INCLUDE_PATH) .arg("-lguile-3.0") .arg(GUILEDEFS_SRC) .arg("-o") .arg(format!("{}/{}", out_dir, GUILEDEFS_TARGET_OBJ)) .spawn() .expect("Error compiling guiledefs.c"); Command::new("ar") .arg("r") .arg(format!("{}/{}", out_dir, GUILEDEFS_TARGET_ARCHIVE)) .arg(format!("{}/{}", out_dir, GUILEDEFS_TARGET_OBJ)) .spawn() .expect("Error creating libguiledefs.a"); println!("cargo:rustc-link-search=native={}", out_dir); } fn main() { #[cfg(feature = "guile")] build_guile(); }