mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-09-25 17:34:28 +00:00
34 lines
1.4 KiB
Rust
34 lines
1.4 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() {
|
|
// SAFETY: a build script's main runs single-threaded before anything
|
|
// else in this process, so no other thread can be reading the
|
|
// environment concurrently.
|
|
unsafe {
|
|
std::env::set_var("PROTOC", protoc_bin_vendored::protoc_bin_path()?);
|
|
}
|
|
}
|
|
|
|
let out_dir = std::path::PathBuf::from(std::env::var("OUT_DIR")?);
|
|
tonic_prost_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(())
|
|
}
|