From b535df88d5e1045558c032b8f7f32f7379e42cce Mon Sep 17 00:00:00 2001 From: Noor Date: Tue, 8 Oct 2024 13:50:39 +0000 Subject: [PATCH] feature gated occlum library and tonic build config --- build.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/build.rs b/build.rs index 70e4853..ef14947 100644 --- a/build.rs +++ b/build.rs @@ -1,13 +1,17 @@ fn main() { - // TODO: make this conditional on occlum feature // TODO: should be conditional on the target platform (musl vs glibc) - println!("cargo:rustc-link-search=/opt/occlum/toolchains/dcap_lib/musl"); - // Cargo will automatically know it must look for `libocclum_dcap.a` - println!("cargo:rustc-link-lib=occlum_dcap"); - // TODO: make this conditional if compiling grpcs examples + #[cfg(feature = "occlum")] + { + println!("cargo:rustc-link-search=/opt/occlum/toolchains/dcap_lib/musl"); + println!("cargo:rustc-link-lib=occlum_dcap"); + } + + // Cargo will automatically know it must look for `libocclum_dcap.a` + + #[cfg(feature = "tonic")] tonic_build::configure() .build_server(true) - .compile(&["examples/echo.proto"], &["examples"]) + .compile_protos(&["examples/echo.proto"], &["examples"]) .unwrap_or_else(|e| panic!("Failed to compile protos {:?}", e)); }