1
0
mirror of https://github.com/CLIUtils/CLI11.git synced 2025-04-29 12:13:52 +00:00
CLI11/scripts/ExtractVersion.py
Daniel Mensinger dbd4933506 meson: Basic meson support (#299)
* meson: Basic meson support

With this patch, CLI11 can be used as a meson
subproject: http://mesonbuild.com/Subprojects.html

However, CMake is still required for testing and
installation. The current meson.build is not a
complete replacement.

* meson: Added meson test

* Adding Azure test
2019-07-25 17:26:13 -04:00

18 lines
507 B
Python
Executable File

#!/usr/bin/env python3
import os
import re
base_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
config_h = os.path.join(base_path, 'include', 'CLI', 'Version.hpp')
data = {'MAJOR': 0, 'MINOR': 0, 'PATCH': 0}
reg = re.compile(r'^\s*#define\s+CLI11_VERSION_([A-Z]+)\s+([0-9]+).*$')
with open(config_h, 'r') as fp:
for l in fp:
m = reg.match(l)
if m:
data[m.group(1)] = int(m.group(2))
print('{}.{}.{}'.format(data['MAJOR'], data['MINOR'], data['PATCH']))