mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Move binding files into another directory.
So that we can copy them when not using bindgen altogether.
This commit is contained in:
parent
35dc68c234
commit
a60e5f0218
6 changed files with 31 additions and 42 deletions
|
@ -9,23 +9,6 @@ mod common {
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub static ref OUTDIR_PATH: PathBuf = PathBuf::from(env::var("OUT_DIR").unwrap()).join("gecko");
|
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")]
|
#[cfg(feature = "bindgen")]
|
||||||
|
@ -43,6 +26,23 @@ mod bindings {
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
use super::common::*;
|
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! {
|
lazy_static! {
|
||||||
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 = {
|
||||||
|
@ -839,30 +839,19 @@ mod bindings {
|
||||||
#[cfg(not(feature = "bindgen"))]
|
#[cfg(not(feature = "bindgen"))]
|
||||||
mod bindings {
|
mod bindings {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::Path;
|
||||||
use super::common::*;
|
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() {
|
pub fn generate() {
|
||||||
generate_structs(BuildType::Debug);
|
let dir = Path::new(file!()).parent().unwrap().join("gecko/generated");
|
||||||
generate_structs(BuildType::Release);
|
println!("cargo:rerun-if-changed={}", dir.display());
|
||||||
generate_bindings();
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,9 @@ files = [
|
||||||
# Helper macro where actually a pseudo-element per line makes sense.
|
# Helper macro where actually a pseudo-element per line makes sense.
|
||||||
"./components/style/gecko/non_ts_pseudo_class_list.rs",
|
"./components/style/gecko/non_ts_pseudo_class_list.rs",
|
||||||
# Generated and upstream code combined with our own. Could use cleanup
|
# Generated and upstream code combined with our own. Could use cleanup
|
||||||
"./components/style/gecko_bindings/bindings.rs",
|
"./components/style/gecko/generated/bindings.rs",
|
||||||
"./components/style/gecko_bindings/structs_debug.rs",
|
"./components/style/gecko/generated/structs_debug.rs",
|
||||||
"./components/style/gecko_bindings/structs_release.rs",
|
"./components/style/gecko/generated/structs_release.rs",
|
||||||
"./components/style/gecko_string_cache/atom_macro.rs",
|
"./components/style/gecko_string_cache/atom_macro.rs",
|
||||||
"./resources/hsts_preload.json",
|
"./resources/hsts_preload.json",
|
||||||
"./tests/wpt/metadata/MANIFEST.json",
|
"./tests/wpt/metadata/MANIFEST.json",
|
||||||
|
|
|
@ -8,7 +8,7 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
ROOT_PATH = os.path.join("..", "..", "..")
|
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")
|
OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "check_bindings.rs")
|
||||||
GLUE_FILE = os.path.join(ROOT_PATH, "ports", "geckolib", "glue.rs")
|
GLUE_FILE = os.path.join(ROOT_PATH, "ports", "geckolib", "glue.rs")
|
||||||
GLUE_OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "glue.rs")
|
GLUE_OUTPUT_FILE = os.path.join(os.environ["OUT_DIR"], "glue.rs")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue