use std::env;
use std::io::Result;
fn main() -> Result<()> {
println!("cargo:rerun-if-changed=protos");
#[cfg(feature = "protoc")]
std::env::set_var("PROTOC", protobuf_src::protoc());
let mut prost_build = prost_build::Config::new();
prost_build.protoc_arg("--experimental_allow_proto3_optional");
prost_build.compile_protos(&["./protos/index.proto"], &["./protos"])?;
let rust_toolchain = env::var("RUSTUP_TOOLCHAIN")
.or_else(|e| match e {
env::VarError::NotPresent => Ok("stable".into()),
e => Err(e),
})
.unwrap();
if rust_toolchain.starts_with("nightly") {
println!("cargo:rustc-cfg=feature=\"nightly\"");
}
Ok(())
}