From e216416e2144b03c643c11cc37706dbf17c335a8 Mon Sep 17 00:00:00 2001 From: lbl <1791778603@qq.com> Date: Sat, 22 Aug 2026 23:16:41 +0800 Subject: [PATCH] fix(build): fall back to system protoc --- vnt-core/build.rs | 14 ++++++++++---- vnt-ipc/build.rs | 15 +++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/vnt-core/build.rs b/vnt-core/build.rs index c884b20..9b36431 100644 --- a/vnt-core/build.rs +++ b/vnt-core/build.rs @@ -1,10 +1,16 @@ fn main() { - let protoc_path = - protoc_bin_vendored::protoc_bin_path().expect("failed to find vendored protoc"); - let mut config = prost_build::Config::new(); - config.protoc_executable(protoc_path); + match protoc_bin_vendored::protoc_bin_path() { + Ok(protoc_path) => { + config.protoc_executable(protoc_path); + } + Err(error) => { + println!( + "cargo:warning=vendored protoc unavailable ({error:?}); falling back to protoc from PATH" + ); + } + } config.protoc_arg("--experimental_allow_proto3_optional"); diff --git a/vnt-ipc/build.rs b/vnt-ipc/build.rs index 9e91283..c3ccfd8 100644 --- a/vnt-ipc/build.rs +++ b/vnt-ipc/build.rs @@ -1,10 +1,17 @@ fn main() { - let protoc_path = - protoc_bin_vendored::protoc_bin_path().expect("failed to find vendored protoc"); - let mut config = prost_build::Config::new(); - config.protoc_executable(protoc_path); + match protoc_bin_vendored::protoc_bin_path() { + Ok(protoc_path) => { + config.protoc_executable(protoc_path); + } + Err(error) => { + println!( + "cargo:warning=vendored protoc unavailable ({error:?}); falling back to protoc from PATH" + ); + } + } + config.protoc_arg("--experimental_allow_proto3_optional"); config .compile_protos(&["proto/local_ipc.proto"], &["proto"])