summaryrefslogtreecommitdiff
path: root/src/build.rs
blob: 3fcea82606857eb2d96645a8691ab2eea8c0e6c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use std::process::Command;
use ructe::{Ructe, RucteError};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut ructe = Ructe::from_env()?;
    let mut statics = ructe.statics()?;
    statics.add_files("statics")?;
    ructe.compile_templates("templates")?;

    let output = Command::new("git")
        .args(&["rev-parse", "HEAD"])
        .output()
        .unwrap();

    let out = std::env::var("out").unwrap_or("/fake".into());
    println!("cargo:rustc-env=out={}", out);

    let git_hash = String::from_utf8(output.stdout).unwrap();
    println!(
        "cargo:rustc-env=GIT_SHA={}",
        if git_hash.as_str() == "" {
            out.into()
        } else {
            git_hash
        }
    );
    Ok(())
}