Skip to content

Commit

Permalink
support disable vendored protoc (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiacai2050 authored Jun 25, 2023
1 parent f60b148 commit 4fdc664
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ceresdbproto"
version = "1.0.4"
version = "1.0.5"
authors = ["CeresDB Authors <ceresdbservice@gmail.com>"]
edition = "2021"
repository = "https://github.com/CeresDB/ceresdbproto"
Expand Down
12 changes: 10 additions & 2 deletions rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,18 @@ impl Builder {
}
}

const ENABLE_VENDOR_ENV: &str = "CERESDBPROTO_ENABLE_VENDORED";

fn main() -> Result<(), Box<dyn std::error::Error>> {
// Download the protoc and set the path for tonic_build.
let protoc_path = protoc_bin_vendored::protoc_bin_path().map_err(|e| Box::new(e))?;
std::env::set_var("PROTOC", protoc_path.as_os_str());

println!("cargo:rerun-if-env-changed={}", ENABLE_VENDOR_ENV);

let enable_vendor = std::env::var(ENABLE_VENDOR_ENV).unwrap_or("true".to_string());
if "true" == enable_vendor {
let protoc_path = protoc_bin_vendored::protoc_bin_path().map_err(|e| Box::new(e))?;
std::env::set_var("PROTOC", protoc_path.as_os_str());
}

// Build protos.
let out_dir = std::env::var("OUT_DIR").map_err(|e| Box::new(e))?;
Expand Down

0 comments on commit 4fdc664

Please sign in to comment.