2019-11-23 17:08:52 +00:00
|
|
|
use std::env;
|
|
|
|
use std::fs::File;
|
|
|
|
use std::path::Path;
|
2020-10-25 02:07:28 +00:00
|
|
|
use std::process::Command;
|
|
|
|
|
|
|
|
use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry};
|
2019-11-23 17:08:52 +00:00
|
|
|
|
2019-05-03 23:48:25 +00:00
|
|
|
fn main() {
|
2021-08-18 09:36:51 +00:00
|
|
|
let mut version = String::from(env!("CARGO_PKG_VERSION"));
|
|
|
|
if let Some(commit_hash) = commit_hash() {
|
2023-02-02 08:30:23 +00:00
|
|
|
version = format!("{version} ({commit_hash})");
|
2021-08-18 09:36:51 +00:00
|
|
|
}
|
2023-02-02 08:30:23 +00:00
|
|
|
println!("cargo:rustc-env=VERSION={version}");
|
2019-11-23 17:08:52 +00:00
|
|
|
|
|
|
|
let dest = env::var("OUT_DIR").unwrap();
|
2022-10-12 04:40:46 +00:00
|
|
|
let mut file = File::create(Path::new(&dest).join("gl_bindings.rs")).unwrap();
|
2019-11-23 17:08:52 +00:00
|
|
|
|
2023-05-21 01:06:15 +00:00
|
|
|
Registry::new(Api::Gl, (3, 3), Profile::Core, Fallbacks::All, [
|
|
|
|
"GL_ARB_blend_func_extended",
|
|
|
|
"GL_KHR_debug",
|
|
|
|
])
|
|
|
|
.write_bindings(GlobalGenerator, &mut file)
|
|
|
|
.unwrap();
|
2019-11-30 06:11:43 +00:00
|
|
|
|
|
|
|
#[cfg(windows)]
|
2023-10-08 03:29:57 +00:00
|
|
|
embed_resource::compile("./windows/alacritty.rc", embed_resource::NONE);
|
2019-05-03 23:48:25 +00:00
|
|
|
}
|
2020-10-25 02:07:28 +00:00
|
|
|
|
2021-08-18 09:36:51 +00:00
|
|
|
fn commit_hash() -> Option<String> {
|
2020-10-25 02:07:28 +00:00
|
|
|
Command::new("git")
|
2022-10-12 04:40:46 +00:00
|
|
|
.args(["rev-parse", "--short", "HEAD"])
|
2020-10-25 02:07:28 +00:00
|
|
|
.output()
|
|
|
|
.ok()
|
2022-02-22 13:08:49 +00:00
|
|
|
.filter(|output| output.status.success())
|
2020-10-25 02:07:28 +00:00
|
|
|
.and_then(|output| String::from_utf8(output.stdout).ok())
|
2021-08-18 09:36:51 +00:00
|
|
|
.map(|hash| hash.trim().into())
|
2020-10-25 02:07:28 +00:00
|
|
|
}
|