/ build.rs
build.rs
1 fn main() -> Result<(), std::io::Error> { 2 // Link to libwaku only when the "waku" feature is enabled. 3 #[cfg(feature = "waku")] 4 { 5 let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap(); 6 let libs_dir = std::path::Path::new(&manifest_dir).join("libs"); 7 println!("cargo:rustc-link-search=native={}", libs_dir.display()); 8 9 let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap_or_default(); 10 match target_os.as_str() { 11 "macos" | "linux" => { 12 println!("cargo:rustc-link-lib=dylib=waku"); 13 println!("cargo:rustc-link-arg=-Wl,-rpath,{}", libs_dir.display()); 14 } 15 other => { 16 panic!("Unsupported target OS: {other}. Only macOS and Linux are supported."); 17 } 18 } 19 } 20 21 let mut config = prost_build::Config::new(); 22 23 config.extern_path( 24 ".consensus.v1.Proposal", 25 "::hashgraph_like_consensus::protos::consensus::v1::Proposal", 26 ); 27 config.extern_path( 28 ".consensus.v1.Vote", 29 "::hashgraph_like_consensus::protos::consensus::v1::Vote", 30 ); 31 32 config.compile_protos( 33 &[ 34 "src/protos/messages/v1/application.proto", 35 "src/protos/messages/v1/welcome.proto", 36 ], 37 &["src/protos/"], 38 )?; 39 Ok(()) 40 }