From 7c6fda8ea996111424340cac05fff10d551b4e69 Mon Sep 17 00:00:00 2001 From: Nathan Froyd Date: Thu, 20 Apr 2017 17:04:58 -0400 Subject: [PATCH] switch gecko_bindings over to the gecko_debug feature ...so that they use the correct Gecko structs regardless of whether Rust code is being compiled with debug assertions or not. --- components/style/Cargo.toml | 2 +- components/style/gecko_bindings/mod.rs | 2 +- .../style/gecko_bindings/nsstring_vendor/Cargo.toml | 2 ++ .../style/gecko_bindings/nsstring_vendor/src/lib.rs | 4 ++-- components/style/gecko_bindings/sugar/ns_com_ptr.rs | 4 ++-- ports/geckolib/glue.rs | 2 +- python/servo/build_commands.py | 8 +++++++- 7 files changed, 16 insertions(+), 8 deletions(-) diff --git a/components/style/Cargo.toml b/components/style/Cargo.toml index 4c42919be8b..06649f36eeb 100644 --- a/components/style/Cargo.toml +++ b/components/style/Cargo.toml @@ -20,7 +20,7 @@ servo = ["serde/unstable", "serde", "serde_derive", "heapsize", "heapsize_derive "cssparser/heapsize", "cssparser/serde", "encoding", "rayon/unstable", "servo_url"] testing = [] -gecko_debug = [] +gecko_debug = ["nsstring_vendor/gecko_debug"] [dependencies] app_units = "0.4" diff --git a/components/style/gecko_bindings/mod.rs b/components/style/gecko_bindings/mod.rs index fa874c7ca42..6ebf8aa0f33 100644 --- a/components/style/gecko_bindings/mod.rs +++ b/components/style/gecko_bindings/mod.rs @@ -16,7 +16,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(debug_assertions)] { + if #[cfg(feature = "gecko_debug")] { include!(concat!(env!("OUT_DIR"), "/gecko/structs_debug.rs")); } else { include!(concat!(env!("OUT_DIR"), "/gecko/structs_release.rs")); diff --git a/components/style/gecko_bindings/nsstring_vendor/Cargo.toml b/components/style/gecko_bindings/nsstring_vendor/Cargo.toml index 035bae1b095..c1294f34ea8 100644 --- a/components/style/gecko_bindings/nsstring_vendor/Cargo.toml +++ b/components/style/gecko_bindings/nsstring_vendor/Cargo.toml @@ -10,3 +10,5 @@ description = "Rust bindings to xpcom string types" [dependencies] +[features] +gecko_debug = [] diff --git a/components/style/gecko_bindings/nsstring_vendor/src/lib.rs b/components/style/gecko_bindings/nsstring_vendor/src/lib.rs index 6b666feb666..385fe5f24da 100644 --- a/components/style/gecko_bindings/nsstring_vendor/src/lib.rs +++ b/components/style/gecko_bindings/nsstring_vendor/src/lib.rs @@ -899,12 +899,12 @@ macro_rules! ns_auto_string { } } -#[cfg(not(debug_assertions))] +#[cfg(not(feature = "gecko_debug"))] #[allow(non_snake_case)] unsafe fn Gecko_IncrementStringAdoptCount(_: *mut c_void) {} extern "C" { - #[cfg(debug_assertions)] + #[cfg(feature = "gecko_debug")] fn Gecko_IncrementStringAdoptCount(data: *mut c_void); // Gecko implementation in nsSubstring.cpp diff --git a/components/style/gecko_bindings/sugar/ns_com_ptr.rs b/components/style/gecko_bindings/sugar/ns_com_ptr.rs index c7ad3af5e35..4cbd81e5876 100644 --- a/components/style/gecko_bindings/sugar/ns_com_ptr.rs +++ b/components/style/gecko_bindings/sugar/ns_com_ptr.rs @@ -8,14 +8,14 @@ use gecko_bindings::structs::nsCOMPtr; impl nsCOMPtr { /// Get this pointer as a raw pointer. - #[cfg(debug_assertions)] + #[cfg(feature = "gecko_debug")] #[inline] pub fn raw(&self) -> *mut T { self.mRawPtr } /// Get this pointer as a raw pointer. - #[cfg(not(debug_assertions))] + #[cfg(not(feature = "gecko_debug"))] #[inline] pub fn raw(&self) -> *mut T { self._base.mRawPtr as *mut _ diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 81c956c3187..a4119ba18f8 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1982,7 +1982,7 @@ pub extern "C" fn Servo_GetComputedKeyframeValues(keyframes: RawGeckoKeyframeLis #[no_mangle] pub extern "C" fn Servo_AssertTreeIsClean(root: RawGeckoElementBorrowed) { - if !cfg!(debug_assertions) { + if !cfg!(feature = "gecko_debug") { panic!("Calling Servo_AssertTreeIsClean in release build"); } diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index efed18c609e..792b6071145 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -417,8 +417,9 @@ class MachCommands(CommandBase): ret = None opts = [] + features = [] if with_gecko is not None: - opts += ["--features", "bindgen"] + features += ["bindgen"] env["MOZ_DIST"] = path.abspath(path.expanduser(with_gecko)) if jobs is not None: opts += ["-j", jobs] @@ -426,6 +427,11 @@ class MachCommands(CommandBase): opts += ["-v"] if release: opts += ["--release"] + else: + features += ["gecko_debug"] + + if features: + opts += ["--features", ' '.join(features)] if with_gecko is not None: print("Generating atoms data...")