diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2020-05-06 13:12:39 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2020-05-12 10:24:24 -0700 |
commit | f29f3f9f28fbe143e9785ed54f088f004be704cd (patch) | |
tree | 1444f83ded7e8b08d26eb0fd13deb9b06d96f91b /mesonbuild/interpreterbase.py | |
parent | ee790eec2ae7bf335d0b0229474ceabf0cebfcc4 (diff) | |
download | meson-f29f3f9f28fbe143e9785ed54f088f004be704cd.zip meson-f29f3f9f28fbe143e9785ed54f088f004be704cd.tar.gz meson-f29f3f9f28fbe143e9785ed54f088f004be704cd.tar.bz2 |
interpreterbase: Fix version checking for deprecation
Currently deprecation features use the same logic as new features, but
that doesn't work correctly. FeatureNew wants to warn about cases where
you claim to support >= 0.40, but use a feature from 0.42; deprecation
wants to warn when you claim to support >= 0.50, but use a feature that
was replaced in 0.45.
To make this work we need to invert the version check in the deprecation
function, so that if the deprecation is 0.45, and the supported version
is >= 0.50, we get a true not a false.
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r-- | mesonbuild/interpreterbase.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index fc666a6..82d16f1 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -18,6 +18,7 @@ from . import mparser, mesonlib, mlog from . import environment, dependencies +import abc import os, copy, re import collections.abc from functools import wraps @@ -212,7 +213,7 @@ class permittedKwargs: return f(*wrapped_args, **wrapped_kwargs) return wrapped -class FeatureCheckBase: +class FeatureCheckBase(metaclass=abc.ABCMeta): "Base class for feature version checks" # In python 3.6 we can just forward declare this, but in 3.5 we can't @@ -230,13 +231,18 @@ class FeatureCheckBase: return '' return mesonlib.project_meson_versions[subproject] + @staticmethod + @abc.abstractmethod + def check_version(target_version: str, feature_Version: str) -> bool: + pass + def use(self, subproject: str) -> None: tv = self.get_target_version(subproject) # No target version if tv == '': return # Target version is new enough - if mesonlib.version_compare_condition_with_min(tv, self.feature_version): + if self.check_version(tv, self.feature_version): return # Feature is too new for target version, register it if subproject not in self.feature_registry: @@ -288,6 +294,10 @@ class FeatureNew(FeatureCheckBase): feature_registry = {} # type: T.ClassVar[T.Dict[str, T.Dict[str, T.Set[str]]]] @staticmethod + def check_version(target_version: str, feature_version: str) -> bool: + return mesonlib.version_compare_condition_with_min(target_version, feature_version) + + @staticmethod def get_warning_str_prefix(tv: str) -> str: return 'Project specifies a minimum meson_version \'{}\' but uses features which were added in newer versions:'.format(tv) @@ -304,6 +314,11 @@ class FeatureDeprecated(FeatureCheckBase): feature_registry = {} # type: T.ClassVar[T.Dict[str, T.Dict[str, T.Set[str]]]] @staticmethod + def check_version(target_version: str, feature_version: str) -> bool: + # For deprecatoin checks we need to return the inverse of FeatureNew checks + return not mesonlib.version_compare_condition_with_min(target_version, feature_version) + + @staticmethod def get_warning_str_prefix(tv: str) -> str: return 'Deprecated features used:' |