Skip to content

Commit

Permalink
Add support for (absolut) target JSON paths
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp committed Mar 24, 2018
1 parent e06560b commit 1a76dad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
7 changes: 1 addition & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ fn run() -> Result<ExitStatus> {
};

let cmode = if let Some(triple) = args.target() {
if Path::new(triple).is_file() {
bail!(
"Xargo doesn't support files as an argument to --target. \
Use `--target foo` instead of `--target foo.json`."
)
} else if triple == meta.host {
if triple == meta.host {
Some(CompilationMode::Native(meta.host.clone()))
} else {
Target::new(triple, &cd, verbose)?.map(CompilationMode::Cross)
Expand Down
13 changes: 13 additions & 0 deletions src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ impl Target {
if rustc::targets(verbose)?.iter().any(|t| t == &triple) {
Ok(Some(Target::Builtin { triple: triple }))
} else {
if Path::new(&triple).exists() {
let path = match Path::new(&triple).canonicalize() {
Ok(path) => path,
Err(_) => bail!("target path {:?} is invalid", triple),
};
let file_stem = match path.file_stem().and_then(|stem| stem.to_str()) {
Some(stem) => stem.into(),
None => {
bail!("target file name {:?} is empty or contains invalid unicode", path)
}
};
return Ok(Some(Target::Custom { json: path, triple: file_stem }))
}
let mut json = cd.path().join(&triple);
json.set_extension("json");

Expand Down

0 comments on commit 1a76dad

Please sign in to comment.