fn main() -> Result<(), Box<dyn std::error::Error>> {
    let proto_files = &[
        "proto/OpenApiCommonMessages.proto",
        "proto/OpenApiCommonModelMessages.proto",
        "proto/OpenApiMessages.proto",
        "proto/OpenApiModelMessages.proto",
    ];

    let includes = &["proto/"];

    let mut config = prost_build::Config::new();
    config.protoc_arg("--experimental_allow_proto3_optional");

    config.compile_protos(proto_files, includes)?;

    // Re-run if any proto file changes
    for proto in proto_files {
        println!("cargo:rerun-if-changed={proto}");
    }

    Ok(())
}
