summaryrefslogtreecommitdiff
path: root/mesonbuild/modules/__init__.py
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2022-07-14 12:59:48 -0700
committerEli Schwartz <eschwartz93@gmail.com>2022-08-17 16:25:36 -0400
commit6843f56f6b8e71e75c287de31686913eea5e4a44 (patch)
treea92e933d88d48dd2bfd4a1fc2bb652296f053332 /mesonbuild/modules/__init__.py
parent2801ead6d3a144f3cf7ae03f61bb463c7aeac0a9 (diff)
downloadmeson-6843f56f6b8e71e75c287de31686913eea5e4a44.tar.gz
modules: use module level information about new and deprecation
Instead of using FeatureNew/FeatureDeprecated in the module. The goal here is to be able to handle information about modules in a single place, instead of having to handle it separately. Each module simply defines some metadata, and then the interpreter handles the rest.
Diffstat (limited to 'mesonbuild/modules/__init__.py')
-rw-r--r--mesonbuild/modules/__init__.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/mesonbuild/modules/__init__.py b/mesonbuild/modules/__init__.py
index 56370d17f..068194026 100644
--- a/mesonbuild/modules/__init__.py
+++ b/mesonbuild/modules/__init__.py
@@ -15,6 +15,7 @@
# This file contains the base representation for import('modname')
from __future__ import annotations
+import dataclasses
import typing as T
from .. import mesonlib
@@ -163,6 +164,17 @@ class ModuleObject(HoldableObject):
class MutableModuleObject(ModuleObject):
pass
+
+@dataclasses.dataclass
+class ModuleInfo:
+
+ """Metadata about a Module."""
+
+ name: str
+ added: T.Optional[str] = None
+ deprecated: T.Optional[str] = None
+
+
class NewExtensionModule(ModuleObject):
"""Class for modern modules
@@ -170,6 +182,8 @@ class NewExtensionModule(ModuleObject):
provides the found method.
"""
+ INFO: ModuleInfo
+
def __init__(self) -> None:
super().__init__()
self.methods.update({
@@ -203,6 +217,10 @@ class NotFoundExtensionModule(NewExtensionModule):
provides the found method.
"""
+ def __init__(self, name: str) -> None:
+ super().__init__()
+ self.INFO = ModuleInfo(name)
+
@staticmethod
def found() -> bool:
return False