Update to imgui-rs 0.11.0.

Remove a lot of code 'temporarily' while we do some restructuring.
This commit is contained in:
silvana 2023-09-22 13:09:38 +02:00
parent cdd3888446
commit e6a6f67b4d
13 changed files with 13520 additions and 4963 deletions

380
implot-sys-bindgen/Cargo.lock generated Normal file
View file

@ -0,0 +1,380 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "aho-corasick"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea5d730647d4fadd988536d06fecce94b7b4f2a7efdae548f1cf4b63205518ab"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi",
"libc",
"winapi",
]
[[package]]
name = "bindgen"
version = "0.57.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"clap",
"env_logger",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"which",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "cc"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]
[[package]]
name = "cexpr"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chlorine"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75476fe966a8af7c0ceae2a3e514afa87d4451741fcdfab8bfaa07ad301842ec"
[[package]]
name = "clang-sys"
version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c688fc74432808e3eb684cae8830a86be1d66a2bd58e1f248ed0960a590baf6f"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clap"
version = "2.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
dependencies = [
"ansi_term",
"atty",
"bitflags",
"strsim",
"textwrap",
"unicode-width",
"vec_map",
]
[[package]]
name = "env_logger"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
dependencies = [
"atty",
"humantime",
"log",
"regex",
"termcolor",
]
[[package]]
name = "glob"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "imgui-sys"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d785272a57cb8058a53a1e6f376f48e2ec4f40fbc6a9bb197dabf7b6b59c03bf"
dependencies = [
"cc",
"cfg-if",
"chlorine",
"mint",
]
[[package]]
name = "implot-sys-bindgen"
version = "0.3.0"
dependencies = [
"bindgen",
"imgui-sys",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "libloading"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
dependencies = [
"cfg-if",
"winapi",
]
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]]
name = "memchr"
version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "mint"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff"
[[package]]
name = "nom"
version = "5.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08959a387a676302eebf4ddbcbc611da04285579f76f88ee0506c63b1a61dd4b"
dependencies = [
"memchr",
"version_check",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "proc-macro2"
version = "1.0.67"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae"
dependencies = [
"proc-macro2",
]
[[package]]
name = "regex"
version = "1.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.7.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "shlex"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2"
[[package]]
name = "strsim"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]]
name = "termcolor"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
dependencies = [
"unicode-width",
]
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "vec_map"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "which"
version = "3.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724"
dependencies = [
"libc",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f29e6f9198ba0d26b4c9f07dbe6f9ed633e1f3d5b8b414090084349e46a52596"
dependencies = [
"winapi",
]
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

View file

@ -6,4 +6,4 @@ edition = "2018"
[dependencies]
bindgen = "0.57"
imgui-sys = { version = "0.8.0" }
imgui-sys = { version = "0.11.0", features = ["docking"] }

View file

@ -6,67 +6,88 @@ use std::{env, io::Write, path::PathBuf};
// to git so people don't have to install clang just to use implot-rs.
fn main() {
let cwd = env::current_dir().expect("Could not read current directory");
let sys_crate_path = cwd
.join("..")
.join("implot-sys")
.canonicalize()
.expect("Could not find sys crate directory");
let cwd = env::current_dir().expect("Could not read current directory");
let sys_crate_path = cwd
.join("..")
.join("implot-sys")
.canonicalize()
.expect("Could not find sys crate directory");
let cimgui_include_path = PathBuf::from(
env::var_os("DEP_IMGUI_THIRD_PARTY").expect("DEP_IMGUI_THIRD_PARTY not defined"),
);
let cimgui_include_path = PathBuf::from(
env::var_os("DEP_IMGUI_THIRD_PARTY").expect("DEP_IMGUI_THIRD_PARTY not defined"),
);
let bindings = Builder::default()
.header(
cimgui_include_path
.join("cimgui.h")
.to_str()
.expect("Could not convert cimgui.h path to string"),
)
.header(
sys_crate_path
.join("third-party")
.join("cimplot")
.join("cimplot.h")
.to_str()
.expect("Could not turn cimplot.h path into string"),
)
.parse_callbacks(Box::new(CargoCallbacks))
.clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1")
// Reuse the imgui types that implot requires from imgui_sys so we don't define
// our own new types.
.raw_line("pub use imgui_sys::{ImVec2, ImVec4, ImGuiCond, ImTextureID};")
.raw_line("pub use imgui_sys::{ImGuiContext, ImGuiKeyModFlags, ImDrawList};")
.raw_line("pub use imgui_sys::{ImGuiMouseButton, ImGuiDragDropFlags};")
.whitelist_recursively(false)
.whitelist_function("ImPlot.*")
.whitelist_type("ImPlot.*")
// We do want to create bindings for the scalar typedefs
.whitelist_type("Im[U|S][0-9]{1,2}")
// Remove some functions that would take a variable-argument list
.blacklist_function("ImPlot_AnnotateVVec4")
.blacklist_function("ImPlot_AnnotateVStr")
.blacklist_function("ImPlot_AnnotateClampedVVec4")
.blacklist_function("ImPlot_AnnotateClampedVStr")
.generate()
.expect("Unable to generate bindings");
println!("{}", cimgui_include_path.display());
// The above type re-export shenanigans make bindgen unable to derive Copy, Clone and Debug on
// some types, but they would work - we hence manually re-add them here.
let mut bindings_string = bindings.to_string();
["ImPlotInputMap", "ImPlotStyle"].iter().for_each(|name| {
bindings_string = bindings_string.replace(
&format!("pub struct {}", name),
&format!("#[derive(Clone, Copy, Debug)]\npub struct {}", name),
);
});
let bindings = Builder::default()
.header(
cimgui_include_path
.join("cimgui.h")
.to_str()
.expect("Could not convert cimgui.h path to string"),
)
.header(
sys_crate_path
.join("third-party")
.join("cimplot")
.join("cimplot.h")
.to_str()
.expect("Could not turn cimplot.h path into string"),
)
.parse_callbacks(Box::new(CargoCallbacks))
.clang_arg("-DCIMGUI_DEFINE_ENUMS_AND_STRUCTS=1")
.clang_arg(format!("-I{}", cimgui_include_path.display()))
// Reuse the imgui types that implot requires from imgui_sys so we don't define
// our own new types.
.raw_line("pub use imgui_sys::{ImVec2, ImVector_ImU32, ImVec4, ImGuiCond, ImTextureID};")
.raw_line("pub use imgui_sys::{ImGuiTextBuffer, ImGuiStorage, ImWchar, ImGuiTextRange};")
.raw_line("pub use imgui_sys::{ImGuiStoragePair, ImDrawCmd, *};")
.raw_line("pub use imgui_sys::{ImGuiContext, ImGuiKey, ImDrawList};")
.raw_line("pub use imgui_sys::{ImGuiMouseButton, ImGuiDragDropFlags};")
.raw_line("use libc::time_t;")
.whitelist_recursively(false)
.whitelist_function("ImPlot.*")
.whitelist_type("ImPlot.*")
// We do want to create bindings for the scalar typedefs
.whitelist_type("Im[U|S][0-9]{1,2}")
.whitelist_type("ImAxis")
.whitelist_var("ImAxis_")
.whitelist_type("ImPool_.+")
.whitelist_type("ImVector_.+")
.whitelist_type("tm")
// Remove some functions that would take a variable-argument list
.blacklist_function("ImPlot_AnnotateVVec4")
.blacklist_function("ImPlot_AnnotateVStr")
.blacklist_function("ImPlot_AnnotateClampedVVec4")
.blacklist_function("ImPlot_AnnotateClampedVStr")
.blacklist_type("ImVector_ImU32")
.blacklist_function("ImPlot_MkGmtTime")
.blacklist_function("ImPlot_GetGmtTime")
.blacklist_function("ImPlot_MkLocTime")
.blacklist_function("ImPlot_GetLocTime")
.blacklist_function("ImPlot_AnnotationV")
.blacklist_function("ImPlot_TagXV")
.blacklist_function("ImPlot_TagYV")
.blacklist_function("ImPlotAnnotationCollection_AppendV")
.blacklist_function("ImPlotTagCollection_AppendV")
.generate()
.expect("Unable to generate bindings");
// Finally we write the bindings to a file.
let out_path = sys_crate_path.join("src");
let mut out_file =
std::fs::File::create(&out_path.join("bindings.rs")).expect("Could not open bindings file");
out_file
.write_all(&bindings_string.into_bytes()[..])
.expect("Couldn't write bindings");
// The above type re-export shenanigans make bindgen unable to derive Copy, Clone and Debug on
// some types, but they would work - we hence manually re-add them here.
let mut bindings_string = bindings.to_string();
["ImPlotInputMap", "ImPlotStyle"].iter().for_each(|name| {
bindings_string = bindings_string.replace(
&format!("pub struct {}", name),
&format!("#[derive(Clone, Copy, Debug)]\npub struct {}", name),
);
});
// Finally we write the bindings to a file.
let out_path = sys_crate_path.join("src");
let mut out_file =
std::fs::File::create(&out_path.join("bindings.rs")).expect("Could not open bindings file");
out_file
.write_all(&bindings_string.into_bytes()[..])
.expect("Couldn't write bindings");
}