-
Notifications
You must be signed in to change notification settings - Fork 6
Add cross configuration #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 |
README.md
Outdated
|
||
## 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add some instructions for building with a guest image that matches the host architecture when it's more accessible with cross!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This allows running unit tests on a non-linux platform via the
cross test
command.