fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Only compile protobuf when binary feature is enabled
    #[cfg(feature = "binary")]
    {
        use std::env;
        use std::path::PathBuf;

        let out_dir = PathBuf::from(env::var("OUT_DIR")?);

        prost_build::Config::new()
            .out_dir(&out_dir)
            .type_attribute(".", "#[derive(serde::Serialize, serde::Deserialize)]")
            .compile_protos(&["proto/wasot.proto"], &["proto/"])?;

        println!("cargo:rerun-if-changed=proto/wasot.proto");
    }

    Ok(())
}
