Skip to content

Commit

Permalink
Restructure project to enable custom mavlink bindings generation (#223)
Browse files Browse the repository at this point in the history
* Restructure project to enable custom mavlink bindings generation

Split the project into three crates:

* mavlink-core: core MAVLink types including TCP, UDP and serial connections
* mavlink-bindgen: a library & CLI for generating Rust bindings for MAVLink dialects
* mavlink: generated MAVLink bindings for the MAVLink dialects in the mavlink/mavlink repo

* run GitHub checks

* reformat

* attempt to fix cross compile test

* attempt to install cross

* Downgrade clap to support MSRV 1.65.0

* Downgrade clap_lex to support MSRV 1.65.0

* Another downgrade

* downgrade anstyle

* Simplify support for MSRV 1.65.0

* Hopefully this works

* fix embedded build

* Fix build on MSRV

* Make cli feature not default

* Only build the mavlink package in tests.

The mavlink-bindgen crate does not itself need to run on embedded hardware

* Attempt to support no_std in mavlink again

* Fix for the last GitHub action

* Make the embedded example work in the cargo workspace

* Remove unused import

* Remove accidentally committed binary
  • Loading branch information
GrahamDennis authored Feb 18, 2024
1 parent be0bc1e commit 09411e9
Show file tree
Hide file tree
Showing 48 changed files with 555 additions and 227 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.65.0
- uses: actions-rs/cargo@v1
with:
command: install
args: cross --locked
- uses: actions-rs/cargo@v1
with:
use-cross: true
Expand Down Expand Up @@ -103,7 +107,7 @@ jobs:
with:
use-cross: true
command: build
args: --verbose --release --target=${{ matrix.TARGET }} ${{ matrix.FLAGS }}
args: --verbose --release --package=mavlink --target=${{ matrix.TARGET }} ${{ matrix.FLAGS }}

test-embedded-size:
needs: build
Expand All @@ -114,7 +118,7 @@ jobs:
with:
target: thumbv7em-none-eabihf
- name: Build
run: cargo +nightly build --target thumbv7em-none-eabihf --manifest-path examples/embedded/Cargo.toml --out-dir $PWD --release -Z unstable-options
run: cargo +nightly build --target thumbv7em-none-eabihf --manifest-path mavlink/examples/embedded/Cargo.toml --out-dir $PWD --release -Z unstable-options

docs:
needs: internal-tests
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "mavlink"]
path = mavlink
[submodule "mavlink/mavlink"]
path = mavlink/mavlink
url = https://github.com/mavlink/mavlink
128 changes: 128 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 4 additions & 99 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,105 +1,10 @@
[workspace]
members = ["mavlink", "mavlink-bindgen", "mavlink-core"]
resolver = "1"

[package]
name = "mavlink"
version = "0.12.2"
authors = ["Todd Stellanova", "Michal Podhradsky", "Kevin Mehall", "Tim Ryan", "Patrick José Pereira", "Ibiyemi Abiodun"]
build = "build/main.rs"
description = "Implements the MAVLink data interchange format for UAVs."
readme = "README.md"
license = "MIT/Apache-2.0"
repository = "https://github.com/mavlink/rust-mavlink"
edition = "2018"
rust-version = "1.65.0"

[build-dependencies]
crc-any = { version = "2.3.0", default-features = false }
quick-xml = "0.26"
quote = "1"
proc-macro2 = "1.0.43"
lazy_static = "1.2.0"
serde = { version = "1.0.115", optional = true, features = ["derive"] }

[[example]]
name = "mavlink-dump"
path = "examples/mavlink-dump/src/main.rs"
required-features = ["ardupilotmega"]

[dependencies]
[workspace.dependencies]
crc-any = { version = "2.3.5", default-features = false }
num-traits = { version = "0.2", default-features = false }
num-derive = "0.3.2"
bitflags = "1.2.1"
serial = { version = "0.4", optional = true }
serde = { version = "1.0.115", optional = true, features = ["derive"] }
byteorder = { version = "1.3.4", default-features = false }
embedded-hal = { version = "0.2", optional = true }
nb = { version = "1.0", optional = true }
serde_arrays = { version = "0.1.0", optional = true }

[features]
"all" = [
"ardupilotmega",
"asluav",
"common",
"development",
"icarous",
"minimal",
"python_array_test",
"standard",
"test",
"ualberta",
"uavionix",
"avssuas",
"cubepilot",
]
"ardupilotmega" = ["common", "icarous", "uavionix"]
"asluav" = ["common"]
"avssuas" = ["common"]
"development" = ["common"]
"matrixpilot" = ["common"]
"minimal" = []
"paparazzi" = ["common"]
"python_array_test" = ["common"]
"slugs" = ["common"]
"standard" = ["common"]
"test" = []
"ualberta" = ["common"]
"uavionix" = ["common"]
"icarous" = []
"common" = []
"cubepilot" = ["common"]

"all-dialects" = [
"ardupilotmega",
"asluav",
"avssuas",
"development",
"matrixpilot",
"minimal",
"paparazzi",
"python_array_test",
"slugs",
"standard",
"test",
"ualberta",
"uavionix",
"icarous",
"common",
"cubepilot",
]

"format-generated-code" = []
"emit-description" = []
"emit-extensions" = []
"std" = ["byteorder/std"]
"udp" = []
"tcp" = []
"direct-serial" = []
"embedded" = ["embedded-hal", "nb"]
"serde" = ["dep:serde", "dep:serde_arrays"]
default = ["std", "tcp", "udp", "direct-serial", "serial", "serde", "ardupilotmega"]

# build with all features on docs.rs so that users viewing documentation
# can see everything
[package.metadata.docs.rs]
features = ["default", "all-dialects", "emit-description", "emit-extensions", "format-generated-code"]
101 changes: 0 additions & 101 deletions build/main.rs

This file was deleted.

Loading

0 comments on commit 09411e9

Please sign in to comment.