Crates.io | dinghy-lib |
lib.rs | dinghy-lib |
version | 0.7.3 |
source | src |
created_at | 2018-03-12 12:51:58.601125 |
updated_at | 2024-10-16 09:27:02.717046 |
description | Cross-compilation made easier - see main crate cargo-dinghy |
homepage | https://medium.com/snips-ai/dinghy-painless-rust-tests-and-benches-on-ios-and-android-c9f94f81d305#.c2sx7two8 |
repository | https://github.com/sonos/dinghy |
max_upload_size | |
id | 55156 |
size | 153,592 |
Dinghy is a cargo
extension to bring cargo workflow to cross-compilation situations.
Dinghy is specifically useful with "small" processor-based devices, like Android and iOS phones, or small single board computers like the Raspberry Pi. Situations where native compilation is not possible, or not practical.
Initially tests and benches were the primary objective of Dinghy, but now
at Snips we use it to cross-compile our entire platform. This includes setting
up the stage for cc
and pkg-config
crates in one single place.
If you are a Rust library author, you can run your tests and benches on your smartphone in minutes. And you should, at least once in a while.
Let's try how BurntSushi's byteorder handles f32 on a few arm devices, two smartphones, and a Raspberry Pi.
Phew. It works.
Once dinghy knows about your toolchains and devices, you will be able to run tests and benches from a simple cargo command in any cargo project, most of the time without altering them.
Just add dinghy -d some_device
between cargo
and its subcommand:
cargo dinghy -d my_android test
cargo dinghy -d my_raspberry bench
By default, without -d
, Dinghy will make a native build, just like cargo
would do.
Depending on your targets and your workstation, the ease of setting up Dinghy can vary.
dinghy-build
crate offers some build.rs
features that are useful in
the context of cross-compilation.If your project already build for the target platform without dinghy and you only want to use dinghy to run code on a
device, you can use dinghy's bundled runner directly. You simply need to register the dinghy as a runner in .cargo/config
.
Here's an example for all apple targets
[target.'cfg(all(any(target_arch="aarch64",target_arch="x86_64"),target_vendor="apple",any(target_os="ios",target_os="tvos",target_os="apple-watchos")))']
runner = "cargo dinghy runner --"
You can then run your tests directly with cargo test --target aarch64-apple-ios-sim
for example.
Please note that the recommended way to use dinghy is as a cargo subcommand as it will set up quite a few things automatically for your project to even build.
The runner will try to auto-detect the platform if it is not passed (as in the above example)
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.