Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fall back to using cargo on the host when no image is found. #312

Merged
merged 1 commit into from
Sep 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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