From caa5b8f6f9582b3e9c28b0cd2c2dd9fd0f2e183f Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sat, 7 Sep 2019 14:18:21 +0200 Subject: [PATCH] Fall back to using `cargo` on the host when no image is found. --- src/docker.rs | 6 +++--- src/main.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/docker.rs b/src/docker.rs index 56a02a02e..2b1f9e687 100644 --- a/src/docker.rs +++ b/src/docker.rs @@ -171,7 +171,7 @@ pub fn run(target: &Target, .run_and_get_status(verbose) } -fn image(toml: Option<&Toml>, target: &Target) -> Result { +pub fn image(toml: Option<&Toml>, target: &Target) -> Result { if let Some(toml) = toml { if let Some(image) = toml.image(target)?.map(|s| s.to_owned()) { return Ok(image) @@ -181,8 +181,8 @@ fn image(toml: Option<&Toml>, target: &Target) -> Result { let triple = target.triple(); if !DOCKER_IMAGES.contains(&triple) { - bail!("cross does not provide docker image for {} target, \ - specify a custom image in Cross.toml", triple); + bail!("`cross` does not provide a Docker image for target {}, \ + specify a custom image in `Cross.toml`.", triple); } let version = env!("CARGO_PKG_VERSION"); diff --git a/src/main.rs b/src/main.rs index f8303c2fb..7eeff67b9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -277,7 +277,15 @@ fn run() -> Result { let needs_interpreter = args.subcommand.map(|sc| sc.needs_interpreter()).unwrap_or(false); - if target.needs_docker() && + let image_exists = match docker::image(toml.as_ref(), &target) { + Ok(_) => true, + Err(err) => { + eprintln!("Warning: {} Falling back to `cargo` on the host.", err); + false + }, + }; + + if image_exists && target.needs_docker() && args.subcommand.map(|sc| sc.needs_docker()).unwrap_or(false) { if version_meta.needs_interpreter() && needs_interpreter &&