From 8c0f9bb1a06c705eb16312dd8b23e402241894db Mon Sep 17 00:00:00 2001 From: Matisse Brard Date: Sat, 15 Jun 2024 19:09:42 +0200 Subject: [PATCH] fix: allow setting PROTOC environment variable --- kclvm/api/build.rs | 10 ++++++---- kclvm/third-party/prost-wkt/wkt-types/build.rs | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/kclvm/api/build.rs b/kclvm/api/build.rs index 617c1b9ae..7d1c39b77 100644 --- a/kclvm/api/build.rs +++ b/kclvm/api/build.rs @@ -5,10 +5,12 @@ use prost_wkt_build::{FileDescriptorSet, Message}; /// According to the file kclvm/spec/gpyrpc/gpyrpc.proto, automatically generate /// the corresponding rust source file to the directory src/model fn main() { - std::env::set_var( - "PROTOC", - protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(), - ); + if env::var("PROTOC").is_err() { + env::set_var( + "PROTOC", + protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(), + ); + } let out = PathBuf::from(env::var("OUT_DIR").unwrap()); let descriptor_file = out.join("kclvm_service_descriptor.bin"); diff --git a/kclvm/third-party/prost-wkt/wkt-types/build.rs b/kclvm/third-party/prost-wkt/wkt-types/build.rs index e49222d52..620c759ae 100644 --- a/kclvm/third-party/prost-wkt/wkt-types/build.rs +++ b/kclvm/third-party/prost-wkt/wkt-types/build.rs @@ -13,10 +13,12 @@ use regex::Regex; fn main() { //hack: set protoc_bin_vendored::protoc_bin_path() to PROTOC - std::env::set_var( - "PROTOC", - protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(), - ); + if env::var("PROTOC").is_err() { + env::set_var( + "PROTOC", + protoc_bin_vendored::protoc_bin_path().unwrap().as_os_str(), + ); + } let dir = PathBuf::from(env::var("OUT_DIR").unwrap()); process_prost_pbtime(&dir);