aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTaylor Holberton <taylorcholberton@gmail.com>2018-12-17 14:00:34 +0000
committerTaylor Holberton <taylorcholberton@gmail.com>2018-12-17 14:00:34 +0000
commit5d159ccf17b5d5761e3ee79390a207780b537f65 (patch)
tree1383640e95d461db0b475cba8ea878b79761742e /scripts
parenta93316d9de1f65fbe2abb25e63f98d4ce224296b (diff)
Putting version.py in scripts folder
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/version.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/scripts/version.py b/scripts/version.py
new file mode 100755
index 0000000..892dbdb
--- /dev/null
+++ b/scripts/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)