blob: 6339cca3f2cc546160322828464732b91d9fa9bb [file] [log] [blame]
Jamie Madill42f529e2014-02-24 12:45:32 -05001import subprocess as sp
2import sys
3
4def grab_output(*command):
5 return sp.Popen(command, stdout=sp.PIPE).communicate()[0].strip()
6
7commit_id_size = 12
8
9try:
10 commit_id = grab_output('git', 'rev-parse', '--short=%d' % commit_id_size, 'HEAD')
11 commit_date = grab_output('git', 'show', '-s', '--format=%ci', 'HEAD')
12except:
13 commit_id = 'invalid-hash'
14 commit_date = 'invalid-date'
15
16hfile = open(sys.argv[1], 'w')
17
18hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
19hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)
20hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
21
22hfile.close()