-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
build.rs
43 lines (38 loc) · 1.67 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
38
39
40
41
42
43
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use gl_generator::{Api, Fallbacks, Profile, Registry};
use std::env;
use std::fs::File;
use std::path::PathBuf;
fn main() {
let target = env::var("TARGET").unwrap();
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
// Generate GL bindings
// For now, we only support EGL, and only on Windows and Android.
if target.contains("android") || target.contains("windows") {
let mut file = File::create(&dest.join("egl_bindings.rs")).unwrap();
Registry::new(Api::Egl, (1, 5), Profile::Core, Fallbacks::All, [])
.write_bindings(gl_generator::StaticStructGenerator, &mut file)
.unwrap();
// Historically, Android builds have succeeded with rust-link-lib=EGL.
// On Windows when relying on %LIBS% to contain libEGL.lib, however,
// we must explicitly use rustc-link-lib=libEGL or rustc will attempt
// to link EGL.lib instead.
if target.contains("windows") {
println!("cargo:rustc-link-lib=libEGL");
} else {
println!("cargo:rust-link-lib=EGL");
}
}
if target.contains("linux") ||
target.contains("dragonfly") ||
target.contains("freebsd") ||
target.contains("openbsd")
{
let mut file = File::create(&dest.join("glx_bindings.rs")).unwrap();
Registry::new(Api::Glx, (1, 4), Profile::Core, Fallbacks::All, [])
.write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap();
}
}