diff --git a/.gitignore b/.gitignore index 9e3641e..80893c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /target -/html \ No newline at end of file +/html +/src/version.rs diff --git a/build.sh b/build.sh index b6448a9..ddb1b3e 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,12 @@ #!/bin/sh +rm webTemplate-* + +version="$(cat Cargo.toml | grep '^version' | sed -e 's/^.*"\([^"]*\)".*$/\1/')" +commit="$(git show --oneline -s | sed -e 's/ .*$//')" +dirty="$(test "$(git diff --shortstat 2> /dev/null | tail -n1)" == "" || echo -n "_drity" )" +echo "pub const VERSION: &'static str = \"${version} (${commit}${dirty})\";" >src/version.rs + cross build --target aarch64-unknown-linux-gnu --release cargo build --release diff --git a/src/main.rs b/src/main.rs index 0174c30..a14496a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,9 @@ use minijinja::Environment; mod render; use render::{Renderer, IndexItem, build_jinja_env, Template}; +mod version; +use version::VERSION; + const SRC_PATH: &'static str = "./src/"; const OUT_PATH: &'static str = "./html/"; @@ -97,6 +100,10 @@ fn render_index( } } +fn version() { + println!("version: {}", VERSION); +} + fn usage() { println!("webtemplate [--output=