diff options
author | Lzu Tao <taolzu@gmail.com> | 2018-12-01 05:15:53 (GMT) |
---|---|---|
committer | Lzu Tao <taolzu@gmail.com> | 2018-12-02 03:00:27 (GMT) |
commit | 5bc119455fde697f132adbd7fd50f095954f703b (patch) | |
tree | d4b4bcffae99a9f793c735f9e59c8a452806c95b /contrib/meson/GetLz4LibraryVersion.py | |
parent | 6689dae33ba1eb588abe3d3cb763bc5dc08878b3 (diff) | |
download | lz4-5bc119455fde697f132adbd7fd50f095954f703b.zip lz4-5bc119455fde697f132adbd7fd50f095954f703b.tar.gz lz4-5bc119455fde697f132adbd7fd50f095954f703b.tar.bz2 |
Add meson build system
Diffstat (limited to 'contrib/meson/GetLz4LibraryVersion.py')
-rw-r--r-- | contrib/meson/GetLz4LibraryVersion.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/contrib/meson/GetLz4LibraryVersion.py b/contrib/meson/GetLz4LibraryVersion.py new file mode 100644 index 0000000..e929f95 --- /dev/null +++ b/contrib/meson/GetLz4LibraryVersion.py @@ -0,0 +1,45 @@ +#!/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 +import sys + + +def usage(): + print('usage: python3 GetLz4LibraryVersion.py <path/to/lz4.h>') + sys.exit(1) + + +def find_version(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(): + if len(sys.argv) < 2: + usage() + + filepath = sys.argv[1] + version_tup = find_version(filepath) + print('.'.join(version_tup)) + + +if __name__ == '__main__': + main() |