atuin/crates/atuin-daemon/build.rs
Remo Senekowitsch 9fa223eaaf
chore(build): compile protobufs with protox (#2122)
* chore(build): compile protobufs with protox

protox is a pure-rust implementation of the protobuf compiler.
Therefore, it can be managed by cargo.

This removes the implicit dependency on protoc being available
in the environment for the build.

* fix(build): replace copypasta in build script

The paths passed to `compile` aren't actually used by the build.
`skip_protoc_run` prevents that.
That's why a clean build succeeds even with this mistake.

However, the paths are passed to a `cargo:rerun-if-changed` directive.
So this mistake would've caused a failed incremental build if the
protobuf definitions were changed.
2024-06-12 16:45:38 +01:00

18 lines
594 B
Rust

use std::{env, fs, path::PathBuf};
use protox::prost::Message;
fn main() -> std::io::Result<()> {
let file_descriptors = protox::compile(["history.proto"], ["./proto/"]).unwrap();
let file_descriptor_path = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR not set"))
.join("file_descriptor_set.bin");
fs::write(&file_descriptor_path, file_descriptors.encode_to_vec()).unwrap();
tonic_build::configure()
.build_server(true)
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.compile(&["history.proto"], &["."])
}