//! Build script for compiling Protocol Buffer definitions

fn main() -> Result<(), Box<dyn std::error::Error>> {
  // Compile proto files if they exist
  let proto_files = ["proto/user.proto"];

  for proto in &proto_files {
    if std::path::Path::new(proto).exists() {
      println!("cargo:rerun-if-changed={}", proto);
    }
  }

  // Only compile if proto directory exists
  if std::path::Path::new("proto").exists() {
    prost_build::compile_protos(&proto_files, &["proto/"])?;
  }

  Ok(())
}
