|
3 | 3 | from dataclasses import dataclass, fields, is_dataclass |
4 | 4 | from enum import StrEnum |
5 | 5 |
|
| 6 | +from .._project import ProjectConfig as _BsProjectConfig |
| 7 | +from .._pluginfactory.pluginorigin import PluginType |
| 8 | +from .._options import OptionPool |
6 | 9 | from ..types import _PipelineSelection, _Scope |
| 10 | +from ..node import MappingNode |
7 | 11 |
|
8 | 12 |
|
9 | 13 | # Inspectable Elements as serialized to the terminal |
@@ -62,18 +66,25 @@ class _UserConfig: |
62 | 66 | @dataclass |
63 | 67 | class _Plugin: |
64 | 68 | name: str |
65 | | - full: str # class str |
| 69 | + description: str |
| 70 | + plugin_type: PluginType |
66 | 71 |
|
67 | 72 |
|
68 | 73 | # Configuration of a given project |
69 | 74 | @dataclass |
70 | 75 | class _ProjectConfig: |
71 | 76 | name: str |
72 | 77 | directory: str | None |
| 78 | + # Original configuration from the project.conf |
| 79 | + original: dict[str, any] |
73 | 80 | junction: str | None |
74 | | - variables: [(str, str)] |
75 | | - element_plugins: [_Plugin] |
76 | | - source_plugins: [_Plugin] |
| 81 | + # Interpolated options |
| 82 | + options: [(str, str)] |
| 83 | + aliases: dict[str, str] |
| 84 | + element_overrides: any |
| 85 | + source_overrides: any |
| 86 | + # plugin information |
| 87 | + plugins: [_Plugin] |
77 | 88 |
|
78 | 89 |
|
79 | 90 | # A single project loaded from the current configuration |
@@ -197,6 +208,11 @@ def _dump_dataclass(_cls): |
197 | 208 | return d |
198 | 209 |
|
199 | 210 |
|
| 211 | +def _dump_option_pool(options: OptionPool): |
| 212 | + opts = dict() |
| 213 | + return options.export_variables(opts) |
| 214 | + |
| 215 | + |
200 | 216 | # Inspect elements from a given Buildstream project |
201 | 217 | class Inspector: |
202 | 218 | def __init__(self, stream, project, context): |
@@ -300,20 +316,37 @@ def _elements(self, dependencies, with_state=False): |
300 | 316 | def _get_projects(self) -> [_Project]: |
301 | 317 | projects = [] |
302 | 318 | for wrapper in self.project.loaded_projects(): |
303 | | - variables = dict() |
304 | | - wrapper.project.options.printable_variables(variables) |
| 319 | + plugins = [] |
| 320 | + plugins.extend( |
| 321 | + [ |
| 322 | + _Plugin(name=plugin[0], description=plugin[3], plugin_type=PluginType.ELEMENT.value) |
| 323 | + for plugin in wrapper.project.element_factory.list_plugins() |
| 324 | + ] |
| 325 | + ) |
| 326 | + plugins.extend( |
| 327 | + [ |
| 328 | + _Plugin(name=plugin[0], description=plugin[3], plugin_type=PluginType.SOURCE.value) |
| 329 | + for plugin in wrapper.project.source_factory.list_plugins() |
| 330 | + ] |
| 331 | + ) |
| 332 | + plugins.extend( |
| 333 | + [ |
| 334 | + _Plugin(name=plugin[0], description=plugin[3], plugin_type=PluginType.SOURCE_MIRROR.value) |
| 335 | + for plugin in wrapper.project.source_factory.list_plugins() |
| 336 | + ] |
| 337 | + ) |
| 338 | + |
305 | 339 | project_config = _make_dataclass( |
306 | 340 | wrapper.project, |
307 | 341 | _ProjectConfig, |
308 | 342 | ["name", "directory"], |
309 | | - variables=variables, |
310 | | - junction=lambda config: None if not config.junction else config.junction._get_full_name(), |
311 | | - element_plugins=lambda config: [ |
312 | | - _Plugin(name=plugin[0], full=str(plugin[1])) for plugin in config.element_factory.list_plugins() |
313 | | - ], |
314 | | - source_plugins=lambda config: [ |
315 | | - _Plugin(name=plugin[0], full=str(plugin[1])) for plugin in config.source_factory.list_plugins() |
316 | | - ], |
| 343 | + options=lambda project: _dump_option_pool(project.options), |
| 344 | + original=lambda project: project._project_conf.strip_node_info(), |
| 345 | + aliases=lambda project: project.config._aliases.strip_node_info(), |
| 346 | + source_overrides=lambda project: project.source_overrides.strip_node_info(), |
| 347 | + element_overrides=lambda project: project.element_overrides.strip_node_info(), |
| 348 | + junction=lambda project: None if not project.junction else project.junction._get_full_name(), |
| 349 | + plugins=plugins, |
317 | 350 | ) |
318 | 351 | projects.append( |
319 | 352 | _make_dataclass( |
|
0 commit comments