diff options
author | Salamandar <felix@piedallu.me> | 2018-04-26 17:12:45 +0200 |
---|---|---|
committer | Salamandar <felix@piedallu.me> | 2018-06-01 14:23:24 +0200 |
commit | 806ab181f24acab8aa825cf844adbd964cedbe29 (patch) | |
tree | 493cc03093a6c3cd792a400ea4d687dca564fc22 /mesonbuild/interpreterbase.py | |
parent | ae19fec9528c0e3ff764eca271227c670284909a (diff) | |
download | meson-806ab181f24acab8aa825cf844adbd964cedbe29.zip meson-806ab181f24acab8aa825cf844adbd964cedbe29.tar.gz meson-806ab181f24acab8aa825cf844adbd964cedbe29.tar.bz2 |
Split function wrapper from a use() method
Diffstat (limited to 'mesonbuild/interpreterbase.py')
-rw-r--r-- | mesonbuild/interpreterbase.py | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 00cb9dd..126e5b8 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -143,17 +143,20 @@ class FeatureNew: for version in sorted(FeatureNew.min_feature_versions.keys()): print('{}: {}'.format(version, FeatureNew.min_feature_versions[version])) + def use(self): + self.add_called_feature() + tv = coredata.target_version + if tv == '': + return + if not mesonlib.version_compare_condition_with_min(tv, self.feature_version): + mlog.error( + '''Project targetting \'{}\' but tried to use feature introduced in \'{}\': {}''' + .format(tv, self.feature_version, self.feature_name)) + def __call__(self, f): @wraps(f) def wrapped(*wrapped_args, **wrapped_kwargs): - self.add_called_feature() - tv = coredata.target_version - if tv == '': - return - if not mesonlib.version_compare_condition_with_min(tv, self.feature_version): - mlog.error( - '''Project targetting \'{}\' but tried to use feature introduced in \'{}\': {}''' - .format(tv, self.feature_version, self.feature_name)) + self.use() return f(*wrapped_args, **wrapped_kwargs) return wrapped @@ -176,18 +179,20 @@ class FeatureDeprecated: for version in sorted(FeatureDeprecated.max_feature_versions.keys()): print('{}: {}'.format(version, FeatureDeprecated.max_feature_versions[version])) + def use(self): + self.add_called_feature() + tv = coredata.target_version + if tv == '': + return + if not mesonlib.version_compare_condition_with_max(tv, self.feature_version): + mlog.error( + '''Project targetting \'{}\' but tried to use feature deprecated since \'{}\': {}''' + .format(tv, self.feature_version, self.feature_name)) + def __call__(self, f): @wraps(f) def wrapped(*wrapped_args, **wrapped_kwargs): - print('deprecated:', self.feature_name, self.feature_version) - self.add_called_feature() - tv = coredata.target_version - if tv == '': - return - if not mesonlib.version_compare_condition_with_max(tv, self.feature_version): - mlog.error( - '''Project targetting \'{}\' but tried to use feature deprecated since \'{}\': {}''' - .format(tv, self.feature_version, self.feature_name)) + self.use() return f(*wrapped_args, **wrapped_kwargs) return wrapped |