Fix commit header generation on non-Windows platforms.
Previously we relied on a batch file, which for obvious reasons
isn't cross-platform.
BUG=angle:529
Change-Id: Ia1e3944f8ed2096773e68c39d48ae2dd7370897b
Reviewed-on: https://chromium-review.googlesource.com/186974
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/186985
Reviewed-by: Nicolas Capens <nicolascapens@chromium.org>
diff --git a/src/commit_id.py b/src/commit_id.py
new file mode 100644
index 0000000..6339cca
--- /dev/null
+++ b/src/commit_id.py
@@ -0,0 +1,22 @@
+import subprocess as sp
+import sys
+
+def grab_output(*command):
+ return sp.Popen(command, stdout=sp.PIPE).communicate()[0].strip()
+
+commit_id_size = 12
+
+try:
+ commit_id = grab_output('git', 'rev-parse', '--short=%d' % commit_id_size, 'HEAD')
+ commit_date = grab_output('git', 'show', '-s', '--format=%ci', 'HEAD')
+except:
+ commit_id = 'invalid-hash'
+ commit_date = 'invalid-date'
+
+hfile = open(sys.argv[1], 'w')
+
+hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
+hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)
+hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
+
+hfile.close()