-
Notifications
You must be signed in to change notification settings - Fork 396
Expand file tree
/
Copy pathbuild.rs
More file actions
54 lines (49 loc) · 2.3 KB
/
build.rs
File metadata and controls
54 lines (49 loc) · 2.3 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 risc0_build::{DockerOptionsBuilder, GuestOptionsBuilder};
use std::collections::HashMap;
use std::path::PathBuf;
// Reference: https://docs.succinct.xyz/docs/sp1/writing-programs/compiling#advanced-build-options-1
fn main() {
// This allows us to skip the guest build in CI or local environments where it's not needed (reducing the build time)
// Note: To use this flag, the aggregation programs should be already compiled, otherwise the compilation will be done anyway.
if std::env::var("SKIP_AGG_PROGRAMS_BUILD")
.map(|v| v == "1")
.unwrap_or(false)
{
let out_dir = std::env::var("OUT_DIR").unwrap();
let methods_path = PathBuf::from(out_dir).join("methods.rs");
if methods_path.exists() {
println!("cargo:warning=SKIP_AGG_PROGRAMS_BUILD=1: methods.rs already exists, skipping aggregation programs build");
return;
} else {
println!(
"cargo:warning=SKIP_AGG_PROGRAMS_BUILD=1 set, but {path} does not exist, running full build",
path = methods_path.display()
);
}
}
sp1_build::build_program_with_args("./aggregation_programs/sp1", {
sp1_build::BuildArgs {
output_directory: Some("./aggregation_programs/sp1/elf".to_string()),
binaries: vec![
"sp1_user_proofs_aggregator_program".into(),
"sp1_chunk_aggregator_program".into(),
],
// We use Docker to generate a reproducible ELF that will be identical across all platforms
// (https://docs.succinct.xyz/docs/sp1/writing-programs/compiling#production-builds)
docker: true,
..Default::default()
}
});
// With this containerized build process, we ensure that all builds of the guest code,
// regardless of the machine or local environment, will produce the same ImageID
let docker_options = DockerOptionsBuilder::default().build().unwrap();
// Reference: https://github.com/risc0/risc0/blob/main/risc0/build/src/config.rs#L73-L90
let guest_options = GuestOptionsBuilder::default()
.use_docker(docker_options)
.build()
.unwrap();
risc0_build::embed_methods_with_options(HashMap::from([(
"risc0_aggregation_program",
guest_options,
)]));
}