~saiko/game

afc29faab617b356a42771a6d0a71103fff73b84 — 2xsaiko a month ago 6c2e3c4 master
Read Git commit info
2 files changed, 17 insertions(+), 1 deletions(-)

A build.rs
M src/main.rs
A build.rs => build.rs +10 -0
@@ 0,0 1,10 @@
use std::process::Command;

fn main() {
    let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
    let git_hash = String::from_utf8(output.stdout).unwrap();
    let output = Command::new("git").args(&["branch", "--show-current"]).output().unwrap();
    let branch = String::from_utf8(output.stdout).unwrap();
    println!("cargo:rustc-env=GIT_HASH={}", git_hash);
    println!("cargo:rustc-env=GIT_BRANCH={}", branch);
}

M src/main.rs => src/main.rs +7 -1
@@ 68,6 68,8 @@ mod testui;

const GAME_NAME: &str = "Untitled Game";
const GAME_VERSION: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH");
const GIT_BRANCH: &str = env!("GIT_BRANCH");

fn main() {
    let mut data_dir: Option<Vec<_>> = None;


@@ 125,7 127,11 @@ fn main() {

fn start_game(env: Environment) -> ! {
    let env = Rc::new(env);
    let title = format!("{} v{} {}", GAME_NAME, GAME_VERSION, if cfg!(debug_assertions) { "Debug" } else { "Release" });
    let title = if GIT_BRANCH != "master" {
        format!("{} v{}-{}-g{} {}", GAME_NAME, GAME_VERSION, GIT_BRANCH, &GIT_HASH[..7], if cfg!(debug_assertions) { "Debug" } else { "Release" })
    } else {
        format!("{} v{}-g{} {}", GAME_NAME, GAME_VERSION, &GIT_HASH[..7], if cfg!(debug_assertions) { "Debug" } else { "Release" })
    };

    let mut event_loop = EventLoop::new();
    let display = glium::Display::new(