mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-11 13:38:35 +00:00
Merge pull request #339 from aloucks/export_include
Expose include path and native defines via `DEP_` env variables
This commit is contained in:
commit
4981ff5943
@ -9,6 +9,7 @@ repository = "https://github.com/Gekkio/imgui-rs"
|
||||
license = "MIT/Apache-2.0"
|
||||
categories = ["gui", "external-ffi-bindings"]
|
||||
build = "build.rs"
|
||||
links = "imgui"
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.0"
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
use std::fs;
|
||||
use std::io;
|
||||
use std::path::Path;
|
||||
|
||||
const CPP_FILES: [&str; 5] = [
|
||||
"third-party/cimgui.cpp",
|
||||
@ -11,6 +12,13 @@ const CPP_FILES: [&str; 5] = [
|
||||
"third-party/imgui/imgui_widgets.cpp",
|
||||
];
|
||||
|
||||
const DEFINES: &[(&str, Option<&str>)] = &[
|
||||
// Disabled due to linking issues
|
||||
("CIMGUI_NO_EXPORT", None),
|
||||
("IMGUI_DISABLE_WIN32_FUNCTIONS", None),
|
||||
("IMGUI_DISABLE_OSX_FUNCTIONS", None),
|
||||
];
|
||||
|
||||
fn assert_file_exists(path: &str) -> io::Result<()> {
|
||||
match fs::metadata(path) {
|
||||
Ok(_) => Ok(()),
|
||||
@ -25,15 +33,21 @@ fn assert_file_exists(path: &str) -> io::Result<()> {
|
||||
}
|
||||
|
||||
fn main() -> io::Result<()> {
|
||||
let manifest_dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
println!(
|
||||
"cargo:THIRD_PARTY={}",
|
||||
manifest_dir.join("third-party").display()
|
||||
);
|
||||
for (key, value) in DEFINES.iter() {
|
||||
println!("cargo:DEFINE_{}={}", key, value.unwrap_or(""));
|
||||
}
|
||||
#[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);
|
||||
for (key, value) in DEFINES.iter() {
|
||||
build.define(key, *value);
|
||||
}
|
||||
|
||||
build.flag_if_supported("-Wno-return-type-c-linkage");
|
||||
for path in &CPP_FILES {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user