mirror of
https://github.com/servo/servo.git
synced 2025-08-14 18:05:36 +01:00
Only generate structs file for the current build
This commit is contained in:
parent
44e0ce3ffe
commit
23d9d12430
6 changed files with 12 additions and 37881 deletions
|
@ -44,23 +44,9 @@ mod bindings {
|
|||
use super::super::PYTHON;
|
||||
use toml;
|
||||
|
||||
const STRUCTS_DEBUG_FILE: &'static str = "structs_debug.rs";
|
||||
const STRUCTS_RELEASE_FILE: &'static str = "structs_release.rs";
|
||||
const STRUCTS_FILE: &'static str = "structs.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
|
||||
}
|
||||
}
|
||||
|
||||
fn read_config(path: &PathBuf) -> toml::Table {
|
||||
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
|
||||
update_last_modified(&path);
|
||||
|
@ -176,7 +162,7 @@ mod bindings {
|
|||
}
|
||||
|
||||
trait BuilderExt {
|
||||
fn get_initial_builder(build_type: BuildType) -> Builder;
|
||||
fn get_initial_builder() -> Builder;
|
||||
fn include<T: Into<String>>(self, file: T) -> Builder;
|
||||
fn zero_size_type(self, ty: &str, structs_list: &HashSet<&str>) -> Builder;
|
||||
fn borrowed_type(self, ty: &str) -> Builder;
|
||||
|
@ -213,14 +199,14 @@ mod bindings {
|
|||
}
|
||||
|
||||
impl BuilderExt for Builder {
|
||||
fn get_initial_builder(build_type: BuildType) -> Builder {
|
||||
fn get_initial_builder() -> Builder {
|
||||
let mut builder = Builder::default();
|
||||
for dir in SEARCH_PATHS.iter() {
|
||||
builder = builder.clang_arg("-I").clang_arg(dir.to_str().unwrap());
|
||||
}
|
||||
builder = builder.include(add_include("mozilla-config.h"));
|
||||
|
||||
if build_type == BuildType::Debug {
|
||||
if env::var("CARGO_FEATURE_GECKO_DEBUG").is_ok() {
|
||||
builder = builder.clang_arg("-DDEBUG=1").clang_arg("-DJS_DEBUG=1");
|
||||
}
|
||||
|
||||
|
@ -376,7 +362,7 @@ mod bindings {
|
|||
}
|
||||
}
|
||||
|
||||
fn generate_structs(build_type: BuildType) {
|
||||
fn generate_structs() {
|
||||
#[derive(Debug)]
|
||||
struct Callbacks(HashMap<String, RegexSet>);
|
||||
impl ParseCallbacks for Callbacks {
|
||||
|
@ -394,7 +380,7 @@ mod bindings {
|
|||
}
|
||||
}
|
||||
|
||||
let builder = Builder::get_initial_builder(build_type)
|
||||
let builder = Builder::get_initial_builder()
|
||||
.enable_cxx_namespaces()
|
||||
.with_codegen_config(CodegenConfig {
|
||||
types: true,
|
||||
|
@ -434,7 +420,7 @@ mod bindings {
|
|||
if generic { "<T>" } else { "" }))
|
||||
})
|
||||
.get_builder();
|
||||
write_binding_file(builder, structs_file(build_type), &fixups);
|
||||
write_binding_file(builder, STRUCTS_FILE, &fixups);
|
||||
}
|
||||
|
||||
fn setup_logging() -> bool {
|
||||
|
@ -483,7 +469,7 @@ mod bindings {
|
|||
}
|
||||
|
||||
fn generate_bindings() {
|
||||
let builder = Builder::get_initial_builder(BuildType::Release)
|
||||
let builder = Builder::get_initial_builder()
|
||||
.disable_name_namespacing()
|
||||
.with_codegen_config(CodegenConfig {
|
||||
functions: true,
|
||||
|
@ -579,8 +565,7 @@ mod bindings {
|
|||
}
|
||||
}
|
||||
run_tasks! {
|
||||
generate_structs(BuildType::Debug),
|
||||
generate_structs(BuildType::Release),
|
||||
generate_structs(),
|
||||
generate_bindings(),
|
||||
generate_atoms(),
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -15,13 +15,7 @@ pub mod bindings {
|
|||
|
||||
#[allow(dead_code, improper_ctypes, non_camel_case_types, non_snake_case, non_upper_case_globals, missing_docs)]
|
||||
pub mod structs {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "gecko_debug")] {
|
||||
include!(concat!(env!("OUT_DIR"), "/gecko/structs_debug.rs"));
|
||||
} else {
|
||||
include!(concat!(env!("OUT_DIR"), "/gecko/structs_release.rs"));
|
||||
}
|
||||
}
|
||||
include!(concat!(env!("OUT_DIR"), "/gecko/structs.rs"));
|
||||
}
|
||||
|
||||
pub mod sugar;
|
||||
|
|
|
@ -47,8 +47,7 @@ files = [
|
|||
# Generated and upstream code combined with our own. Could use cleanup
|
||||
"./components/style/gecko/generated/bindings.rs",
|
||||
"./components/style/gecko/generated/pseudo_element_definition.rs",
|
||||
"./components/style/gecko/generated/structs_debug.rs",
|
||||
"./components/style/gecko/generated/structs_release.rs",
|
||||
"./components/style/gecko/generated/structs.rs",
|
||||
"./components/style/gecko/generated/atom_macro.rs",
|
||||
"./resources/hsts_preload.json",
|
||||
"./tests/wpt/metadata/MANIFEST.json",
|
||||
|
|
|
@ -64,7 +64,7 @@ fn main() {
|
|||
TO PASS DATA AROUND BETWEEN BUILD SCRIPTS_OUT_DIR").unwrap();
|
||||
File::create(out_dir.join("bindings.rs"))
|
||||
.unwrap()
|
||||
.write_all(format!("include!(concat!({:?}, \"/gecko/structs_debug.rs\"));",
|
||||
.write_all(format!("include!(concat!({:?}, \"/gecko/structs.rs\"));",
|
||||
style_out_dir).as_bytes())
|
||||
.unwrap();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue