|
| 1 | +//! Test building of the `cortex-m` crate, a foundational crate in the embedded ecosystem |
| 2 | +//! for a collection of thumb targets. This is a smoke test that verifies that both cargo |
| 3 | +//! and rustc work in this case. |
| 4 | +//! |
1 | 5 | //! How to run this |
2 | 6 | //! $ ./x.py clean |
3 | 7 | //! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make |
|
13 | 17 | use std::path::PathBuf; |
14 | 18 |
|
15 | 19 | use run_make_support::rfs::create_dir; |
16 | | -use run_make_support::{cmd, env_var}; |
| 20 | +use run_make_support::{cmd, env_var, target}; |
17 | 21 |
|
18 | 22 | const CRATE: &str = "cortex-m"; |
19 | 23 | const CRATE_URL: &str = "https://github.com/rust-embedded/cortex-m"; |
20 | 24 | const CRATE_SHA1: &str = "a448e9156e2cb1e556e5441fd65426952ef4b927"; // v0.5.0 |
21 | 25 |
|
22 | 26 | fn main() { |
| 27 | + // FIXME: requires an internet connection https://github.com/rust-lang/rust/issues/128733 |
23 | 28 | // See below link for git usage: |
24 | 29 | // https://stackoverflow.com/questions/3489173#14091182 |
25 | 30 | cmd("git").args(["clone", CRATE_URL, CRATE]).run(); |
26 | 31 | std::env::set_current_dir(CRATE).unwrap(); |
27 | 32 | cmd("git").args(["reset", "--hard", CRATE_SHA1]).run(); |
28 | 33 |
|
29 | 34 | let target_dir = PathBuf::from("target"); |
30 | | - let target = env_var("TARGET"); |
31 | | - |
32 | 35 | let manifest_path = PathBuf::from("Cargo.toml"); |
33 | 36 |
|
34 | 37 | let path = env_var("PATH"); |
35 | 38 | let rustc = env_var("RUSTC"); |
36 | 39 | let bootstrap_cargo = env_var("BOOTSTRAP_CARGO"); |
| 40 | + // FIXME: extract bootstrap cargo invocations to a proper command |
| 41 | + // https://github.com/rust-lang/rust/issues/128734 |
37 | 42 | let mut cmd = cmd(bootstrap_cargo); |
38 | 43 | cmd.args(&[ |
39 | 44 | "build", |
40 | 45 | "--manifest-path", |
41 | 46 | manifest_path.to_str().unwrap(), |
42 | 47 | "-Zbuild-std=core", |
43 | 48 | "--target", |
44 | | - &target, |
| 49 | + &target(), |
45 | 50 | ]) |
46 | 51 | .env("PATH", path) |
47 | 52 | .env("RUSTC", rustc) |
| 53 | + .env("CARGO_TARGET_DIR", &target_dir) |
48 | 54 | // Don't make lints fatal, but they need to at least warn |
49 | 55 | // or they break Cargo's target info parsing. |
50 | | - .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn") |
51 | | - .env("CARGO_TARGET_DIR", &target_dir) |
52 | | - .env("RUSTC_BOOTSTRAP", "1") |
53 | | - // Visual Studio 2022 requires that the LIB env var be set so it can |
54 | | - // find the Windows SDK. |
55 | | - .env("LIB", std::env::var("LIB").unwrap_or_default()); |
| 56 | + .env("RUSTFLAGS", "-Copt-level=0 -Cdebug-assertions=yes --cap-lints=warn"); |
56 | 57 |
|
57 | 58 | cmd.run(); |
58 | 59 | } |
0 commit comments