Skip to content
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
41 changes: 41 additions & 0 deletions Cargo.lock

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

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ heck = "0.5.0"
prost = "0.14.1"
prost-build = "0.14.1"
prost-types = "0.14.1"
protobuf-src = { version = "2.1.1", optional = true }


[features]
default = []
default = []
build-protoc = ["protobuf-src"] # Build `protoc` from source instead of relying on a system installation
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ const PROTOS: &[&str] = &[
];

fn main() -> Result<()> {
#[cfg(feature = "build-protoc")]
{
println!("build-protoc feature is enabled");
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debug print statements should use cargo:warning= prefix for build script output to properly integrate with Cargo's output formatting, or be removed entirely for production builds.

Suggested change
println!("build-protoc feature is enabled");
println!("cargo:warning=build-protoc feature is enabled");

Copilot uses AI. Check for mistakes.
env::set_var("PROTOC", protobuf_src::protoc());
Copy link

Copilot AI Sep 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing error handling for protobuf_src::protoc(). If the protoc build fails, this will panic at runtime. Consider wrapping in a Result and providing a meaningful error message.

Suggested change
env::set_var("PROTOC", protobuf_src::protoc());
let protoc_path = protobuf_src::protoc().map_err(|e| {
std::io::Error::new(
std::io::ErrorKind::Other,
format!("Failed to build protoc: {}", e),
)
})?;
env::set_var("PROTOC", protoc_path);

Copilot uses AI. Check for mistakes.
}
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR not set"));
println!("cargo:rerun-if-changed=proto");

Expand Down