Skip to content

Commit

Permalink
switch gecko_bindings over to the gecko_debug feature
Browse files Browse the repository at this point in the history
...so that they use the correct Gecko structs regardless of whether Rust
code is being compiled with debug assertions or not.
  • Loading branch information
froydnj committed Apr 22, 2017
1 parent 93fa0ae commit 7c6fda8
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion components/style/Cargo.toml
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion components/style/gecko_bindings/mod.rs
Expand Up @@ -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"));
Expand Down
2 changes: 2 additions & 0 deletions components/style/gecko_bindings/nsstring_vendor/Cargo.toml
Expand Up @@ -10,3 +10,5 @@ description = "Rust bindings to xpcom string types"

[dependencies]

[features]
gecko_debug = []
4 changes: 2 additions & 2 deletions components/style/gecko_bindings/nsstring_vendor/src/lib.rs
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions components/style/gecko_bindings/sugar/ns_com_ptr.rs
Expand Up @@ -8,14 +8,14 @@ use gecko_bindings::structs::nsCOMPtr;

impl<T> nsCOMPtr<T> {
/// 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 _
Expand Down
2 changes: 1 addition & 1 deletion ports/geckolib/glue.rs
Expand Up @@ -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");
}

Expand Down
8 changes: 7 additions & 1 deletion python/servo/build_commands.py
Expand Up @@ -417,15 +417,21 @@ def build_geckolib(self, with_gecko=None, jobs=None, verbose=False, release=Fals

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]
if verbose:
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...")
Expand Down

0 comments on commit 7c6fda8

Please sign in to comment.