aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/interpreter
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2023-08-11 09:15:02 -0700
committerDylan Baker <dylan@pnwbakers.com>2023-08-14 09:55:18 -0700
commitcd676e229b3b5d34550a9a39fa41c2d686c48596 (patch)
treecdc82ecca33276b2c780bed94e7c703934554cb8 /mesonbuild/interpreter
parent90ce0841441506e3f409ab59ded1df8f2e6e7363 (diff)
downloadmeson-cd676e229b3b5d34550a9a39fa41c2d686c48596.zip
meson-cd676e229b3b5d34550a9a39fa41c2d686c48596.tar.gz
meson-cd676e229b3b5d34550a9a39fa41c2d686c48596.tar.bz2
interpreter: use typed_kwargs for shared_library(version)
Diffstat (limited to 'mesonbuild/interpreter')
-rw-r--r--mesonbuild/interpreter/kwargs.py9
-rw-r--r--mesonbuild/interpreter/type_checking.py11
2 files changed, 17 insertions, 3 deletions
diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py
index 48e483e..e92f700 100644
--- a/mesonbuild/interpreter/kwargs.py
+++ b/mesonbuild/interpreter/kwargs.py
@@ -338,7 +338,12 @@ class StaticLibrary(_BuildTarget):
pass
-class SharedLibrary(_BuildTarget):
+class _SharedLibMixin(TypedDict):
+
+ version: T.Optional[str]
+
+
+class SharedLibrary(_BuildTarget, _SharedLibMixin):
pass
@@ -346,7 +351,7 @@ class SharedModule(_BuildTarget):
pass
-class Library(_BuildTarget):
+class Library(_BuildTarget, _SharedLibMixin):
"""For library, both_library, and as a base for build_target"""
diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py
index b919d6a..5ae189a 100644
--- a/mesonbuild/interpreter/type_checking.py
+++ b/mesonbuild/interpreter/type_checking.py
@@ -119,6 +119,13 @@ def _lower_strlist(input: T.List[str]) -> T.List[str]:
return [i.lower() for i in input]
+def _validate_shlib_version(val: T.Optional[str]) -> T.Optional[str]:
+ if val is not None and not re.fullmatch(r'[0-9]+(\.[0-9]+){0,2}', val):
+ return (f'Invalid Shared library version "{val}". '
+ 'Must be of the form X.Y.Z where all three are numbers. Y and Z are optional.')
+ return None
+
+
def variables_validator(contents: T.Union[str, T.List[str], T.Dict[str, str]]) -> T.Optional[str]:
if isinstance(contents, str):
contents = [contents]
@@ -527,7 +534,9 @@ STATIC_LIB_KWS = [
# Arguments exclusive to SharedLibrary. These are separated to make integrating
# them into build_target easier
-_EXCLUSIVE_SHARED_LIB_KWS: T.List[KwargInfo] = []
+_EXCLUSIVE_SHARED_LIB_KWS: T.List[KwargInfo] = [
+ KwargInfo('version', (str, NoneType), validator=_validate_shlib_version)
+]
# The total list of arguments used by SharedLibrary
SHARED_LIB_KWS = [