Add cross configuration#69
Conversation
This allows running unit tests on a non-linux platform via the `cross test` command.
|
Wow, I had no idea that was a thing! Would you mind adding some instructions/links in the readme? |
So I'll add generic instructions on how to use cross to test. There is more to it in terms of running |
|
|
||
| ## Running unit tests | ||
|
|
||
| First, you'll need to install the `aarch64-unknown-linux-gnu` target to run unit tests. |
There was a problem hiding this comment.
Why would I need that target specifically? Does x86_64 not work for the tests? Also why would I need to cross compile in the first place for running tests?
There was a problem hiding this comment.
Oh sorry. That's incorrect. Updated
|
|
||
| Running tests with `cross`: | ||
|
|
||
| cross test --target x86_64-unknown-linux-gnu --tests --features stm32h503 |
There was a problem hiding this comment.
Judging by the
[target.aarch64-unknown-linux-gnu.image]
line in Cross.toml is there something special to do on that arch?
There was a problem hiding this comment.
So you can run it on either architecture. That directive in Cross.toml is to allow you to run tests for the aarch64-unknown-linux-gnu in a cross aarch64-unknown-linux-gnu image that is built for arm64 hosts (ie. no cross-compilation), which makes building a lot faster on an arm64 Macs (and probably Windows too). Unfortunately building that cross image for arm64 hosts is currently broken (this PR will fix it I believe: https://github.com/japaric/xargo/pull/349/files), so including instructions for use is kinda awkward. Without that directive, cross will download the aarch64-unknown-linux-gnu image built for x86_64 and run the tests on that, which does involve cross compilation and provides no benefit over running the x86_64-unknown-linux-gnu cross image.
There was a problem hiding this comment.
I'll add some instructions for building with a guest image that matches the host architecture when it's more accessible with cross!
This allows running unit tests on a non-linux platform via the
cross testcommand.