Skip to content

Commit 61ad52e

Browse files
committed
link to the static lib during build
1 parent aeba6b0 commit 61ad52e

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

build.rs

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,31 @@
1+
use std::env;
2+
use std::path::Path;
3+
use std::process::Command;
4+
15
fn main() {
2-
/* println!("cargo:rustc-link-search=native=./");
3-
println!("cargo:rustc-link-lib=k"); */
6+
let out_dir = env::var("OUT_DIR").unwrap();
7+
let cbqn_dir = Path::new(&out_dir).join("CBQN");
8+
9+
if !cbqn_dir.exists() {
10+
Command::new("git")
11+
.args([
12+
"clone",
13+
"https://github.com/dzaima/CBQN.git",
14+
cbqn_dir.to_str().unwrap(),
15+
])
16+
.status()
17+
.expect("cargo:warning=Failed to clone CBQN repository");
18+
}
19+
20+
Command::new("make")
21+
.current_dir(&cbqn_dir)
22+
.arg("static-lib")
23+
.arg("FFI=0")
24+
.status()
25+
.expect("cargo:warning=Failed to build CBQN static library");
26+
27+
println!("cargo:rustc-link-search=native={}", cbqn_dir.display());
28+
println!("cargo:rustc-link-lib=static=cbqn");
29+
30+
println!("cargo:rerun-if-changed={}", cbqn_dir.join("src").display());
431
}

0 commit comments

Comments
 (0)