-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathbuild.rs
42 lines (35 loc) · 1.36 KB
/
build.rs
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
41
42
use std::{env, fs, path::Path, process::Command};
fn main() {
if cfg!(feature = "build-witness") {
let witness_cpp = env::var("WITNESS_CPP").unwrap();
let circuit_file = Path::new(&witness_cpp);
let circuit_name = circuit_file.file_stem().unwrap().to_str().unwrap();
let status = Command::new("circom")
.args([
fs::canonicalize(circuit_file).unwrap().to_str().unwrap(),
"--c",
])
.status()
.unwrap();
assert!(status.success());
let cpp = Path::new("./")
.join(circuit_name.to_owned() + "_cpp")
.join(circuit_name.to_owned() + ".cpp");
println!("cargo:warning=\"{}\"", cpp.to_str().unwrap());
let status = Command::new("./script/replace.sh")
.arg(cpp.to_str().unwrap())
.status()
.unwrap();
assert!(status.success());
cxx_build::bridge("src/generate.rs")
.file("src/circuit.cc")
.flag_if_supported("-std=c++14")
.flag_if_supported("-w")
.flag_if_supported("-d")
.flag_if_supported("-g")
.compile("witness");
println!("cargo:rerun-if-changed=src/main.rs");
println!("cargo:rerun-if-changed=src/circuit.cc");
println!("cargo:rerun-if-changed=include/circuit.h");
}
}