imgui-rs/imgui-sys/build.rs
Joonas Javanainen 6ee5a2867b
Generate bindings for 1.76
cimgui has changed a lot, and the default bindings include a lot of
internal stuff that we (probably) don't want. Therefore we stop checking
out cimgui as a submodule and just use it as a tool instead.
2020-06-05 16:08:40 +03:00

47 lines
1.2 KiB
Rust

#![allow(dead_code)]
use std::fs;
use std::io;
const CPP_FILES: [&str; 5] = [
"third-party/cimgui.cpp",
"third-party/imgui/imgui.cpp",
"third-party/imgui/imgui_demo.cpp",
"third-party/imgui/imgui_draw.cpp",
"third-party/imgui/imgui_widgets.cpp",
];
fn assert_file_exists(path: &str) -> io::Result<()> {
match fs::metadata(path) {
Ok(_) => Ok(()),
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {
panic!(
"Can't access {}. Did you forget to fetch git submodules?",
path
);
}
Err(e) => Err(e),
}
}
fn main() -> io::Result<()> {
#[cfg(not(feature = "wasm"))]
{
let mut build = cc::Build::new();
build.cpp(true);
// Disabled due to linking issues
build
.define("CIMGUI_NO_EXPORT", None)
.define("IMGUI_DISABLE_WIN32_FUNCTIONS", None)
.define("IMGUI_DISABLE_OSX_FUNCTIONS", None);
build.flag_if_supported("-Wno-return-type-c-linkage");
for path in &CPP_FILES {
assert_file_exists(path)?;
build.file(path);
}
build.compile("libcimgui.a");
}
Ok(())
}