Skip to content

Commit

Permalink
include_str! the release version from a VERSION file
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Mar 29, 2022
1 parent c572bdf commit c6cdf63
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
22.03
18 changes: 5 additions & 13 deletions helix-term/build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
use helix_loader::grammar::{build_grammars, fetch_grammars};
use std::borrow::Cow;
use std::io::Read;
use std::process::Command;

fn main() {
let mut version = String::new();

if std::fs::File::open("../.version")
.and_then(|mut f| f.read_to_string(&mut version))
.is_err()
{
version = "dev".to_string();
}
const VERSION: &str = include_str!("../VERSION");

fn main() {
let git_hash = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
Expand All @@ -21,8 +13,8 @@ fn main() {
.and_then(|x| String::from_utf8(x.stdout).ok());

let version: Cow<_> = match git_hash {
Some(git_hash) => format!("{} ({})", version, &git_hash[..8]).into(),
None => version.into(),
Some(git_hash) => format!("{} ({})", VERSION, &git_hash[..8]).into(),
None => VERSION.into(),
};

if std::env::var("HELIX_DISABLE_AUTO_GRAMMAR_BUILD").is_err() {
Expand All @@ -31,7 +23,7 @@ fn main() {
}

println!("cargo:rerun-if-changed=../runtime/grammars/");
println!("cargo:rerun-if-changed=../.version");
println!("cargo:rerun-if-changed=../VERSION");

println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
}

0 comments on commit c6cdf63

Please sign in to comment.