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 git_sha1_h_in_path
= os
.path
.join(os
.path
.dirname(sys
.argv
[0]),
34 '..', 'src', 'git_sha1.h.in')
35 with
open(git_sha1_h_in_path
, 'r') as git_sha1_h_in
:
36 sys
.stdout
.write(git_sha1_h_in
.read().replace('@VCS_TAG@', git_sha1
))