Repository navigation
Expand file tree
/
Copy pathbuild.rs
More file actions
54 lines (41 loc) · 1.83 KB
/
Copy pathbuild.rs
File metadata and controls
54 lines (41 loc) · 1.83 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
use std::env;
use std::fs;
use std::path::{PathBuf, Path};
fn main() {
// Build the RAPS project
build_wraps();
// Copy the ELF file to the OUT_DIR
copy_elf();
}
fn copy_elf() {
// Define the destination path (project root)
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
let source = "./succint-wraps/target/elf-compilation/riscv32im-succinct-zkvm-elf/release/ab-rotation-program";
let destination = Path::new(&out_dir).join("ab-rotation-program");
fs::copy(source, &destination).expect("Failed to copy binary");
let source = "./succint-wraps/target/elf-compilation/riscv32im-succinct-zkvm-elf/release/raps-compression-program";
let destination = Path::new(&out_dir).join("raps-compression-program");
fs::copy(source, &destination).expect("Failed to copy binary");
}
fn build_wraps() {
// Get the path to the nested directory relative to the root project
let nested_dir = PathBuf::from("succint-wraps");
// Get the current directory (where build.rs is located)
let current_dir = env::current_dir().expect("Failed to get current directory");
// Combine paths to get the full path to the nested directory
let full_nested_path = current_dir.join(&nested_dir);
// Print directory for debugging
println!("cargo:warning=Building in directory: {}", full_nested_path.display());
// Run cargo build in the nested directory
let status = std::process::Command::new("cargo")
.current_dir(&full_nested_path)
.arg("build")
.arg("--release")
.status()
.expect("Failed to execute cargo build");
if !status.success() {
panic!("Failed to build nested project");
}
// Tell cargo to rerun this build script if files in the nested directory change
println!("cargo:rerun-if-changed={}", nested_dir.display());
}