Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support disable vendored protoc #81

Merged
merged 1 commit into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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