-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
37 lines (31 loc) · 1.16 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::env;
use std::fs::File;
use std::path::PathBuf;
use gl_generator::{Api, Fallbacks, Profile, Registry, StructGenerator};
fn main() {
let target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
if target_os == "android" || target_os == "linux" {
#[cfg(feature = "swappy")]
{
if cfg!(feature = "shared-stdcxx"){
_add_lib("c++_shared", false);
}else{
_add_lib("c++_static", false);
}
println!("cargo:rustc-link-search=native={}", "libs/");
println!("cargo:rustc-link-lib=static={}", "swappy");
}
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
let registry = Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, []);
registry.write_bindings(StructGenerator, &mut file).unwrap();
}
}
fn _add_lib(_name: impl AsRef<str>, _static: bool) {
#[cfg(not(feature = "test"))]
println!(
"cargo:rustc-link-lib={}{}",
if _static { "static=" } else { "" },
_name.as_ref()
);
}