Skip to content

Commit

Permalink
Merge cross-rs#312
Browse files Browse the repository at this point in the history
312: Fall back to using `cargo` on the host when no image is found. r=reitermarkus a=reitermarkus



Co-authored-by: Markus Reiter <me@reitermark.us>
  • Loading branch information
bors[bot] and reitermarkus committed Sep 8, 2019
2 parents c9f7927 + caa5b8f commit 3fa5f1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/docker.rs
Expand Up @@ -171,7 +171,7 @@ pub fn run(target: &Target,
.run_and_get_status(verbose)
}

fn image(toml: Option<&Toml>, target: &Target) -> Result<String> {
pub fn image(toml: Option<&Toml>, target: &Target) -> Result<String> {
if let Some(toml) = toml {
if let Some(image) = toml.image(target)?.map(|s| s.to_owned()) {
return Ok(image)
Expand All @@ -181,8 +181,8 @@ fn image(toml: Option<&Toml>, target: &Target) -> Result<String> {
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");
Expand Down
10 changes: 9 additions & 1 deletion src/main.rs
Expand Up @@ -277,7 +277,15 @@ fn run() -> Result<ExitStatus> {

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 &&
Expand Down

0 comments on commit 3fa5f1b

Please sign in to comment.