Skip to content

Commit

Permalink
Auto merge of #6778 - phil-opp:canonicalize-config-target, r=alexcric…
Browse files Browse the repository at this point in the history
…hton

Canonicalize default target if it ends with `.json`

Targets that end with `.json` are not target triples but paths to target configuration files. We currently canonicalize all `.json` paths that are passed as `--target` so that the paths are still valid when building dependencies (where the current working directory is changed).

This commit adds the same canonicalization to default targets specified in a `build.target` key in a `.cargo/config` file by adding a new `Config::target_triple` function.
  • Loading branch information
bors committed Mar 25, 2019
2 parents 5b4840d + 703f7a7 commit 4cc4337
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/cargo/core/compiler/build_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,17 @@ impl BuildConfig {
failure::bail!("target was empty")
}
}
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
let cfg_target = match config.get_string("build.target")? {
Some(ref target) if target.val.ends_with(".json") => {
let path = target.definition.root(config).join(&target.val);
let path_string = path
.into_os_string()
.into_string()
.map_err(|_| failure::format_err!("Target path is not valid unicode"));
Some(path_string?)
}
other => other.map(|t| t.val),
};
let target = requested_target.or(cfg_target);

if jobs == Some(0) {
Expand Down

0 comments on commit 4cc4337

Please sign in to comment.