Got include to work, but bindgen still errors out

This commit is contained in:
4bb4 2020-07-12 14:29:02 +02:00
parent 42adfb57fb
commit d1ce31d8cf
2 changed files with 28 additions and 6 deletions

View file

@ -8,6 +8,10 @@ license = "MIT/Apache-2.0"
categories = ["gui", "external-ffi-bindings"]
build = "build.rs"
[dependencies]
imgui-sys = { git = "https://github.com/Gekkio/imgui-rs/", branch = "master" }
imgui = { git = "https://github.com/Gekkio/imgui-rs/", branch = "master" }
[build-dependencies]
cc = "1.0"
imgui = { git = "https://github.com/aloucks/imgui-rs/", branch = "export_include" }
bindgen = "0.53.1"

View file

@ -3,8 +3,9 @@
// This is taken pretty vanilla from
// https://github.com/Gekkio/imgui-rs/blob/master/imgui-sys/build.rs
// for now, but expected to diverge from that over time.
use std::fs;
use std::io;
use std::{env, fs, io, path::PathBuf};
use bindgen;
const CPP_FILES: [&str; 2] = [
"third-party/cimplot/cimplot.cpp",
@ -25,6 +26,7 @@ fn assert_file_exists(path: &str) -> io::Result<()> {
}
fn main() -> io::Result<()> {
// --- Compile cimgui
let mut build = cc::Build::new();
build.cpp(true);
// Disabled due to linking issues
@ -33,11 +35,10 @@ fn main() -> io::Result<()> {
.define("IMGUI_DISABLE_WIN32_FUNCTIONS", None)
.define("IMGUI_DISABLE_OSX_FUNCTIONS", None);
// This won't seem to work yet
let imgui_third_party =
std::env::var_os("DEP_IMGUI_THIRD_PARTY").expect("No env var found for third_party folder");
env::var_os("DEP_IMGUI_THIRD_PARTY").expect("No envvar found for third_party");
println!("third party is {:?}", imgui_third_party);
build.include(imgui_third_party);
build.include(imgui_third_party.clone().into_string().unwrap() + "/imgui/");
build.flag_if_supported("-Wno-return-type-c-linkage");
for path in &CPP_FILES {
@ -45,5 +46,22 @@ fn main() -> io::Result<()> {
build.file(path);
}
build.compile("libcimplot.a");
// --- Create bindgen bindings
// The actual generate() errors out right now with parsing errors,
// will probably need to whiltelist things, fix preprocessor definitions,
// bindgen settings or some combination thereof.
let _bindings = bindgen::Builder::default()
.header(imgui_third_party.into_string().unwrap() + "/cimgui.h")
.header("wrapper.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks));
//.generate()
//.expect("Unable to generate bindings");
//let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
//bindings
//.write_to_file(out_path.join("bindings.rs"))
//.expect("Couldn't write bindings!");
Ok(())
}