protoc-bin-vendored
Precompiled Google protoc binaries bundled in a Rust crate for hassle-free Protobuf code generation.
Repository Health
Technical Analysis
protoc-bin-vendored packages the official Google-built protoc (Protocol Buffers compiler) binaries directly inside a Rust crate, so build scripts can invoke protoc without requiring developers to download or install it separately. It selects the correct binary for the host platform and exposes its filesystem path through a simple API.
By vendoring platform-specific protoc executables plus the standard .proto include files, it removes an external system dependency from Protobuf-based Rust builds, making CI and cross-machine builds reproducible out of the box.
What You Get
- Precompiled, Google-built protoc binaries bundled for Linux, macOS, and Windows across multiple architectures
- A protoc_bin_path() function that returns the path to the correct binary for the current platform
- An include_path() function exposing the bundled standard protobuf .proto files
- A typed Error when no binary is available for the host OS/architecture
- Zero external system dependency for Protobuf builds, improving CI and cross-machine reproducibility
Common Use Cases
- Providing protoc to Protobuf codegen crates (such as protobuf-codegen or tonic-build) from a build script
- Making CI pipelines build Protobuf projects without installing protoc system-wide
- Ensuring a consistent, pinned protoc version across all developer machines
- Cross-platform Rust projects that generate code from .proto schemas at build time
Under The Hood
Architecture - The project is a Cargo workspace where a thin facade crate (protoc-bin-vendored) depends on a family of platform-specific crates (protoc-bin-vendored-linux-x86_64, -macos-aarch_64, -win32, and so on), each of which embeds the actual binary for one target. At runtime the facade inspects env::consts OS/arch, dispatches to the matching platform crate via an ArchCrate enum, and returns the extracted binary path or a descriptive Error.
Tech Stack - Pure Rust (edition 2021) with no third-party runtime dependencies; it relies only on std for path and environment handling. An arch-template crate and update-bin.sh script drive regeneration of the per-platform crates when new protoc releases are vendored.
Code Quality - The crate enforces #![deny(missing_docs)] and denies broken intra-doc links, and its public functions are documented with runnable doctests. The workspace structure keeps platform binaries isolated so consumers only pull what they need.
API Design - The API is deliberately minimal: two functions, protoc_bin_path() and include_path(), each returning a Result. That small surface makes it trivial to drop into a build.rs, with essentially no learning curve beyond wiring the returned path into your codegen invocation.