diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 17af89e9e34..bbb75880b53 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -17,7 +17,7 @@ path = "lib.rs" doctest = false [features] -gecko = ["style_traits/gecko", "bindgen", "regex", "toml", "num_cpus"] +gecko = ["style_traits/gecko", "bindgen", "regex", "toml", "num_cpus", "mozbuild"] servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "servo_url", "string_cache", "to_shmem/servo", @@ -79,6 +79,7 @@ void = "1.0.2" bindgen = { version = "0.62", optional = true, default-features = false } lazy_static = "1" log = "0.4" +mozbuild = {version = "0.1", optional = true} regex = { version = "1.1", optional = true } toml = { version = "0.5", optional = true, default-features = false } walkdir = "2.1.4" diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index 848ea50f8de..9c411b3ddb2 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -42,14 +42,12 @@ fn read_config(path: &PathBuf) -> Table { lazy_static! { static ref CONFIG: Table = { // Load Gecko's binding generator config from the source tree. - let path = PathBuf::from(env::var_os("MOZ_SRC").unwrap()) - .join("layout/style/ServoBindings.toml"); + let path = mozbuild::TOPSRCDIR.join("layout/style/ServoBindings.toml"); read_config(&path) }; static ref BINDGEN_FLAGS: Vec = { // Load build-specific config overrides. - let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap()) - .join("layout/style/extra-bindgen-flags"); + let path = mozbuild::TOPOBJDIR.join("layout/style/extra-bindgen-flags"); println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); fs::read_to_string(path).expect("Failed to read extra-bindgen-flags file") .split_whitespace() @@ -57,13 +55,7 @@ lazy_static! { .collect() }; static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); - static ref DISTDIR_PATH: PathBuf = { - let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap()); - if !path.is_absolute() || !path.is_dir() { - panic!("MOZ_TOPOBJDIR must be an absolute directory, was: {}", path.display()); - } - path.join("dist") - }; + static ref DISTDIR_PATH: PathBuf = mozbuild::TOPOBJDIR.join("dist"); static ref SEARCH_PATHS: Vec = vec![ DISTDIR_PATH.join("include"), DISTDIR_PATH.join("include/nspr"),