forked from limbonaut/limboai
-
Notifications
You must be signed in to change notification settings - Fork 0
/
limboai_version.py
65 lines (52 loc) · 1.58 KB
/
limboai_version.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Edit the following variables to change version info
major = 1
minor = 3
patch = 0
status = "dev"
doc_branch = "master"
godot_cpp_ref = "godot-4.3-stable"
# Code that generates version header
def _git_hash(short: bool = False):
import subprocess
ret = "unknown"
try:
if short:
cmd = ["git", "rev-parse", "--short", "HEAD"]
else:
cmd = ["git", "rev-parse", "HEAD"]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
ret = proc.communicate()[0].strip().decode("utf-8")
except:
pass
return ret
def _get_version_info():
return {
"major": major,
"minor": minor,
"patch": patch,
"status": status,
"doc_branch": doc_branch,
"git_short_hash": _git_hash(short=True),
"git_hash": _git_hash(short=False),
}
def generate_module_version_header():
version_info = _get_version_info()
f = open("util/limboai_version.gen.h", "w")
f.write(
"""/* THIS FILE IS GENERATED DO NOT EDIT */
#ifndef LIMBOAI_VERSION_GEN_H
#define LIMBOAI_VERSION_GEN_H
#define LIMBOAI_VERSION_MAJOR {major}
#define LIMBOAI_VERSION_MINOR {minor}
#define LIMBOAI_VERSION_PATCH {patch}
#define LIMBOAI_VERSION_STATUS "{status}"
#define LIMBOAI_VERSION_HASH "{git_hash}"
#define LIMBOAI_VERSION_SHORT_HASH "{git_short_hash}"
#define LIMBOAI_VERSION_DOC_BRANCH "{doc_branch}"
#define LIMBOAI_VERSION_DOC_URL "https://limboai.readthedocs.io/en/" LIMBOAI_VERSION_DOC_BRANCH "/"
#endif // LIMBOAI_VERSION_GEN_H
""".format(
**version_info
)
)
f.close()