diff options
author | Damien George <damien@micropython.org> | 2022-10-27 12:57:10 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2022-10-27 13:00:48 +1100 |
commit | c138e10fbb60981ca9e9b7459e7b9ae0c2528c94 (patch) | |
tree | 9ac04da1da52847ec6b8be8052d87795b0be8385 /py/makeversionhdr.py | |
parent | 11910e2fa1c8f5dc76cbc90598ff81526d1f6312 (diff) |
py/makeversionhdr: Fall back to py/mpconfig.h instead of docs/conf.py.
Commit 64af916c111b61bce82c00f356a6b1cb81946d87 removed the version string
from docs/conf.py. py/mpconfig.h is a better place to get the version
from, so use that (when there is no git repository).
Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/makeversionhdr.py')
-rw-r--r-- | py/makeversionhdr.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py index 54b7fa9ab..d1b41e63b 100644 --- a/py/makeversionhdr.py +++ b/py/makeversionhdr.py @@ -62,21 +62,27 @@ def get_version_info_from_git(): return git_tag, git_hash -def get_version_info_from_docs_conf(): - with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "docs", "conf.py")) as f: +def get_version_info_from_mpconfig(): + with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "py", "mpconfig.h")) as f: for line in f: - if line.startswith("version = release = '"): - ver = line.strip().split(" = ")[2].strip("'") - git_tag = "v" + ver + if line.startswith("#define MICROPY_VERSION_MAJOR "): + ver_major = int(line.strip().split()[2]) + elif line.startswith("#define MICROPY_VERSION_MINOR "): + ver_minor = int(line.strip().split()[2]) + elif line.startswith("#define MICROPY_VERSION_MICRO "): + ver_micro = int(line.strip().split()[2]) + git_tag = "v%d.%d" % (ver_major, ver_minor) + if ver_micro != 0: + git_tag += ".%d" % (ver_micro,) return git_tag, "<no hash>" return None def make_version_header(filename): - # Get version info using git, with fallback to docs/conf.py + # Get version info using git, with fallback to py/mpconfig.h info = get_version_info_from_git() if info is None: - info = get_version_info_from_docs_conf() + info = get_version_info_from_mpconfig() git_tag, git_hash = info |