diff options
| author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-02-08 15:22:21 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-02-08 15:22:21 +0200 |
| commit | cd757db89964bd39f6aeaa3763b216f14dc03c9e (patch) | |
| tree | 7c77e7d874c593a96c413bda0a09396b83eff6fe /mesonlib.py | |
| parent | 526c86d92fcd53edbb216983acee297c79172c99 (diff) | |
| download | meson-cd757db89964bd39f6aeaa3763b216f14dc03c9e.tar.gz | |
Can specify version requirements to dependencies.
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 c30057e29..7e1577047 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) |
