Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1167 from alexheretic/dot-cargo-config-target
Browse files Browse the repository at this point in the history
Use .cargo/config build.target-dir + "/rls"
  • Loading branch information
nrc authored Dec 4, 2018
2 parents cfd8449 + 2187243 commit cd79447
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/build/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,16 +690,28 @@ pub fn make_cargo_config(
.entry("build".to_owned())
.or_insert_with(|| ConfigValue::Table(HashMap::new(), config_path.clone()));

let target_dir = target_dir
.map(|d| d.to_str().unwrap().to_owned())
.unwrap_or_else(|| {
build_dir
.join("target")
.join("rls")
.to_str()
.unwrap()
.to_owned()
});
let target_dir = target_dir
.map(|d| d.to_str().unwrap().to_owned())
.unwrap_or_else(|| {
// Try to use .cargo/config build.target-dir + "/rls"
let cargo_target = build_value
.table("build")
.ok()
.and_then(|(build, _)| build.get("target-dir"))
.and_then(|td| td.string("target-dir").ok())
.map(|(target, _)| {
let t_path = Path::new(target);
if t_path.is_absolute() {
t_path.into()
} else {
build_dir.join(t_path)
}
})
.unwrap_or_else(|| build_dir.join("target"));

cargo_target.join("rls").to_str().unwrap().to_owned()
});

let td_value = ConfigValue::String(target_dir, config_path);
if let ConfigValue::Table(ref mut build_table, _) = *build_value {
build_table.insert("target-dir".to_owned(), td_value);
Expand Down

0 comments on commit cd79447

Please sign in to comment.