Skip to content

CI doesn't build examples in documentation #192

Closed
@hannobraun

Description

@hannobraun

All examples in documentation should be built by scripts/build.sh, but that currently does cargo build only, not cargo test.

cargo test needs the test crate, which isn't available on Cortex-M. Which means we need to compile the tests on the host machine, which is fine, since we don't need to run them. The problem is, the target is set in .cargo/config, and there's no way (as far as I can tell) to say "ignore that, I want the target to be the host".

This leaves us with several options, none of which are ideal:

  • Not set the target in .cargo/config. This means we'll have to pass --target=thumbv6m-none-eabi to everything. This would suck, as I'm doing a lot of cargo run --example during development.
  • Override the target by passing --target to cargo test. We could just pass x86_64-unknown-linux-gnu, which would be good enough for me and for CI, but not for the general case.
  • Auto-detect target in build.rs and pass that via --target to cargo test. Maybe we can write the target triple into a file in target/, and read that in scripts/build.sh.
  • Write a Rust program that prints the current target (using build.rs, as in the linked Stack Overflow answer), cargo install that in scripts/build.sh. Maybe something like that even exists?
  • Implement Different default targets for cargo build and cargo test? rust-lang/cargo#6784 and use that new capability once it's released.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: infrastructureIssues relating to the build and test infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions