protoc-prebuilt
Protobuf compiler protoc pre-built binaries installer.
Installed binaries stored in OUT_DIR of the crate using the library.
Usage
Library export init function which takes version parameter. Version parameter should be a tag name from protobuf repository without v prefix, for example, "21.12" or "22.0-rc3" (see protobuf repository tags). Function return a tuple contains paths to protoc binary and include directory.
In next examples provided build.rs script content for different generators. For example, we have next simplified project structure with protobuf files:
src/
proto/
apple.proto
orange.proto
build.rs
With prost-build
use compile_protos;
use init;
use set_var;
With protobuf-codegen
use Codegen;
use init;
use set_var;
Comparison with analogues
- protoc-bin-vendored store pre-built protobuf compiler in dependencies crates, so you can't use latest or specify version of compiler, if it's not provide by crate author
- protobuf-src build protobuf compiler from sources, it not support
windowstarget and compilers versions hardcoded, so you can't use specify version