From 443542bfd30318ddbe3d1c7c029f90386b541347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 16 Dec 2018 17:01:03 +0000 Subject: meson: extract project version from header file and version .so - Extract project version from tinyalsa/version.h for easier maintainability - Version shared lib: tinyalsa.so -> tinyalsa.so.1.1.1 --- version.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 version.py (limited to 'version.py') diff --git a/version.py b/version.py new file mode 100755 index 0000000..892dbdb --- /dev/null +++ b/version.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +# +# tinyalsa version.py: Extracts versions from TINYALSA_VERSION_STRING in +# include/tinyalsa/version.h header file for Meson build. +import os +import sys + +if __name__ == '__main__': + try: + srcroot = os.environ['MESON_SOURCE_ROOT'] + except: + srcroot = os.getcwd() + print('Warning: MESON_SOURCE_ROOT env var not set, assuming source code is in', srcroot, file=sys.stderr) + + # API version + api_version = None + f = open(os.path.join(srcroot, 'include', 'tinyalsa', 'version.h'), 'r') + for line in f: + if line.startswith('#define TINYALSA_VERSION_STRING '): + api_version = line[32:].strip().replace('"', '') + print(api_version) + sys.exit(0) + + print('Warning: Could not extract API version from TINYALSA_VERSION_STRING in include/tinyalsa/version.h in', srcroot, file=sys.stderr) + sys.exit(-1) -- cgit v1.2.3