Commits

Anonymous committed 5003d2a

versioning information

Comments (0)

Files changed (3)

 
 all:: build/unihistext
 
-build/unihistext: src/unihistext src/make-wrapper.sh src/gzip-wrapper.sh
+build/unihistext: src/unihistext src/make-wrapper.sh src/gzip-wrapper.sh src/version.py
 	mkdir -p `dirname $@`
-	{ cd src && ./make-wrapper.sh unihistext; } > $@
+	{ cd src && ./make-wrapper.sh unihistext version.py; } > $@
 	chmod +x $@
 
+src/version.py:
+	{ echo "version = \"unknown\""; cd src && ./version-gen.sh | sed -e "s/^.*\$$/version = \"&\"/"; } > $@
+.PHONY: src/version.py
+
 clean:
-	rm -rf build $(shell find -name '*~' | grep -v .git )
+	rm -rf build $(shell find -name '*~' | grep -v .git ) src/version.py
 import unicodedata
 from itertools import imap
 import codecs
+from version import version
 
 def unicode_xreadlines(input, encoding = 'utf-8'):
     return codecs.iterdecode(input.xreadlines(), encoding=encoding)
     print
 
 def print_version():
-    print os.path.basename(sys.argv[0]) + " v0.1"
+    print os.path.basename(sys.argv[0]) + " version " + version
     print "Supported Unicode version: " + unicodedata.unidata_version
 
 def is_combining(unichr, more_combinings = (unicodedata.lookup('zero width joiner'), unicodedata.lookup('zero width non-joiner'))):

src/version-gen.sh

+#!/bin/bash
+
+git describe 2>/dev/null | grep -qE . || exit 1
+ver=`git describe`
+
+git update-index -q --refresh
+test -z "$(git diff-index --name-only HEAD --)" || ver="$ver-dirty"
+ver=$(echo "$ver" | sed -e 's/-/./g' | sed -e 's/^v//');
+echo $ver