summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'build.rs')
-rw-r--r--build.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/build.rs b/build.rs
new file mode 100644
index 0000000..83fcc3c
--- /dev/null
+++ b/build.rs
@@ -0,0 +1,39 @@
+#[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();
+}