zlayer-builder 0.13.0

Dockerfile parsing and buildah-based container image building
Documentation
//! Build script for zlayer-builder.
//!
//! Compiles the buildah-sidecar gRPC schema at
//! `<CARGO_MANIFEST_DIR>/proto/buildah_sidecar.proto` into
//! `${OUT_DIR}/zlayer.buildah_sidecar.v1.rs`, which the crate `include!`s
//! from `backend/buildah_sidecar/mod.rs`.
//!
//! The proto lives INSIDE the crate (not at the workspace root) so the
//! crate stays self-contained when consumed as a git or registry dep
//! (and so `cargo vendor` and `cargo package` carry it along). Older
//! revs of this crate sourced the proto from `../../proto/`, which only
//! resolved correctly inside a live `ZLayer` workspace checkout — vendor
//! / publish consumers got a "No such file or directory" build failure.

use std::path::PathBuf;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let manifest_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR")?);
    let proto_dir = manifest_dir.join("proto");
    let proto_path = proto_dir.join("buildah_sidecar.proto");

    println!("cargo:rerun-if-changed={}", proto_path.display());

    // tonic-build 0.14 split prost code generation into `tonic-prost-build`.
    // The runtime crate `tonic-build` now only exposes the trait-based
    // codegen plumbing; the high-level `configure()` builder lives in
    // `tonic-prost-build`.
    tonic_prost_build::configure()
        .build_server(false) // Rust side is a client only.
        .build_client(true)
        .compile_protos(&[proto_path], &[proto_dir])?;

    Ok(())
}