summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/commit_id.py
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /gfx/angle/src/commit_id.py
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'gfx/angle/src/commit_id.py')
-rwxr-xr-xgfx/angle/src/commit_id.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/gfx/angle/src/commit_id.py b/gfx/angle/src/commit_id.py
new file mode 100755
index 000000000..bbdb810ce
--- /dev/null
+++ b/gfx/angle/src/commit_id.py
@@ -0,0 +1,42 @@
+import subprocess as sp
+import sys
+import os
+
+usage = """\
+Usage: commit_id.py check <angle_dir> - check if git is present
+ commit_id.py gen <angle_dir> <file_to_write> - generate commit.h"""
+
+def grab_output(command, cwd):
+ return sp.Popen(command, stdout=sp.PIPE, shell=True, cwd=cwd).communicate()[0].strip()
+
+if len(sys.argv) < 3:
+ sys.exit(usage)
+
+operation = sys.argv[1]
+cwd = sys.argv[2]
+
+if operation == 'check':
+ index_path = os.path.join(cwd, '.git', 'index')
+ if os.path.exists(index_path):
+ print("1")
+ else:
+ print("0")
+ sys.exit(0)
+
+output_file = sys.argv[3]
+commit_id_size = 12
+
+try:
+ commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd)
+ commit_date = grab_output('git show -s --format=%ci HEAD', cwd)
+except:
+ commit_id = 'invalid-hash'
+ commit_date = 'invalid-date'
+
+hfile = open(output_file, '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()