-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathbuild.rs
More file actions
40 lines (31 loc) · 1.07 KB
/
build.rs
File metadata and controls
40 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use std::{env, path::PathBuf, process::Command};
const GO_SRC: &str = "./go_verifiers_lib/verifier.go";
const GO_OUT: &str = "libverifier.a";
const GO_LIB: &str = "verifier";
fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
// Fix the missing dependency issue
let mut get_cmd = Command::new("go");
get_cmd
.arg("get")
.arg("github.com/iden3/go-rapidsnark/verifier@v0.0.5");
let _ = get_cmd.output(); // Run but don't fail if it has issues
// Build library
let mut go_build = Command::new("go");
go_build
.arg("build")
.arg("-buildmode=c-archive")
.arg("-o")
.arg(out_dir.join(GO_OUT))
.arg(GO_SRC);
go_build.status().expect("Go build failed");
println!("cargo:rerun-if-changed={}", GO_SRC);
println!(
"cargo:rustc-link-search=native={}",
out_dir.to_str().unwrap()
);
if cfg!(target_os = "linux") {
println!("cargo:rustc-link-arg=-Wl,--allow-multiple-definition");
}
println!("cargo:rustc-link-lib=static={}", GO_LIB);
}