diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2025-10-22 16:52:08 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2025-12-22 11:58:30 +0100 |
| commit | 9752def1c96eb32dc37c32398a0fe8802392fbc9 (patch) | |
| tree | c43f2d983c6b9273df80d0edf9560d3ab726927d /mesonbuild | |
| parent | bfb5ea6fdbd85568c4ce20e28d4d727b78994938 (diff) | |
| download | meson-9752def1c96eb32dc37c32398a0fe8802392fbc9.tar.gz | |
modules: rust: implement more package accessors
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/modules/rust.py | 35 |
1 files changed, 35 insertions, 0 deletions
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,10 +146,45 @@ 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'}))) def dependency_method(self, state: ModuleState, args: T.List, kwargs: FuncDependency) -> Dependency: |
