mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
Made webidl search path relative to manifest.
Manifest dir should be more stable than current dir.
This commit is contained in:
parent
fe8aad7227
commit
293e6c88e8
1 changed files with 18 additions and 2 deletions
|
@ -66,9 +66,25 @@ fn get_ty_name(ty: &str) -> &str {
|
|||
}
|
||||
}
|
||||
|
||||
fn get_manifest_dir() -> io::Result<path::PathBuf> {
|
||||
match env::var("CARGO_MANIFEST_DIR") {
|
||||
Ok(var) => {
|
||||
let mut dir = path::PathBuf::new();
|
||||
dir.push(var);
|
||||
Ok(dir)
|
||||
},
|
||||
Err(env::VarError::NotPresent) => {
|
||||
Err(io::Error::new(io::ErrorKind::NotFound, "CARGO_MANIFEST_DIR environment variable was not found"))
|
||||
},
|
||||
Err(env::VarError::NotUnicode(_)) => {
|
||||
Err(io::Error::new(io::ErrorKind::InvalidData, "CARGO_MANIFEST_DIR environment variable's contents are non valid UTF-8"))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn get_webidl_path(struct_name: &str) -> io::Result<path::PathBuf> {
|
||||
let mut dir = env::current_dir()?;
|
||||
dir.push("components/script/dom/webidls/");
|
||||
let mut dir = get_manifest_dir()?;
|
||||
dir.push("dom/webidls/");
|
||||
dir.push(format!("{}.webidl", struct_name));
|
||||
|
||||
Ok(dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue