mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-08 15:41:15 +02:00
Every workflow that builds the Rust volume server first installed protoc from a package manager - twelve steps across apt, brew and choco. That is 37s per job on a good day, and this week archive.ubuntu.com stalled long enough for four jobs to burn their whole timeout without reaching a build. protoc-bin-vendored ships the compiler as a build-dependency, so it now arrives through the cargo registry the workflows already cache and there is nothing left to install. cargo build works on a machine with no protoc at all, which is worth as much locally as it is in CI. It also pins the version. The apt protoc on ubuntu-22.04 is 3.12, old enough to reject proto3 optional, which is why build.rs passes --experimental_allow_proto3_optional; the vendored one is 31.1. The flag stays, since it costs nothing and keeps a build against an older PROTOC working, and an explicit PROTOC still overrides the vendored binary for packagers who supply their own.
29 lines
1.2 KiB
Rust
29 lines
1.2 KiB
Rust
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
// Use the protoc that ships with protoc-bin-vendored rather than a system
|
|
// one, so the build needs no package manager and always sees the same
|
|
// version. An explicit PROTOC still wins, for packagers supplying their own.
|
|
if std::env::var_os("PROTOC").is_none() {
|
|
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path()?);
|
|
}
|
|
|
|
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
|
|
tonic_build::configure()
|
|
.build_server(true)
|
|
.build_client(true)
|
|
// filer.proto uses proto3 optional, which protoc rejects without this
|
|
// flag before 3.15. The vendored protoc is newer, but it still accepts
|
|
// the flag, so this keeps a build against an older PROTOC working.
|
|
.protoc_arg("--experimental_allow_proto3_optional")
|
|
.file_descriptor_set_path(out_dir.join("seaweed_descriptor.bin"))
|
|
.compile_protos(
|
|
&[
|
|
"proto/volume_server.proto",
|
|
"proto/master.proto",
|
|
"proto/remote.proto",
|
|
"../weed/pb/filer.proto",
|
|
],
|
|
&["proto/", "../weed/pb/"],
|
|
)?;
|
|
Ok(())
|
|
}
|