summaryrefslogtreecommitdiff
path: root/bindings/rs-timeout/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bindings/rs-timeout/build.rs')
-rw-r--r--bindings/rs-timeout/build.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/bindings/rs-timeout/build.rs b/bindings/rs-timeout/build.rs
new file mode 100644
index 0000000..bdefe22
--- /dev/null
+++ b/bindings/rs-timeout/build.rs
@@ -0,0 +1,52 @@
+use std::env;
+use std::path::{Path, PathBuf};
+use std::process::Command;
+
+fn main() {
+ // Compile C source file
+ let output = Command::new("make")
+ // .arg("so") // 生成动态库
+ .arg("static") // 生成静态库
+ .current_dir("./timeout")
+ .output()
+ .expect("Failed to compile C source file");
+
+ if !output.status.success() {
+ panic!(
+ "Failed to compile C source file: {}",
+ String::from_utf8_lossy(&output.stderr)
+ );
+ }
+
+ // // Add shared library path to system library search path
+ // let output = Command::new("sh")
+ // .arg("-c")
+ // .arg("export LD_LIBRARY_PATH=/workspaces/rs-timeout/timeout:$LD_LIBRARY_PATH")
+ // .output()
+ // .expect("Failed to add shared library path to system library search path");
+
+ // if !output.status.success() {
+ // panic!(
+ // "Failed to add shared library path to system library search path: {}",
+ // String::from_utf8_lossy(&output.stderr)
+ // );
+ // }
+
+ // let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ // println!(
+ // "cargo:rustc-link-search=native={}",
+ // Path::new(&dir).join("timeout").display()
+ // );
+ // Link shared library
+ // let root = String::from(env::var_os("CARGO_MANIFEST_DIR").unwrap().to_str().unwrap());
+ // // 将 /lib 添加到链接搜索目录
+ // println!("cargo:rustc-link-search=native={}", format!("{}/timeout", &root));
+
+ // println!("cargo:rustc-link-lib=timeout");
+ // // println!("cargo:rustc-link-search=native=./timeout");
+ // println!("cargo:rerun-if-changed=./timeout");
+
+ // let dir = env::var("CARGO_MANIFEST_DIR").unwrap();
+ println!("cargo:rustc-link-search=native=./bindings/rs-timeout/timeout");
+ println!("cargo:rustc-link-lib=static=timeout");
+}