summaryrefslogtreecommitdiffstats
path: root/bin/git_sha1_gen.py
blob: 97981fbba2476f331d06da7d19c4e85c301476a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import os.path
import subprocess
import sys

git_dir = os.path.join(os.path.dirname(sys.argv[0]), '..', '.git')
try:
    git_sha1 = subprocess.check_output([
        'git',
        '--git-dir=' + git_dir,
        'rev-parse',
        '--short=10',
        'HEAD',
    ], stderr=open(os.devnull, 'w')).decode("ascii")
except:
    # don't print anything if it fails
    pass
else:
    sys.stdout.write('#define MESA_GIT_SHA1 "git-%s"\n' % git_sha1.rstrip())