Skip to content
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

CI doesn't build examples in documentation #192

Closed
hannobraun opened this issue Jan 10, 2020 · 2 comments
Closed

CI doesn't build examples in documentation #192

hannobraun opened this issue Jan 10, 2020 · 2 comments
Labels
type: infrastructure Issues relating to the build and test infrastructure

Comments

@hannobraun
Copy link
Member

hannobraun commented Jan 10, 2020

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.
@hannobraun hannobraun added the type: infrastructure Issues relating to the build and test infrastructure label Jan 10, 2020
@hannobraun
Copy link
Member Author

Forgot one additional option:

  • Run rustdoc --test src/lib.rs directly. That doesn't require the test crate (I think), but we need to pass it all the info that Cargo would otherwise take care of.

@hannobraun hannobraun changed the title CI doens't run examples in documentation CI doens't compile examples in documentation Mar 19, 2020
@hannobraun hannobraun changed the title CI doens't compile examples in documentation CI doesn't build examples in documentation Mar 19, 2020
@hannobraun
Copy link
Member Author

I noticed some typos and wrong use of words in the title and original issue description. I updated both to make them more clear.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: infrastructure Issues relating to the build and test infrastructure
Projects
None yet
Development

No branches or pull requests

1 participant