2018-03-02 02:22:44 +00:00
|
|
|
import errno
|
2018-03-01 15:50:29 +00:00
|
|
|
import subprocess
|
2018-03-02 02:22:44 +00:00
|
|
|
try:
|
|
|
|
FileNotFoundError
|
|
|
|
except NameError:
|
|
|
|
FileNotFoundError = OSError
|
2018-03-01 15:50:29 +00:00
|
|
|
try:
|
|
|
|
git_hash = subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=None).decode().strip()
|
|
|
|
definition = '"{}"'.format(git_hash)
|
2018-03-02 02:22:44 +00:00
|
|
|
except FileNotFoundError as e:
|
|
|
|
if e.errno != errno.ENOENT:
|
|
|
|
raise
|
|
|
|
definition = "0"
|
|
|
|
except subprocess.CalledProcessError:
|
2018-03-01 15:50:29 +00:00
|
|
|
definition = "0";
|
|
|
|
print("const char *GIT_SHORTREV_HASH = {};".format(definition))
|