IDL from build.rs, without the CLI

The companion for zerodds-build: a prost-build-style build-script helper that compiles .idl to Rust through the shared composition pipeline — no external binary, no PATH requirement.

What it shows

  • The pipeline it runs is the one the CLI runs: #include tracking, vendor key-pragmas, default extensibility and TypeObject lowering.
  • idl/Pose.idl holds a plain @appendable struct Pose; idl/Robot.idl adds #include "Pose.idl", a struct Unit with a nested Pose, and #pragma keylist Unit id — the Cyclone/OpenSplice/RTI pragma spelling of @key, not the OMG IDL 4.2 annotation.
  • The roundtrip test asserts both that Unit's wire form carries the CDR key encoding the pragma should have produced and that the TypeObject block is non-empty — proof the full pipeline ran.
  • Contrast with idlc-buildrs: that one shells out to the compiled CLI and needs it on PATH.

Build and run

cargo test   # roundtrip + TypeObject unit test on the lib target
cargo run --bin zerodds-build-sample-demo

Output

zerodds-build-sample-demo: 36 bytes on the wire, roundtripped Unit { id: 7, pose: Pose { x: 1.0, y: 2.0, theta: 0.5 } }

Taken verbatim from the example's own README.

See also

IDL aus build.rs, ohne die CLI

Der Begleiter für zerodds-build: ein Build-Script-Helfer im Stil von prost-build, der .idl über die geteilte Kompositions-Pipeline nach Rust übersetzt — kein externes Binary, keine PATH-Anforderung.

Was es zeigt

  • Die Pipeline, die es fährt, ist die der CLI: #include-Verfolgung, Vendor-Key-Pragmas, Default-Extensibility und TypeObject-Lowering.
  • idl/Pose.idl enthält ein einfaches @appendable struct Pose; idl/Robot.idl ergänzt #include "Pose.idl", ein struct Unit mit verschachteltem Pose und #pragma keylist Unit id — die Pragma-Schreibweise von Cyclone/OpenSplice/RTI für @key, nicht die OMG-IDL-4.2-Annotation.
  • Der Roundtrip-Test sichert zu, dass die Wire-Form von Unit die CDR-Key-Kodierung trägt, die das Pragma erzeugen sollte, und dass der TypeObject-Block nicht leer ist — Beleg, dass die vollständige Pipeline lief.
  • Im Gegensatz zu idlc-buildrs: Das ruft die kompilierte CLI auf und braucht sie auf dem PATH.

Bauen und ausführen

cargo test   # Roundtrip- und TypeObject-Unit-Test auf dem Lib-Target
cargo run --bin zerodds-build-sample-demo

Ausgabe

zerodds-build-sample-demo: 36 bytes on the wire, roundtripped Unit { id: 7, pose: Pose { x: 1.0, y: 2.0, theta: 0.5 } }

Wörtlich aus dem README des Beispiels übernommen.

Verwandt