summaryrefslogtreecommitdiff
path: root/wscript
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-20 13:59:07 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-20 13:59:07 +0100
commit7aaf59faf8bb0ff85a2f76f6569076790a124813 (patch)
treef35c23fe5cbe709ffeea4584c9420795ef89ca5b /wscript
parentd92919284b25526581f5a3f461f1e06106b91a09 (diff)
Give access to git revision, and make test mode accessible.
Diffstat (limited to 'wscript')
-rw-r--r--wscript21
1 files changed, 21 insertions, 0 deletions
diff --git a/wscript b/wscript
index c1538ceb..b70a8e2d 100644
--- a/wscript
+++ b/wscript
@@ -1,3 +1,5 @@
+import subprocess
+
APPNAME = 'libdcp'
VERSION = '0.03pre'
@@ -25,6 +27,8 @@ def configure(conf):
conf.recurse('asdcplib')
def build(bld):
+ create_stored_commit()
+
bld(source = 'libdcp.pc.in',
version = VERSION,
includedir = '%s/include' % bld.env.PREFIX,
@@ -37,3 +41,20 @@ def build(bld):
def dist(ctx):
ctx.excl = 'TODO core *~ .git build .waf* .lock* doc/*~ src/*~ test/ref/*~'
+
+def create_stored_commit():
+ cmd = "LANG= git log --abbrev HEAD^..HEAD ."
+ output = subprocess.Popen(cmd, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE).communicate()[0].splitlines()
+ o = output[0].decode('utf-8')
+ commit = o.replace ("commit ", "")[0:10]
+
+ try:
+ text = '#include "git_commit.h"\n'
+ text += 'char const * libdcp::git_commit = \"%s\";\n' % commit
+ print('Writing git commit info to src/git_commit.cc')
+ o = open('src/git_commit.cc', 'w')
+ o.write(text)
+ o.close()
+ except IOError:
+ print('Could not open src/git_commit.cc for writing\n')
+ sys.exit(-1)