From 5a3bf69e3fd771271921f62219cdb8f920db39ee Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Sun, 25 Oct 2020 02:07:28 +0000 Subject: Remove rustc_tools_util dependency Since our usage of the rustc_tools_util crate is so trivial, it seems like we should be able to just inline it directly into Alacritty. It's a very well trusted crate, being hosted directly by rust-lang and it does not pull in any other dependencies, but having a dependency for just 6 lines of code seems a bit extreme. --- alacritty/Cargo.toml | 1 - alacritty/build.rs | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'alacritty') diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml index a8ae5196..905003e5 100644 --- a/alacritty/Cargo.toml +++ b/alacritty/Cargo.toml @@ -32,7 +32,6 @@ unicode-width = "0.1" [build-dependencies] gl_generator = "0.14.0" -rustc_tools_util = "0.2.0" [target.'cfg(not(windows))'.dependencies] xdg = "2" diff --git a/alacritty/build.rs b/alacritty/build.rs index e8e0c114..3c0ec110 100644 --- a/alacritty/build.rs +++ b/alacritty/build.rs @@ -1,12 +1,12 @@ -use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry}; - use std::env; use std::fs::File; use std::path::Path; +use std::process::Command; + +use gl_generator::{Api, Fallbacks, GlobalGenerator, Profile, Registry}; fn main() { - let hash = rustc_tools_util::get_commit_hash().unwrap_or_default(); - println!("cargo:rustc-env=GIT_HASH={}", hash); + println!("cargo:rustc-env=GIT_HASH={}", commit_hash()); let dest = env::var("OUT_DIR").unwrap(); let mut file = File::create(&Path::new(&dest).join("gl_bindings.rs")).unwrap(); @@ -18,3 +18,12 @@ fn main() { #[cfg(windows)] embed_resource::compile("../extra/windows/windows.rc"); } + +fn commit_hash() -> String { + Command::new("git") + .args(&["rev-parse", "--short", "HEAD"]) + .output() + .ok() + .and_then(|output| String::from_utf8(output.stdout).ok()) + .unwrap_or_default() +} -- cgit