From 9752def1c96eb32dc37c32398a0fe8802392fbc9 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Wed, 22 Oct 2025 16:52:08 +0200 Subject: modules: rust: implement more package accessors Signed-off-by: Paolo Bonzini --- mesonbuild/modules/rust.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'mesonbuild/modules') diff --git a/mesonbuild/modules/rust.py b/mesonbuild/modules/rust.py index 4c61b7e31..29d1b1fbb 100644 --- a/mesonbuild/modules/rust.py +++ b/mesonbuild/modules/rust.py @@ -146,9 +146,44 @@ class RustSubproject(ModuleObject): self.rust_ws = rust_ws self.package = package self.methods.update({ + 'all_features': self.all_features_method, + 'api': self.api_method, 'dependency': self.dependency_method, + 'features': self.features_method, + 'name': self.name_method, + 'version': self.version_method, }) + @noPosargs + @noKwargs + def name_method(self, state: ModuleState, args: T.List, kwargs: TYPE_kwargs) -> str: + """Returns the name of the package.""" + return self.package.manifest.package.name + + @noPosargs + @noKwargs + def api_method(self, state: ModuleState, args: T.List, kwargs: TYPE_kwargs) -> str: + """Returns the API version of the package.""" + return self.package.manifest.package.api + + @noPosargs + @noKwargs + def version_method(self, state: ModuleState, args: T.List, kwargs: TYPE_kwargs) -> str: + """Returns the version of the package.""" + return self.package.manifest.package.version + + @noPosargs + @noKwargs + def all_features_method(self, state: ModuleState, args: T.List, kwargs: TYPE_kwargs) -> T.List[str]: + """Returns all features for specific package.""" + return sorted(list(self.package.manifest.features.keys())) + + @noPosargs + @noKwargs + def features_method(self, state: ModuleState, args: T.List, kwargs: TYPE_kwargs) -> T.List[str]: + """Returns chosen features for specific package.""" + return sorted(list(self.package.cfg.features)) + @noPosargs @typed_kwargs('package.dependency', KwargInfo('rust_abi', (str, NoneType), default=None, validator=in_set_validator({'rust', 'c', 'proc-macro'}))) -- cgit v1.2.3