make Valgrind optional

This commit is contained in:
edef 2015-04-16 03:21:40 -04:00
parent 2760a0a7aa
commit 195350863a
5 changed files with 20 additions and 2 deletions

View File

@ -8,5 +8,6 @@ build = "build.rs"
gcc = "0.3.3" gcc = "0.3.3"
[features] [features]
default = ["os"] default = ["os", "valgrind"]
os = [] os = []
valgrind = []

View File

@ -1,5 +1,8 @@
extern crate gcc; extern crate gcc;
use std::env::var_os;
fn main() { fn main() {
gcc::compile_library("libvalgrind.a", &["src/debug/valgrind.c"]); if var_os("CARGO_FEATURE_VALGRIND").is_some() {
gcc::compile_library("libvalgrind.a", &["src/debug/valgrind/native.c"]);
}
} }

14
src/debug/valgrind/mod.rs Normal file
View File

@ -0,0 +1,14 @@
pub use self::imp::*;
#[cfg(feature = "valgrind")]
#[path = "native.rs"]
mod imp;
#[cfg(not(feature = "valgrind"))]
mod imp {
//! Stub for the Valgrind functions
#![allow(non_camel_case_types)]
pub type stack_id_t = ();
pub unsafe fn stack_register(_start: *const u8, _end: *const u8) -> stack_id_t {}
pub unsafe fn stack_deregister(_id: stack_id_t) {}
}