Merge pull request #339 from aloucks/export_include

Expose include path and native defines via `DEP_` env variables
This commit is contained in:
Joonas Javanainen 2020-07-07 22:49:25 +03:00 committed by GitHub
commit 4981ff5943
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 5 deletions

View File

@ -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"

View File

@ -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 {