Skip to content

Commit 0a9a344

Browse files
committed
Canonicalize paths passed as --target
1 parent e4ee901 commit 0a9a344

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/cargo/ops/cargo_compile.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
2525
use std::collections::{HashMap, HashSet};
2626
use std::default::Default;
27-
use std::path::PathBuf;
27+
use std::path::{Path, PathBuf};
2828
use std::sync::Arc;
2929

3030
use core::{Package, Source, Target};
3131
use core::{PackageId, PackageIdSpec, Profile, Profiles, TargetKind, Workspace};
3232
use core::resolver::{Method, Resolve};
3333
use ops::{self, BuildOutput, DefaultExecutor, Executor};
3434
use util::config::Config;
35-
use util::{profile, CargoResult};
35+
use util::{profile, CargoResult, CargoResultExt};
3636

3737
/// Contains information about how a package should be compiled.
3838
#[derive(Debug)]
@@ -235,7 +235,17 @@ pub fn compile_ws<'a>(
235235
ref target_rustc_args,
236236
} = *options;
237237

238-
let target = target.clone();
238+
let target = match target {
239+
&Some(ref target) if target.ends_with(".json") => {
240+
let path = Path::new(target)
241+
.canonicalize()
242+
.chain_err(|| format_err!("Target path {:?} is not a valid file", target))?;
243+
Some(path.into_os_string()
244+
.into_string()
245+
.map_err(|_| format_err!("Target path is not valid unicode"))?)
246+
}
247+
other => other.clone(),
248+
};
239249

240250
if jobs == Some(0) {
241251
bail!("jobs must be at least 1")

0 commit comments

Comments
 (0)