mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 21:48:36 +00:00
Verify that cimgui/imgui files are accessible
This provides a nicer error if somebody is trying to run the examples without having submodules fetched
This commit is contained in:
parent
5304f13362
commit
74ff73d06d
@ -1,10 +1,34 @@
|
||||
fn main() {
|
||||
cc::Build::new()
|
||||
.cpp(true)
|
||||
.file("third-party/cimgui/cimgui.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_demo.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_draw.cpp")
|
||||
.file("third-party/cimgui/imgui/imgui_widgets.cpp")
|
||||
.compile("libcimgui.a");
|
||||
use std::fs;
|
||||
use std::io;
|
||||
|
||||
const CPP_FILES: [&str; 5] = [
|
||||
"third-party/cimgui/cimgui.cpp",
|
||||
"third-party/cimgui/imgui/imgui.cpp",
|
||||
"third-party/cimgui/imgui/imgui_demo.cpp",
|
||||
"third-party/cimgui/imgui/imgui_draw.cpp",
|
||||
"third-party/cimgui/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<()> {
|
||||
let mut build = cc::Build::new();
|
||||
build.cpp(true);
|
||||
for path in &CPP_FILES {
|
||||
assert_file_exists(path)?;
|
||||
build.file(path);
|
||||
}
|
||||
build.compile("libcimgui.a");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user