Skip to content

Commit 38e085a

Browse files
committed
Wip, add more project information
1 parent 541bd7f commit 38e085a

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

src/buildstream/_frontend/inspect.py

Lines changed: 47 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
from dataclasses import dataclass, fields, is_dataclass
44
from enum import StrEnum
55

6+
from .._project import ProjectConfig as _BsProjectConfig
7+
from .._pluginfactory.pluginorigin import PluginType
8+
from .._options import OptionPool
69
from ..types import _PipelineSelection, _Scope
10+
from ..node import MappingNode
711

812

913
# Inspectable Elements as serialized to the terminal
@@ -62,18 +66,25 @@ class _UserConfig:
6266
@dataclass
6367
class _Plugin:
6468
name: str
65-
full: str # class str
69+
description: str
70+
plugin_type: PluginType
6671

6772

6873
# Configuration of a given project
6974
@dataclass
7075
class _ProjectConfig:
7176
name: str
7277
directory: str | None
78+
# Original configuration from the project.conf
79+
original: dict[str, any]
7380
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]
7788

7889

7990
# A single project loaded from the current configuration
@@ -197,6 +208,11 @@ def _dump_dataclass(_cls):
197208
return d
198209

199210

211+
def _dump_option_pool(options: OptionPool):
212+
opts = dict()
213+
return options.export_variables(opts)
214+
215+
200216
# Inspect elements from a given Buildstream project
201217
class Inspector:
202218
def __init__(self, stream, project, context):
@@ -300,20 +316,37 @@ def _elements(self, dependencies, with_state=False):
300316
def _get_projects(self) -> [_Project]:
301317
projects = []
302318
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+
305339
project_config = _make_dataclass(
306340
wrapper.project,
307341
_ProjectConfig,
308342
["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,
317350
)
318351
projects.append(
319352
_make_dataclass(

tests/frontend/inspect/elements/import-local-files.bst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ kind: import
22
sources:
33
- kind: local
44
path: files
5+
config:
6+
target: /

tests/frontend/inspect/project.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@ name: test
33
min-version: 2.0
44
element-path: elements
55

6+
variables:
7+
schema: https
8+
69
aliases:
7-
example: https://example.org/
10+
example: "%{schema}://example.org/"

0 commit comments

Comments
 (0)