summaryrefslogtreecommitdiffstats
path: root/contrib/meson/GetLz4LibraryVersion.py
diff options
context:
space:
mode:
authorTristan Partin <tristan@partin.io>2022-08-16 07:36:48 (GMT)
committerTristan Partin <tristan@partin.io>2022-10-20 04:27:05 (GMT)
commit198e532300f253ada3acac3ab5428ed991adb085 (patch)
treeb5c04cd31e42772751dac47bc6a0780b581b871d /contrib/meson/GetLz4LibraryVersion.py
parente312412c60140b3d061526499cef22e5e99d7751 (diff)
downloadlz4-198e532300f253ada3acac3ab5428ed991adb085.zip
lz4-198e532300f253ada3acac3ab5428ed991adb085.tar.gz
lz4-198e532300f253ada3acac3ab5428ed991adb085.tar.bz2
Update Meson build to 1.9.4
Specifically this adds support for the following options: - LZ4_ALIGN_TEST - LZ4_STATIC_LINKING_ONLY_DISABLE_MEMORY_ALLOCATION - LZ4_DISTANCE_MAX - LZ4_FAST_DEC_LOOP - LZ4_FORCE_SW_BITCOUNT - LZ4_FREESTANDING - LZ4_USER_MEMORY_FUNCTIONS - compiling ossfuzz targets - compiling more test targets - registering some tests
Diffstat (limited to 'contrib/meson/GetLz4LibraryVersion.py')
-rw-r--r--contrib/meson/GetLz4LibraryVersion.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/contrib/meson/GetLz4LibraryVersion.py b/contrib/meson/GetLz4LibraryVersion.py
new file mode 100644
index 0000000..d8abfcb
--- /dev/null
+++ b/contrib/meson/GetLz4LibraryVersion.py
@@ -0,0 +1,39 @@
+#!/usr/bin/env python3
+# #############################################################################
+# Copyright (c) 2018-present lzutao <taolzu(at)gmail.com>
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# #############################################################################
+import re
+
+
+def find_version_tuple(filepath):
+ version_file_data = None
+ with open(filepath) as fd:
+ version_file_data = fd.read()
+
+ patterns = r"""#\s*define\s+LZ4_VERSION_MAJOR\s+([0-9]+).*$
+#\s*define\s+LZ4_VERSION_MINOR\s+([0-9]+).*$
+#\s*define\s+LZ4_VERSION_RELEASE\s+([0-9]+).*$
+"""
+ regex = re.compile(patterns, re.MULTILINE)
+ version_match = regex.search(version_file_data)
+ if version_match:
+ return version_match.groups()
+ raise Exception("Unable to find version string.")
+
+
+def main():
+ import argparse
+ parser = argparse.ArgumentParser(description='Print lz4 version from lib/lz4.h')
+ parser.add_argument('file', help='path to lib/lz4.h')
+ args = parser.parse_args()
+ version_tuple = find_version_tuple(args.file)
+ print('.'.join(version_tuple))
+
+
+if __name__ == '__main__':
+ main()