summaryrefslogtreecommitdiff
path: root/build.rs
diff options
context:
space:
mode:
authorQrius <[email protected]>2024-12-06 14:23:32 +0100
committerQrius <[email protected]>2024-12-06 14:23:41 +0100
commit1b59010b7da3b86aea6eb929d7efe37bdf735cd6 (patch)
tree568406b02dd280c005a54622b22a025776dcca9a /build.rs
parent42ec0c6469238b60bfd5f5c0baa085ec0c6ec148 (diff)
downloadskaldpress-1b59010b7da3b86aea6eb929d7efe37bdf735cd6.tar.gz
skaldpress-1b59010b7da3b86aea6eb929d7efe37bdf735cd6.zip
Add some basic bindings for Guile-3.0
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();
+}