11use risc0_binfmt:: compute_image_id;
2- use risc0_build:: { embed_method_metadata_with_options, DockerOptions , GuestOptions } ;
3- use std:: {
4- collections:: HashMap ,
5- env,
6- fs:: File ,
7- io:: Write ,
8- path:: { Path , PathBuf } ,
9- str:: FromStr ,
10- } ;
2+ use risc0_build:: { embed_method_metadata_with_options, DockerOptionsBuilder , GuestOptionsBuilder } ;
3+ use std:: { collections:: HashMap , env, fs:: File , io:: Write } ;
114
125fn main ( ) {
136 println ! ( "cargo:rerun-if-env-changed=ZKDCAP_RISC0_BUILD" ) ;
@@ -23,24 +16,23 @@ fn main() {
2316
2417 // Builds can be made deterministic, and thereby reproducible, by using Docker to build the
2518 // guest.
26- let use_docker = Some ( DockerOptions {
27- root_dir : Some ( "../../" . into ( ) ) ,
28- } ) ;
19+ let use_docker = DockerOptionsBuilder :: default ( )
20+ . root_dir ( "../../" )
21+ . build ( )
22+ . unwrap ( ) ;
23+
24+ let guest_options = GuestOptionsBuilder :: default ( )
25+ . use_docker ( use_docker)
26+ . build ( )
27+ . unwrap ( ) ;
2928
3029 // Generate Rust source files for the methods crate.
31- let guests = embed_method_metadata_with_options ( HashMap :: from ( [ (
32- "guests" ,
33- GuestOptions {
34- features : Vec :: new ( ) ,
35- use_docker,
36- } ,
37- ) ] ) ) ;
30+ let guests = embed_method_metadata_with_options ( HashMap :: from ( [ ( "guests" , guest_options) ] ) ) ;
3831
3932 if guests. len ( ) != 1 {
4033 panic ! ( "expected exactly one guest, found {}" , guests. len( ) ) ;
4134 } ;
42- let elf_path = get_correct_elf_path ( & PathBuf :: from_str ( & guests[ 0 ] . path ) . unwrap ( ) ) ;
43- let elf_value = std:: fs:: read ( & elf_path) . unwrap ( ) ;
35+ let elf_value = std:: fs:: read ( guests[ 0 ] . path . to_string ( ) ) . unwrap ( ) ;
4436 let image_id = compute_image_id ( & elf_value) . unwrap ( ) ;
4537 let image_id_words = image_id. as_words ( ) . to_vec ( ) ;
4638 let image_id_str = image_id. to_string ( ) ;
@@ -60,28 +52,3 @@ pub const DCAP_QUOTE_VERIFIER_ELF: &[u8] = include_bytes!("../artifacts/dcap-quo
6052 )
6153 . unwrap ( ) ;
6254}
63-
64- fn get_correct_elf_path ( elf_path : & Path ) -> String {
65- elf_path
66- . parent ( )
67- . unwrap ( )
68- . parent ( )
69- . unwrap ( )
70- . parent ( )
71- . unwrap ( )
72- . parent ( )
73- . unwrap ( )
74- . parent ( )
75- . unwrap ( )
76- . parent ( )
77- . unwrap ( )
78- . parent ( )
79- . unwrap ( )
80- . parent ( )
81- . unwrap ( )
82- . join ( "target/riscv-guest/riscv32im-risc0-zkvm-elf/docker/guests/dcap_quote_verifier" )
83- . as_path ( )
84- . to_str ( )
85- . unwrap ( )
86- . to_string ( )
87- }
0 commit comments