blob: ad4bc3c804e3e700a7a3e7f444c4b7f64979c7be (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use std::process::Command;
use std::{env, fs, path::PathBuf};
use protox::Compiler;
use protox::prost::Message;
fn main() -> Result<(), std::io::Error> {
{
let output = Command::new("git").args(["rev-parse", "HEAD"]).output();
let sha = match output {
Ok(sha) => String::from_utf8(sha.stdout).unwrap(),
Err(_) => String::from("NO_GIT"),
};
println!("cargo:rustc-env=GIT_HASH={sha}");
}
{
let proto_paths = [
"proto/history.proto",
"proto/search.proto",
"proto/control.proto",
"proto/semantic.proto",
];
let proto_include_dirs = ["proto"];
let file_descriptor_set = Compiler::new(proto_include_dirs)
.map_err(std::io::Error::other)?
.include_source_info(true)
.include_imports(true)
.open_files(proto_paths)
.map_err(std::io::Error::other)?
.file_descriptor_set();
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_descriptor_set.encode_to_vec()).unwrap();
tonic_prost_build::configure()
.build_server(true)
.file_descriptor_set_path(&file_descriptor_path)
.skip_protoc_run()
.compile_protos(&proto_paths, &proto_include_dirs)?;
}
Ok(())
}
|