aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_plugins
diff options
context:
space:
mode:
authorKatasonov Vladyslav <cpud47@gmail.com>2019-06-04 23:08:01 +0300
committerKatasonov Vladyslav <cpud47@gmail.com>2019-06-04 23:08:01 +0300
commit293e6c88e85602d155ddbcf154a59675efe95a6c (patch)
treeaee96a28b5014191af5a526970f8e563ab0f58db /components/script_plugins
parentfe8aad722749e8e5c9223800b98fc4e87b9ab161 (diff)
downloadservo-293e6c88e85602d155ddbcf154a59675efe95a6c.tar.gz
servo-293e6c88e85602d155ddbcf154a59675efe95a6c.zip
Made webidl search path relative to manifest.
Manifest dir should be more stable than current dir.
Diffstat (limited to 'components/script_plugins')
-rw-r--r--components/script_plugins/webidl_must_inherit.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/components/script_plugins/webidl_must_inherit.rs b/components/script_plugins/webidl_must_inherit.rs
index ce6ed841217..f853211d0f2 100644
--- a/components/script_plugins/webidl_must_inherit.rs
+++ b/components/script_plugins/webidl_must_inherit.rs
@@ -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)