summaryrefslogtreecommitdiff
path: root/src/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/build.rs')
-rw-r--r--src/build.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/build.rs b/src/build.rs
new file mode 100644
index 0000000..3fcea82
--- /dev/null
+++ b/src/build.rs
@@ -0,0 +1,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(())
+}