Bug 1751331 - Use the mozbuild crate in servo. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D136562
This commit is contained in:
Mike Hommey 2022-01-25 21:29:51 +00:00
parent 7723b5cc59
commit 2239244615
3 changed files with 6 additions and 12 deletions

1
Cargo.lock generated
View File

@ -4830,6 +4830,7 @@ dependencies = [
"malloc_size_of", "malloc_size_of",
"malloc_size_of_derive", "malloc_size_of_derive",
"matches", "matches",
"mozbuild",
"new_debug_unreachable", "new_debug_unreachable",
"nsstring", "nsstring",
"num-derive", "num-derive",

View File

@ -17,7 +17,7 @@ path = "lib.rs"
doctest = false doctest = false
[features] [features]
gecko = ["nsstring", "serde", "style_traits/gecko", "bindgen", "regex", "toml"] gecko = ["nsstring", "serde", "style_traits/gecko", "bindgen", "regex", "toml", "mozbuild"]
servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever", servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union", "cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
"servo_url", "string_cache", "to_shmem/servo", "servo_arc/servo"] "servo_url", "string_cache", "to_shmem/servo", "servo_arc/servo"]
@ -84,3 +84,4 @@ bindgen = {version = "0.56", optional = true, default-features = false}
regex = {version = "1.0", optional = true, default-features = false, features = ["perf", "std"]} regex = {version = "1.0", optional = true, default-features = false, features = ["perf", "std"]}
walkdir = "2.1.4" walkdir = "2.1.4"
toml = {version = "0.4.5", optional = true, default-features = false} toml = {version = "0.4.5", optional = true, default-features = false}
mozbuild = {version = "0.1", optional = true}

View File

@ -42,14 +42,12 @@ fn read_config(path: &PathBuf) -> Table {
lazy_static! { lazy_static! {
static ref CONFIG: Table = { static ref CONFIG: Table = {
// Load Gecko's binding generator config from the source tree. // Load Gecko's binding generator config from the source tree.
let path = PathBuf::from(env::var_os("MOZ_SRC").unwrap()) let path = mozbuild::TOPSRCDIR.join("layout/style/ServoBindings.toml");
.join("layout/style/ServoBindings.toml");
read_config(&path) read_config(&path)
}; };
static ref BINDGEN_FLAGS: Vec<String> = { static ref BINDGEN_FLAGS: Vec<String> = {
// Load build-specific config overrides. // Load build-specific config overrides.
let path = PathBuf::from(env::var_os("MOZ_TOPOBJDIR").unwrap()) let path = mozbuild::TOPOBJDIR.join("layout/style/extra-bindgen-flags");
.join("layout/style/extra-bindgen-flags");
println!("cargo:rerun-if-changed={}", path.to_str().unwrap()); println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
fs::read_to_string(path).expect("Failed to read extra-bindgen-flags file") fs::read_to_string(path).expect("Failed to read extra-bindgen-flags file")
.split_whitespace() .split_whitespace()
@ -57,13 +55,7 @@ lazy_static! {
.collect() .collect()
}; };
static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap();
static ref DISTDIR_PATH: PathBuf = { static ref DISTDIR_PATH: PathBuf = mozbuild::TOPOBJDIR.join("dist");
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 SEARCH_PATHS: Vec<PathBuf> = vec![ static ref SEARCH_PATHS: Vec<PathBuf> = vec![
DISTDIR_PATH.join("include"), DISTDIR_PATH.join("include"),
DISTDIR_PATH.join("include/nspr"), DISTDIR_PATH.join("include/nspr"),