Skip to content

Commit

Permalink
Fall back to using cargo on the host when no image is found.
Browse files Browse the repository at this point in the history
  • Loading branch information
reitermarkus committed Sep 7, 2019
1 parent c9f7927 commit caa5b8f
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 caa5b8f

Please sign in to comment.