diff --git a/components/style/build_gecko.rs b/components/style/build_gecko.rs index c7371e40746..94fbae9f4fa 100644 --- a/components/style/build_gecko.rs +++ b/components/style/build_gecko.rs @@ -9,23 +9,6 @@ mod common { lazy_static! { pub static ref OUTDIR_PATH: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap()).join("gecko"); } - - pub const STRUCTS_DEBUG_FILE: &'static str = "structs_debug.rs"; - pub const STRUCTS_RELEASE_FILE: &'static str = "structs_release.rs"; - pub const BINDINGS_FILE: &'static str = "bindings.rs"; - - #[derive(Clone, Copy, PartialEq)] - pub enum BuildType { - Debug, - Release, - } - - pub fn structs_file(build_type: BuildType) -> &'static str { - match build_type { - BuildType::Debug => STRUCTS_DEBUG_FILE, - BuildType::Release => STRUCTS_RELEASE_FILE - } - } } #[cfg(feature = "bindgen")] @@ -43,6 +26,23 @@ mod bindings { use std::time::SystemTime; use super::common::*; + const STRUCTS_DEBUG_FILE: &'static str = "structs_debug.rs"; + const STRUCTS_RELEASE_FILE: &'static str = "structs_release.rs"; + const BINDINGS_FILE: &'static str = "bindings.rs"; + + #[derive(Clone, Copy, PartialEq)] + enum BuildType { + Debug, + Release, + } + + fn structs_file(build_type: BuildType) -> &'static str { + match build_type { + BuildType::Debug => STRUCTS_DEBUG_FILE, + BuildType::Release => STRUCTS_RELEASE_FILE + } + } + lazy_static! { static ref INCLUDE_RE: Regex = Regex::new(r#"#include\s*"(.+?)""#).unwrap(); static ref DISTDIR_PATH: PathBuf = { @@ -839,30 +839,19 @@ mod bindings { #[cfg(not(feature = "bindgen"))] mod bindings { use std::fs; - use std::path::{Path, PathBuf}; + use std::path::Path; use super::common::*; - lazy_static! { - static ref BINDINGS_PATH: PathBuf = Path::new(file!()).parent().unwrap().join("gecko_bindings"); - } - - fn generate_structs(build_type: BuildType) { - let file = structs_file(build_type); - let source = BINDINGS_PATH.join(file); - println!("cargo:rerun-if-changed={}", source.display()); - fs::copy(source, OUTDIR_PATH.join(file)).unwrap(); - } - - fn generate_bindings() { - let source = BINDINGS_PATH.join(BINDINGS_FILE); - println!("cargo:rerun-if-changed={}", source.display()); - fs::copy(source, OUTDIR_PATH.join(BINDINGS_FILE)).unwrap(); - } - pub fn generate() { - generate_structs(BuildType::Debug); - generate_structs(BuildType::Release); - generate_bindings(); + let dir = Path::new(file!()).parent().unwrap().join("gecko/generated"); + println!("cargo:rerun-if-changed={}", dir.display()); + let entries = dir.read_dir().expect("Fail to list the generated directory"); + for entry in entries { + let entry = entry.expect("Fail to get dir entry"); + println!("cargo:rerun-if-changed={}", entry.path().display()); + fs::copy(entry.path(), OUTDIR_PATH.join(entry.file_name())) + .expect("Fail to copy the file"); + } } } diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko/generated/bindings.rs similarity index 100% rename from components/style/gecko_bindings/bindings.rs rename to components/style/gecko/generated/bindings.rs diff --git a/components/style/gecko_bindings/structs_debug.rs b/components/style/gecko/generated/structs_debug.rs similarity index 100% rename from components/style/gecko_bindings/structs_debug.rs rename to components/style/gecko/generated/structs_debug.rs diff --git a/components/style/gecko_bindings/structs_release.rs b/components/style/gecko/generated/structs_release.rs similarity index 100% rename from components/style/gecko_bindings/structs_release.rs rename to components/style/gecko/generated/structs_release.rs diff --git a/servo-tidy.toml b/servo-tidy.toml index 6bc386c85f0..df227bb3afe 100644 --- a/servo-tidy.toml +++ b/servo-tidy.toml @@ -37,9 +37,9 @@ files = [ # Helper macro where actually a pseudo-element per line makes sense. "./components/style/gecko/non_ts_pseudo_class_list.rs", # Generated and upstream code combined with our own. Could use cleanup - "./components/style/gecko_bindings/bindings.rs", - "./components/style/gecko_bindings/structs_debug.rs", - "./components/style/gecko_bindings/structs_release.rs", + "./components/style/gecko/generated/bindings.rs", + "./components/style/gecko/generated/structs_debug.rs", + "./components/style/gecko/generated/structs_release.rs", "./components/style/gecko_string_cache/atom_macro.rs", "./resources/hsts_preload.json", "./tests/wpt/metadata/MANIFEST.json", diff --git a/tests/unit/stylo/check_bindings.py b/tests/unit/stylo/check_bindings.py index db5a11cc3a7..f4cdc5b6655 100755 --- a/tests/unit/stylo/check_bindings.py +++ b/tests/unit/stylo/check_bindings.py @@ -8,7 +8,7 @@ import os import re ROOT_PATH = os.path.join("..", "..", "..") -INPUT_FILE = os.path.join(ROOT_PATH, "components", "style", "gecko_bindings", "bindings.rs") +INPUT_FILE = os.path.join(ROOT_PATH, "components", "style", "gecko", "generated", "bindings.rs") OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "check_bindings.rs") GLUE_FILE = os.path.join(ROOT_PATH, "ports", "geckolib", "glue.rs") GLUE_OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "glue.rs")