Skip to content

Commit 4cc4337

Browse files
committed
Auto merge of #6778 - phil-opp:canonicalize-config-target, r=alexcrichton
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.
2 parents 5b4840d + 703f7a7 commit 4cc4337

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/cargo/core/compiler/build_config.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,17 @@ impl BuildConfig {
6565
failure::bail!("target was empty")
6666
}
6767
}
68-
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
68+
let cfg_target = match config.get_string("build.target")? {
69+
Some(ref target) if target.val.ends_with(".json") => {
70+
let path = target.definition.root(config).join(&target.val);
71+
let path_string = path
72+
.into_os_string()
73+
.into_string()
74+
.map_err(|_| failure::format_err!("Target path is not valid unicode"));
75+
Some(path_string?)
76+
}
77+
other => other.map(|t| t.val),
78+
};
6979
let target = requested_target.or(cfg_target);
7080

7181
if jobs == Some(0) {

0 commit comments

Comments
 (0)