Got include to work, but bindgen still errors out
This commit is contained in:
parent
42adfb57fb
commit
d1ce31d8cf
2 changed files with 28 additions and 6 deletions
|
@ -8,6 +8,10 @@ license = "MIT/Apache-2.0"
|
||||||
categories = ["gui", "external-ffi-bindings"]
|
categories = ["gui", "external-ffi-bindings"]
|
||||||
build = "build.rs"
|
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]
|
[build-dependencies]
|
||||||
cc = "1.0"
|
cc = "1.0"
|
||||||
imgui = { git = "https://github.com/aloucks/imgui-rs/", branch = "export_include" }
|
bindgen = "0.53.1"
|
||||||
|
|
|
@ -3,8 +3,9 @@
|
||||||
// This is taken pretty vanilla from
|
// This is taken pretty vanilla from
|
||||||
// https://github.com/Gekkio/imgui-rs/blob/master/imgui-sys/build.rs
|
// https://github.com/Gekkio/imgui-rs/blob/master/imgui-sys/build.rs
|
||||||
// for now, but expected to diverge from that over time.
|
// for now, but expected to diverge from that over time.
|
||||||
use std::fs;
|
use std::{env, fs, io, path::PathBuf};
|
||||||
use std::io;
|
|
||||||
|
use bindgen;
|
||||||
|
|
||||||
const CPP_FILES: [&str; 2] = [
|
const CPP_FILES: [&str; 2] = [
|
||||||
"third-party/cimplot/cimplot.cpp",
|
"third-party/cimplot/cimplot.cpp",
|
||||||
|
@ -25,6 +26,7 @@ fn assert_file_exists(path: &str) -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> io::Result<()> {
|
fn main() -> io::Result<()> {
|
||||||
|
// --- Compile cimgui
|
||||||
let mut build = cc::Build::new();
|
let mut build = cc::Build::new();
|
||||||
build.cpp(true);
|
build.cpp(true);
|
||||||
// Disabled due to linking issues
|
// Disabled due to linking issues
|
||||||
|
@ -33,11 +35,10 @@ fn main() -> io::Result<()> {
|
||||||
.define("IMGUI_DISABLE_WIN32_FUNCTIONS", None)
|
.define("IMGUI_DISABLE_WIN32_FUNCTIONS", None)
|
||||||
.define("IMGUI_DISABLE_OSX_FUNCTIONS", None);
|
.define("IMGUI_DISABLE_OSX_FUNCTIONS", None);
|
||||||
|
|
||||||
// This won't seem to work yet
|
|
||||||
let imgui_third_party =
|
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);
|
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");
|
build.flag_if_supported("-Wno-return-type-c-linkage");
|
||||||
for path in &CPP_FILES {
|
for path in &CPP_FILES {
|
||||||
|
@ -45,5 +46,22 @@ fn main() -> io::Result<()> {
|
||||||
build.file(path);
|
build.file(path);
|
||||||
}
|
}
|
||||||
build.compile("libcimplot.a");
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue