servo: Merge #14563 - Add asserts to make failure clearer (from upsuper:buildtime-bindgen); r=emilio
authorXidorn Quan <me@upsuper.org>
Tue, 13 Dec 2016 01:40:23 -0800
changeset 340325 e112a04957731eb2d22369cc8ce662b60b55ff44
parent 340324 0ea1d828c66589d690e55ed98ab927a0a268a318
child 340326 0b360afbefa1804d88b51a7046a48d9d50971175
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
servo: Merge #14563 - Add asserts to make failure clearer (from upsuper:buildtime-bindgen); r=emilio Gecko currently doesn't pass absolute path for `MOZ_DIST`, which leads to obscure panic when running the build script. This patch adds some assertions so that failures around this would be clearer. r? @emilio Source-Repo: https://github.com/servo/servo Source-Revision: a6cfec972f033df77276d74f7bc455f6717ea50f
servo/components/style/build_gecko.rs
--- a/servo/components/style/build_gecko.rs
+++ b/servo/components/style/build_gecko.rs
@@ -37,17 +37,23 @@ mod bindings {
     use std::fs::File;
     use std::io::{BufWriter, Read, Write};
     use std::path::PathBuf;
     use std::sync::Mutex;
     use super::common::*;
 
     lazy_static! {
         static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap();
-        static ref DISTDIR_PATH: PathBuf = PathBuf::from(env::var("MOZ_DIST").unwrap());
+        static ref DISTDIR_PATH: PathBuf = {
+            let path = PathBuf::from(env::var("MOZ_DIST").unwrap());
+            if !path.is_absolute() || !path.is_dir() {
+                panic!("MOZ_DIST must be an absolute directory, was: {}", path.display());
+            }
+            path
+        };
         static ref SEARCH_PATHS: Vec<PathBuf> = vec![
             DISTDIR_PATH.join("include"),
             DISTDIR_PATH.join("include/nspr"),
         ];
         static ref ADDED_PATHS: Mutex<HashSet<PathBuf>> = Mutex::new(HashSet::new());
     }
 
     fn search_include(name: &str) -> Option<PathBuf> {