diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2018-08-13 16:33:40 +0100 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2018-09-11 16:30:19 +0100 |
commit | 4df39ca52f7b2222d88cb9c3b00be7bbbb18bdcb (patch) | |
tree | 24bb85fd7cf7937f869abc31596f95724412d3a5 | |
parent | 47d0a13482e98323621192ebc27b74871af81c62 (diff) | |
download | meson-4df39ca52f7b2222d88cb9c3b00be7bbbb18bdcb.zip meson-4df39ca52f7b2222d88cb9c3b00be7bbbb18bdcb.tar.gz meson-4df39ca52f7b2222d88cb9c3b00be7bbbb18bdcb.tar.bz2 |
Re-implement version_compare_condition_with_min likewise
Also remove unused version_compare_with_max
Also remove now unused make_same_len
-rw-r--r-- | mesonbuild/mesonlib.py | 57 |
1 files changed, 3 insertions, 54 deletions
diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 723a81d..1c63f17 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -404,12 +404,6 @@ def grab_leading_numbers(vstr, strict=False): break return result -def make_same_len(listA, listB): - maxlen = max(len(listA), len(listB)) - for i in listA, listB: - for n in range(len(i), maxlen): - i.append(0) - # a helper class which implements the same version ordering as RPM @functools.total_ordering class Version: @@ -505,22 +499,16 @@ def version_compare_many(vstr1, conditions): found.append(req) return not_found == [], not_found, found - +# determine if the minimum version satisfying the condition |condition| exceeds +# the minimum version for a feature |minimum| def version_compare_condition_with_min(condition, minimum): - match = numpart.match(minimum.strip()) - if match is None: - msg = 'Uncomparable version string {!r}.' - raise MesonException(msg.format(minimum)) - minimum = match.group(0) if condition.startswith('>='): cmpop = operator.le condition = condition[2:] elif condition.startswith('<='): return True - condition = condition[2:] elif condition.startswith('!='): return True - condition = condition[2:] elif condition.startswith('=='): cmpop = operator.le condition = condition[2:] @@ -532,48 +520,9 @@ def version_compare_condition_with_min(condition, minimum): condition = condition[1:] elif condition.startswith('<'): return True - condition = condition[2:] else: cmpop = operator.le - varr1 = grab_leading_numbers(minimum, True) - varr2 = grab_leading_numbers(condition, True) - make_same_len(varr1, varr2) - return cmpop(varr1, varr2) - -def version_compare_condition_with_max(condition, maximum): - match = numpart.match(maximum.strip()) - if match is None: - msg = 'Uncomparable version string {!r}.' - raise MesonException(msg.format(maximum)) - maximum = match.group(0) - if condition.startswith('>='): - return False - condition = condition[2:] - elif condition.startswith('<='): - cmpop = operator.ge - condition = condition[2:] - elif condition.startswith('!='): - return False - condition = condition[2:] - elif condition.startswith('=='): - cmpop = operator.ge - condition = condition[2:] - elif condition.startswith('='): - cmpop = operator.ge - condition = condition[1:] - elif condition.startswith('>'): - return False - condition = condition[1:] - elif condition.startswith('<'): - cmpop = operator.gt - condition = condition[2:] - else: - cmpop = operator.ge - varr1 = grab_leading_numbers(maximum, True) - varr2 = grab_leading_numbers(condition, True) - make_same_len(varr1, varr2) - return cmpop(varr1, varr2) - + return cmpop(Version(minimum), Version(condition)) def default_libdir(): if is_debianlike(): |