From d16896264308d96a34632be46a7bcfb39c43091a Mon Sep 17 00:00:00 2001 From: pv42 Date: Wed, 7 Aug 2024 14:25:42 +0200 Subject: [PATCH] Fix: improve mavlink-bindgen readme --- mavlink-bindgen/README.md | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/mavlink-bindgen/README.md b/mavlink-bindgen/README.md index 7e678a70cb..c813b5fc3a 100644 --- a/mavlink-bindgen/README.md +++ b/mavlink-bindgen/README.md @@ -1,46 +1,46 @@ -# rust-mavlink +# mavlink-bindgen [![Build status](https://github.com/mavlink/rust-mavlink/actions/workflows/test.yml/badge.svg)](https://github.com/mavlink/rust-mavlink/actions/workflows/test.yml) - [![Crate info](https://img.shields.io/crates/v/mavlink-bindgen.svg)](https://crates.io/crates/mavlink-bindgen) [![Documentation](https://docs.rs/mavlink-bindgen/badge.svg)](https://docs.rs/mavlink-bindgen) -Library and CLI for code generator of the Rust implementation of the [MAVLink](https://mavlink.io/en) UAV messaging protocol. +Library and CLI for generating code for the Rust implementation of the [MAVLink](https://mavlink.io/en) UAV messaging protocol. -`mavlink-bindgen` can be used to create MAVLink bindings for Rust. This is used from `build.rs` in the [mavlink](https://crates.io/crates/mavlink) crate to create bindings from the standard MAVLink dialects in https://github.com/mavlink/mavlink. +`mavlink-bindgen` can be used to create MAVLink bindings for Rust. This is used from `build.rs` in the [mavlink](https://crates.io/crates/mavlink) crate to create bindings from the standard MAVLink dialects in . ## Usage -`mavlink-bindgen` can be used as a code generator from `build.rs` as done is the `mavlink` crate for a custom MAVLink dialect or as a CLI tool to generate rust binding from XML dialect definitions. The generated code will depend on the [mavlink-core](https://crates.io/crates/mavlink-core) crate in both use cases. +`mavlink-bindgen` can be used as a code generator from `build.rs` as done is the `mavlink` crate for a custom MAVLink dialect or as a CLI tool to generate rust binding from XML dialect definitions. The generated code will depend on the [mavlink-core](https://crates.io/crates/mavlink-core) crate in both use cases. Each dialect generated will be locked behind a feature flag of the same name, that must be enabled when using the generated code. ### CLI -Build using cargo with `cli` feature enabled: +Build the binary using cargo with `cli` feature enabled: ```shell +cd mavlink-bindgen cargo build --features cli ``` -Alternatively you can build and install `mavlink-bindgen` to you locally installed crates: +Alternatively you can build and install `mavlink-bindgen` to your locally installed crates: ```shell cargo install mavlink-bindgen --features cli ``` -Generate code using the resulting binary: +To generate code using the resulting binary: ```shell mavlink-bindgen --format-generated-code message_definitions mavlink_dialects ``` -The full options are shown below. +The full command line options are shown below. ```shell Usage: mavlink-bindgen [OPTIONS] Arguments: Path to the directory containing the MAVLink dialect definitions - Path to the directory where the code is generated into + Path to the directory where the code is generated into, must already exist Options: --format-generated-code format code generated code @@ -48,6 +48,8 @@ Options: -h, --help Print help ``` +The output dir will contain a `mod.rs` file with each dialect in its own file locked behind a feature flag. + ### Library as build dependency Add to your Cargo.toml: @@ -91,4 +93,6 @@ include!(concat!(env!("OUT_DIR"), "/mod.rs")); pub use mavlink_core::*; ``` -This approach is used by the mavlink crate see its build script for an example. +Since each dialect is locked behind a feature flag these need to be enabled for the dialects to become available when using the generated code. + +This approach is used by the `mavlink` crate see its build script for an example.