From: Philipp Oppermann Date: Thu, 22 Mar 2018 17:53:19 +0000 (+0100) Subject: Canonicalize paths passed as `--target` X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~2^2~7^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0a9a34416f8163d07aa7101e0698b6378d39b004;p=cargo.git Canonicalize paths passed as `--target` --- diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index bec0be93e..74cc8949a 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -24,7 +24,7 @@ use std::collections::{HashMap, HashSet}; use std::default::Default; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use std::sync::Arc; use core::{Package, Source, Target}; @@ -32,7 +32,7 @@ use core::{PackageId, PackageIdSpec, Profile, Profiles, TargetKind, Workspace}; use core::resolver::{Method, Resolve}; use ops::{self, BuildOutput, DefaultExecutor, Executor}; use util::config::Config; -use util::{profile, CargoResult}; +use util::{profile, CargoResult, CargoResultExt}; /// Contains information about how a package should be compiled. #[derive(Debug)] @@ -235,7 +235,17 @@ pub fn compile_ws<'a>( ref target_rustc_args, } = *options; - let target = target.clone(); + let target = match target { + &Some(ref target) if target.ends_with(".json") => { + let path = Path::new(target) + .canonicalize() + .chain_err(|| format_err!("Target path {:?} is not a valid file", target))?; + Some(path.into_os_string() + .into_string() + .map_err(|_| format_err!("Target path is not valid unicode"))?) + } + other => other.clone(), + }; if jobs == Some(0) { bail!("jobs must be at least 1")