Skip to content

Commit

Permalink
Merge pull request #1 from tcheinen/master
Browse files Browse the repository at this point in the history
fix issue with compiling due to duplicate symbols in math.h
  • Loading branch information
19h authored Jun 28, 2020
2 parents 1d83078 + 77eca7d commit e075c65
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,43 @@ use bindgen::builder;

use std::env;
use std::path::PathBuf;
use std::collections::HashSet;

#[derive(Debug)]
struct IgnoreMacros(HashSet<String>);

impl bindgen::callbacks::ParseCallbacks for IgnoreMacros {
fn will_parse_macro(&self, name: &str) -> bindgen::callbacks::MacroParsingBehavior {
if self.0.contains(name) {
bindgen::callbacks::MacroParsingBehavior::Ignore
} else {
bindgen::callbacks::MacroParsingBehavior::Default
}
}
}

fn main() {
println!("cargo:rustc-link-lib=gvc");
println!("cargo:rustc-link-lib=cgraph");
println!("cargo:rustc-link-lib=pathplan");
println!("cargo:rustc-link-lib=cdt");

let ignored_macros = IgnoreMacros(
vec![
"FP_INFINITE".into(),
"FP_NAN".into(),
"FP_NORMAL".into(),
"FP_SUBNORMAL".into(),
"FP_ZERO".into(),
]
.into_iter()
.collect(),
);

let bindings =
builder()
.header("./wrapper.h")
.parse_callbacks(Box::new(ignored_macros))
.generate()
.expect("Unable to generate bindings");

Expand Down

0 comments on commit e075c65

Please sign in to comment.