diff options
author | Axel Waggershauser <awagger@gmail.com> | 2015-02-11 00:17:30 +0100 |
---|---|---|
committer | Axel Waggershauser <awagger@gmail.com> | 2015-02-11 00:17:30 +0100 |
commit | bc4b28b06932cb05270345ecb5e686c6c53dd611 (patch) | |
tree | 310ea92700de4062498617376f54de34d4406fd8 /mesonlib.py | |
parent | 129bb902bc94547c3a2a8e4ff29ee91c8d5fc427 (diff) | |
parent | 57e74de3aea47a361cfb358bfbb78dbda5866109 (diff) | |
download | meson-bc4b28b06932cb05270345ecb5e686c6c53dd611.zip meson-bc4b28b06932cb05270345ecb5e686c6c53dd611.tar.gz meson-bc4b28b06932cb05270345ecb5e686c6c53dd611.tar.bz2 |
tracked upstream (mostly new vcs_tag)
Diffstat (limited to 'mesonlib.py')
-rw-r--r-- | mesonlib.py | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/mesonlib.py b/mesonlib.py index c30057e..7e15770 100644 --- a/mesonlib.py +++ b/mesonlib.py @@ -14,7 +14,7 @@ """A library of random helper functionality.""" -import platform, subprocess +import platform, subprocess, operator def is_osx(): return platform.system().lower() == 'darwin' @@ -41,3 +41,31 @@ def exe_exists(arglist): except FileNotFoundError: pass return False + +def version_compare(vstr1, vstr2): + if vstr2.startswith('>='): + cmpop = operator.ge + vstr2 = vstr2[2:] + elif vstr2.startswith('<='): + cmpop = operator.le + vstr2 = vstr2[2:] + elif vstr2.startswith('!='): + cmpop = operator.ne + vstr2 = vstr2[2:] + elif vstr2.startswith('=='): + cmpop = operator.eq + vstr2 = vstr2[2:] + elif vstr2.startswith('='): + cmpop = operator.eq + vstr2 = vstr2[1:] + elif vstr2.startswith('>'): + cmpop = operator.gt + vstr2 = vstr2[1:] + elif vstr2.startswith('<'): + cmpop = operator.lt + vstr2 = vstr2[1:] + else: + cmpop = operator.eq + varr1 = [int(x) for x in vstr1.split('.')] + varr2 = [int(x) for x in vstr2.split('.')] + return cmpop(varr1, varr2) |