use rustc_version::{version_meta, Channel};
fn main() {
println!("cargo::rustc-check-cfg=cfg(NIGHTLY_CHANNEL)");
if let Channel::Nightly = version_meta().unwrap().channel {
println!("cargo:rustc-cfg=NIGHTLY_CHANNEL");
}
#[cfg(feature = "declarative-plans")]
compile_proto_definitions();
}
#[cfg(feature = "declarative-plans")]
fn compile_proto_definitions() {
let proto_dir = "proto";
let proto_files = [
"schema.proto",
"expressions.proto",
"plan.proto",
"operation.proto",
];
for file in &proto_files {
println!("cargo:rerun-if-changed={proto_dir}/{file}");
}
let files: Vec<String> = proto_files
.iter()
.map(|f| format!("{proto_dir}/{f}"))
.collect();
#[cfg(feature = "vendored-protoc")]
set_vendored_protoc();
prost_build::Config::new()
.disable_comments(["."])
.compile_protos(&files, &[proto_dir])
.expect("failed to compile .proto files");
}
#[cfg(all(feature = "declarative-plans", feature = "vendored-protoc"))]
fn set_vendored_protoc() {
if std::env::var_os("PROTOC").is_none() {
let protoc = protoc_bin_vendored::protoc_bin_path().expect("vendored protoc binary");
std::env::set_var("PROTOC", protoc);
}
}