Allow specifying sysroot OR sysroot_src
This commit is contained in:
parent
696775153d
commit
2c2520fbb4
@ -230,16 +230,26 @@ pub fn load_inline(
|
|||||||
project_json: ProjectJson,
|
project_json: ProjectJson,
|
||||||
target: Option<&str>,
|
target: Option<&str>,
|
||||||
) -> Result<ProjectWorkspace> {
|
) -> Result<ProjectWorkspace> {
|
||||||
let sysroot = match project_json.sysroot_src.clone() {
|
let sysroot = match (project_json.sysroot.clone(), project_json.sysroot_src.clone()) {
|
||||||
Some(sysroot_src) => {
|
(Some(sysroot), Some(sysroot_src)) => Some(Sysroot::load(sysroot, sysroot_src)?),
|
||||||
// if `sysroot` isn't specified (only `sysroot_src`), we won't have
|
(Some(sysroot), None) => {
|
||||||
// a real sysroot path, that's fine. it's just used to discover
|
// assume sysroot is structured like rustup's and guess `sysroot_src`
|
||||||
// the standalone `proc-macro-srv` binary.
|
let sysroot_src =
|
||||||
let sysroot = project_json.sysroot.clone().unwrap_or_else(|| sysroot_src.clone());
|
sysroot.join("lib").join("rustlib").join("src").join("rust").join("library");
|
||||||
|
|
||||||
Some(Sysroot::load(sysroot, sysroot_src)?)
|
Some(Sysroot::load(sysroot, sysroot_src)?)
|
||||||
}
|
}
|
||||||
None => None,
|
(None, Some(sysroot_src)) => {
|
||||||
|
// assume sysroot is structured like rustup's and guess `sysroot`
|
||||||
|
let mut sysroot = sysroot_src.clone();
|
||||||
|
for _ in 0..5 {
|
||||||
|
sysroot.pop();
|
||||||
|
}
|
||||||
|
Some(Sysroot::load(sysroot, sysroot_src)?)
|
||||||
|
}
|
||||||
|
(None, None) => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let rustc_cfg = rustc_cfg::get(None, target);
|
let rustc_cfg = rustc_cfg::get(None, target);
|
||||||
Ok(ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg })
|
Ok(ProjectWorkspace::Json { project: project_json, sysroot, rustc_cfg })
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user