Added a separate bindgen building crate and pre-generated bindings

This commit is contained in:
4bb4 2020-08-03 21:50:03 +02:00
parent c1ccb4eb6f
commit 0f11df5989
7 changed files with 10072 additions and 24 deletions

View file

@ -15,4 +15,3 @@ imgui = { git = "https://github.com/Gekkio/imgui-rs/", branch = "master" }
[build-dependencies]
cc = "1.0"
bindgen = "0.53.1"

View file

@ -5,8 +5,6 @@
// for now, but expected to diverge from that over time.
use std::{env, fs, io, path::Path};
use bindgen;
const CPP_FILES: [&str; 2] = [
"third-party/cimplot/cimplot.cpp",
"third-party/cimplot/implot/implot.cpp",
@ -54,24 +52,6 @@ fn main() -> io::Result<()> {
assert_file_exists(path)?;
build.file(path);
}
build.compile("cimplot");
// --- Create bindgen bindings
// TODO(4bb4) move this out to separate shell script (see #1) so users don't have
// to have clang installed to build this crate.
let bindings = bindgen::Builder::default()
.header(&(cimgui_include_path.into_string().unwrap() + "/cimgui.h"))
.header("third-party/cimplot/cimplot.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks))
.clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1")
.generate()
.expect("Unable to generate bindings");
let out_path = std::path::PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
Ok(())
}

9999
implot-sys/src/bindings.rs Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,4 @@
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
// TODO(4bb4) change this to include the bindings we hand-generate
// once that is happening
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
include!("bindings.rs");