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};
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)]
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")