mirror of
https://github.com/ddnet/ddnet.git
synced 2024-10-30 04:38:18 +00:00
bb086b8393
Use the `DDNET_GIT_SHORTREV_HASH` variable for this. This allows builds that do not use `git` to still have this kind of version information.
13 lines
422 B
Python
13 lines
422 B
Python
import os
|
|
import subprocess
|
|
git_hash = os.environ.get("DDNET_GIT_SHORTREV_HASH")
|
|
try:
|
|
git_hash = git_hash or subprocess.check_output(["git", "rev-parse", "--short=16", "HEAD"], stderr=subprocess.DEVNULL).decode().strip()
|
|
except (FileNotFoundError, subprocess.CalledProcessError):
|
|
pass
|
|
if git_hash is not None:
|
|
definition = f'"{git_hash}"'
|
|
else:
|
|
definition = "0"
|
|
print(f"const char *GIT_SHORTREV_HASH = {definition};")
|