|
1 | 1 | use std::env;
|
2 |
| -use std::ffi::OsString; |
| 2 | +use std::ffi::{OsStr, OsString}; |
3 | 3 | use std::fmt::Write as _;
|
4 | 4 | use std::fs::{self, File};
|
5 | 5 | use std::io::{self, BufRead, BufReader, BufWriter, Read, Write};
|
@@ -341,8 +341,11 @@ fn setup(subcommand: MiriCommand) {
|
341 | 341 | ask_to_run(cmd, ask_user, "install a recent enough xargo");
|
342 | 342 | }
|
343 | 343 |
|
344 |
| - // Determine where the rust sources are located. `XARGO_RUST_SRC` env var trumps everything. |
345 |
| - let rust_src = match std::env::var_os("XARGO_RUST_SRC") { |
| 344 | + // Determine where the rust sources are located. The env vars manually setting the source |
| 345 | + // (`MIRI_LIB_SRC`, `XARGO_RUST_SRC`) trump auto-detection. |
| 346 | + let rust_src_env_var = |
| 347 | + std::env::var_os("MIRI_LIB_SRC").or_else(|| std::env::var_os("XARGO_RUST_SRC")); |
| 348 | + let rust_src = match rust_src_env_var { |
346 | 349 | Some(path) => {
|
347 | 350 | let path = PathBuf::from(path);
|
348 | 351 | // Make path absolute if possible.
|
@@ -376,6 +379,13 @@ fn setup(subcommand: MiriCommand) {
|
376 | 379 | if !rust_src.exists() {
|
377 | 380 | show_error(format!("given Rust source directory `{}` does not exist.", rust_src.display()));
|
378 | 381 | }
|
| 382 | + if rust_src.file_name().and_then(OsStr::to_str) != Some("library") { |
| 383 | + show_error(format!( |
| 384 | + "given Rust source directory `{}` does not seem to be the `library` subdirectory of \ |
| 385 | + a Rust source checkout.", |
| 386 | + rust_src.display() |
| 387 | + )); |
| 388 | + } |
379 | 389 |
|
380 | 390 | // Next, we need our own libstd. Prepare a xargo project for that purpose.
|
381 | 391 | // We will do this work in whatever is a good cache dir for this platform.
|
|
0 commit comments