Files
third_party_mesa3d/bin/git_sha1_gen.py
Tobias Klausmann 44828e99f9 build: Don't bail on OSError in git_sha1_gen.py
When building sandboxed, we may encounter additional errors. Ignore the errors,
as we are in a constrained environment.

This can be observed when building latest git with OBS.

Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
2017-08-02 14:28:58 +01:00

24 lines
585 B
Python
Executable File

#!/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'))
except subprocess.CalledProcessError as e:
# don't print anything if git fails
pass
except OSError as eos:
# don't fail on inaccessible files when sandboxed
pass
else:
sys.stdout.write('#define MESA_GIT_SHA1 "git-%s"\n' % git_sha1.rstrip())