Skip to content

Conversation

@fmorency
Copy link
Contributor

@fmorency fmorency commented Sep 9, 2025

This pull request adds support for building the protoc binary from source as an optional feature, improving build portability and flexibility. The main changes include introducing the protobuf-src dependency and a new build-protoc feature, along with conditional logic in build.rs to use the built protoc binary when the feature is enabled.

Dependency and feature additions:

  • Added protobuf-src as an optional dependency in Cargo.toml to allow building protoc from source.
  • Introduced the build-protoc feature in Cargo.toml, which enables building protoc from source rather than relying on a system installation.

Build script enhancements:

  • Updated build.rs to check for the build-protoc feature and set the PROTOC environment variable to the path of the built protoc binary if enabled, improving build flexibility across different environments.

@fmorency fmorency requested a review from Copilot September 9, 2025 18:32
@fmorency fmorency self-assigned this Sep 9, 2025
@fmorency fmorency merged commit 95ade09 into manifest-network:main Sep 9, 2025
@fmorency fmorency deleted the protoc branch September 9, 2025 18:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for building the protoc binary from source as an optional feature, enhancing build portability by reducing dependency on system-installed protoc.

  • Introduces protobuf-src as an optional dependency with a new build-protoc feature
  • Updates build script to conditionally use built protoc binary when feature is enabled
  • Adds build-time logging to indicate when the feature is active

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
Cargo.toml Adds optional protobuf-src dependency and build-protoc feature
build.rs Implements conditional logic to use built protoc when feature is enabled

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.
#[cfg(feature = "build-protoc")]
{
println!("build-protoc feature is enabled");
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant