use std::env;
use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());

    tonic_prost_build::configure()
        .build_server(false)
        .build_client(true)
        .out_dir(&out_dir)
        // Suppress warnings in generated code
        .server_mod_attribute(".", "#[allow(unused_qualifications)]")
        .client_mod_attribute(".", "#[allow(unused_qualifications)]")
        .compile_protos(
            &[
                "../e2e/proto/trading.proto",
                "../e2e/proto/ml_training.proto",
            ],
            &["../e2e/proto"],
        )?;

    Ok(())
}
