Skip to content

Commit

Permalink
link to the static lib during build
Browse files Browse the repository at this point in the history
  • Loading branch information
x86y committed Jul 20, 2024
1 parent aeba6b0 commit 61ad52e
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
use std::env;
use std::path::Path;
use std::process::Command;

fn main() {
/* println!("cargo:rustc-link-search=native=./");
println!("cargo:rustc-link-lib=k"); */
let out_dir = env::var("OUT_DIR").unwrap();
let cbqn_dir = Path::new(&out_dir).join("CBQN");

if !cbqn_dir.exists() {
Command::new("git")
.args([
"clone",
"https://github.com/dzaima/CBQN.git",
cbqn_dir.to_str().unwrap(),
])
.status()
.expect("cargo:warning=Failed to clone CBQN repository");
}

Command::new("make")
.current_dir(&cbqn_dir)
.arg("static-lib")
.arg("FFI=0")
.status()
.expect("cargo:warning=Failed to build CBQN static library");

println!("cargo:rustc-link-search=native={}", cbqn_dir.display());
println!("cargo:rustc-link-lib=static=cbqn");

println!("cargo:rerun-if-changed={}", cbqn_dir.join("src").display());
}

0 comments on commit 61ad52e

Please sign in to comment.