4 Generate the contents of the git_sha1.h file.
5 The output of this script goes to stdout.
16 """Try to get the git SHA1 with git rev-parse."""
17 git_dir
= os
.path
.join(os
.path
.dirname(sys
.argv
[0]), '..', '.git')
19 git_sha1
= subprocess
.check_output([
21 '--git-dir=' + git_dir
,
24 ], stderr
=open(os
.devnull
, 'w')).decode("ascii")
26 # don't print anything if it fails
31 git_sha1
= os
.environ
.get('MESA_GIT_SHA1_OVERRIDE', get_git_sha1())[:10]
33 sys
.stdout
.write('#define MESA_GIT_SHA1 "git-%s"\n' % git_sha1
.rstrip())