spdlog/scripts/extract_version.py

18 lines
497 B
Python
Raw Normal View History

2019-06-30 22:48:20 +08:00
#!/usr/bin/env python3
import os
import re
2019-07-01 18:37:18 +08:00
base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
2021-04-08 14:56:01 +08:00
config_h = os.path.join(base_path, 'include', 'spdlog', 'version.h')
data = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0}
reg = re.compile(r'^\s*#define\s+SPDLOG_VER_([A-Z]+)\s+([0-9]+).*$')
2019-06-30 22:48:20 +08:00
with open(config_h, 'r') as fp:
2021-04-08 14:56:01 +08:00
for l in fp:
m = reg.match(l)
if m:
data[m.group(1)] = int(m.group(2))
2019-06-30 22:48:20 +08:00
2021-04-08 14:56:01 +08:00
print(f"{data['MAJOR']}.{data['MINOR']}.{data['PATCH']}")