use std::{
env,
fs::OpenOptions,
io::{Read, Write},
path::Path,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("cargo:rerun-if-changed=../../format/Flight.proto");
env::set_var("OUT_DIR", "src");
let path = Path::new("../../format/Flight.proto");
if path.exists() {
tonic_build::compile_protos("../../format/Flight.proto")?;
let mut file = OpenOptions::new()
.read(true)
.open("src/arrow.flight.protocol.rs")?;
let mut buffer = String::new();
file.read_to_string(&mut buffer)?;
let mut file = OpenOptions::new()
.write(true)
.truncate(true)
.open("src/arrow.flight.protocol.rs")?;
file.write_all("// This file was automatically generated through the build.rs script, and should not be edited.\n\n".as_bytes())?;
file.write_all(buffer.as_bytes())?;
}
Ok(())
}