diff --git a/repl/build.rs b/repl/build.rs new file mode 100644 index 0000000000..2b30553805 --- /dev/null +++ b/repl/build.rs @@ -0,0 +1,9 @@ +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(); + println!("cargo:rustc-env=GIT_HASH={}", git_hash); + // This is the closest thing to making sure we rebuild this every time a new commit is made + println!("cargo:rerun-if-changed=../.git/COMMIT_EDITMSG"); +} \ No newline at end of file diff --git a/repl/src/main.rs b/repl/src/main.rs index b4dd0403fa..5cac8200b0 100644 --- a/repl/src/main.rs +++ b/repl/src/main.rs @@ -88,10 +88,15 @@ fn fmt_stdio() -> Result<()> { } fn run() -> std::result::Result<(), Box> { - const GLUON_VERSION: &'static str = env!("CARGO_PKG_VERSION"); let matches = clap_app!(gluon => - (version: GLUON_VERSION) + (version: crate_version!()) + (long_version: + concat!( + crate_version!(), "\n", + "commit: ", env!("GIT_HASH") + ) + ) (about: "executes gluon programs") (@arg REPL: -i --interactive "Starts the repl") (@subcommand fmt =>