mirror of
https://github.com/servo/servo.git
synced 2025-06-19 14:48:59 +01:00
Auto merge of #18753 - upsuper:binding-structs, r=emilio
Only generate structs file for the current build This PR changes build_gecko.rs to only generate the `structs.rs` for the current build (rather than both), depending on whether `gecko_debug` feature is set. The in-tree files are switched to use the previous release one, because that's what we currently use for stylo test and it is in general what we really care about. For this change, `gecko_debug` mode is removed from Servo CI (in `build-geckolib`) with the assumption that people general do that build locally for stylo development, so it is less likely to be broken than release. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18753) <!-- Reviewable:end -->
This commit is contained in:
commit
f2879a568d
7 changed files with 12 additions and 37883 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;
|
||||
|
|
|
@ -442,8 +442,6 @@ class MachCommands(CommandBase):
|
|||
opts += ["-v"]
|
||||
if release:
|
||||
opts += ["--release"]
|
||||
else:
|
||||
features += ["gecko_debug"]
|
||||
|
||||
if features:
|
||||
opts += ["--features", ' '.join(features)]
|
||||
|
|
|
@ -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