#!/usr/bin/env bash # Regenerate Rust code from the HyperHDR flatbuffers schemas. # The flatc version must match the `flatbuffers` crate version in Cargo.toml. set -euo pipefail root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" out="$root/src/hyperhdr/generated" crate_ver="$(grep -E '^flatbuffers\s*=' "$root/Cargo.toml" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" flatc_ver="$(flatc --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" if [[ "$crate_ver" != "$flatc_ver" ]]; then echo "flatc $flatc_ver does not match flatbuffers crate $crate_ver" >&2 exit 1 fi rm -f "$out"/*_generated.rs mkdir -p "$out" flatc --rust -o "$out" "$root/schema/hyperhdr_request.fbs" "$root/schema/hyperhdr_reply.fbs" echo "generated with flatc $flatc_ver:" ls -1 "$out"