Skip to content

Commit c4a6ee4

Browse files
authored
Merge pull request #632 from jkloetzke/list-layers
List layers command
2 parents 13cef3b + 4f2a07f commit c4a6ee4

File tree

23 files changed

+283
-73
lines changed

23 files changed

+283
-73
lines changed

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def __getattr__(cls, name):
6161

6262
# General information about the project.
6363
project = 'Bob'
64-
copyright = '2016-2024, The BobBuildTool Contributors'
64+
copyright = '2016-2025, The BobBuildTool Contributors'
6565

6666
# The version info for the project you're documenting, acts as replacement for
6767
# |version| and |release|, also used in various other places throughout the

doc/manpages/bob-layers.rst

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Synopsis
1515

1616
::
1717

18+
bob layers update [-h] [-lc LAYERCONFIG] [-D DEFINES]
19+
[--indent INDENT | --no-indent]
20+
[--format {yaml,json,flat}]
1821
bob layers status [-h] [-lc LAYERCONFIG] [-D DEFINES] [--show-clean]
1922
[--show-overrides] [-v]
2023
bob layers update [-h] [-lc LAYERCONFIG] [-D DEFINES]
@@ -23,8 +26,12 @@ Synopsis
2326
Description
2427
-----------
2528

26-
Update layers or show their SCM-status. The following sub-commands are
27-
available:
29+
Update layers or show their status. The following sub-commands are available:
30+
31+
``ls``
32+
List known layers and their properties. There are multiple output formats
33+
available. The output of this command is supposed to stay stable and is
34+
thus suitable for scripting.
2835

2936
``update``
3037
Updates the layers.
@@ -45,6 +52,20 @@ Options
4552
Do not move layer workspace to attic if inline SCM switching is not possible.
4653
Instead a build error is issued.
4754

55+
``--format {yaml,json,flat}``
56+
Selects a different output format. Defaults to ``yaml``. The ``flat`` format
57+
is an INI-style format where each key/value pair is printed on a separate
58+
line.
59+
60+
``--indent INDENT``
61+
The ``yaml`` and ``json`` output formats are pretty printed with an
62+
indentation of 4 spaces by default. Use this option to chance this to
63+
``INDENT`` number of spaces.
64+
65+
``--no-indent``
66+
Disables the pretty printing of the ``yaml`` and ``json`` formats. The
67+
output will be more compact but is less readable.
68+
4869
``-lc LAYERCONFIG``
4970
Use additional layer configuration file.
5071

doc/manual/configuration.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,8 @@ possibility is to provide an SCM-Dictionary (see
21412141

21422142
If a layer SCM specification is given, Bob takes care of the layer management:
21432143

2144-
- Layers are checked out / updated during bob-build (except build-only).
2144+
- Layers are checked out / updated automatically during
2145+
:ref:`manpage-dev`/:ref:`manpage-build` (except ``--build-only`` builds).
21452146
- The ``bob layers`` command can update layers or show their status (see
21462147
:ref:`manpage-layers`).
21472148

@@ -2152,9 +2153,10 @@ If a layer SCM specification is given, Bob takes care of the layer management:
21522153

21532154
Only git, svn, url and cvs SCMs are supported for layers. Because layers are
21542155
fetched and updated before any :ref:`configuration-config-usr` is parsed, the
2155-
regular ``whitelist`` and ``scmOverrides`` settings are not used. Instead,
2156+
regular ``whitelist`` and ``scmOverrides`` settings are not used. Instead,
21562157
layer checkouts are controlled by ``layersWhitelist`` and
2157-
``layersScmOverrides``.
2158+
``layersScmOverrides``. These settings can be optionally overridden from the
2159+
command line by passing a layers configuration file with the ``-lc`` option.
21582160

21592161
layersWhitelist
21602162
~~~~~~~~~~~~~~~

pym/bob/cmds/build/build.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
from ...layers import updateLayers
1313
from ...share import getShare
1414
from ...tty import setVerbosity, setTui, Warn
15-
from ...utils import copyTree, processDefines, EventLoopWrapper, SandboxMode
15+
from ...utils import copyTree, EventLoopWrapper, SandboxMode
16+
from ..helpers import processDefines
1617
import argparse
1718
import datetime
1819
import re

pym/bob/cmds/build/clean.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from ...share import getShare
1010
from ...state import BobState
1111
from ...tty import colorize, ERROR, WARNING, EXECUTED, DEFAULT, Warn
12-
from ...utils import removePath, processDefines
12+
from ...utils import removePath
13+
from ..helpers import processDefines
1314
import argparse
1415
import os
1516

pym/bob/cmds/build/project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
from ...generators import generators as defaultGenerators
99
from ...input import RecipeSet
1010
from ...tty import colorize
11-
from ...utils import processDefines, SandboxMode
11+
from ...utils import SandboxMode
12+
from ..helpers import processDefines
1213
import argparse
1314
import os
1415

pym/bob/cmds/build/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ...builder import LocalBuilder
77
from ...errors import ParseError
88
from ...input import RecipeSet
9-
from ...utils import processDefines
9+
from ..helpers import processDefines
1010
from string import Formatter
1111
import argparse
1212
import os

pym/bob/cmds/build/status.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from ...state import BobState
1010
from ...tty import colorize, ERROR, WARNING, EXECUTED, DEFAULT, SKIPPED, \
1111
IMPORTANT, NORMAL, INFO, DEBUG, TRACE, HEADLINE
12-
from ...utils import joinLines, processDefines
12+
from ...utils import joinLines
13+
from ..helpers import processDefines
1314
from textwrap import indent
1415
import argparse
1516
import os

pym/bob/cmds/graph.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from .. import BOB_VERSION
77
from ..input import RecipeSet
88
from ..tty import colorize
9-
from ..utils import processDefines, runInEventLoop
9+
from ..utils import runInEventLoop
10+
from .helpers import processDefines
1011
import argparse
1112
import asyncio
1213
import json

pym/bob/cmds/helpers.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
def processDefines(defs):
4+
"""Convert a list of 'KEY=VALUE' strings into a dict"""
5+
defines = {}
6+
for define in defs:
7+
key, _sep, value = define.partition('=')
8+
defines[key] = value
9+
return defines
10+
11+
12+
def dumpYaml(doc, indent):
13+
if indent is None:
14+
style = None
15+
else:
16+
style = False
17+
18+
import yaml
19+
return yaml.dump(doc, default_flow_style=style, indent=indent)
20+
21+
def dumpJson(doc, indent):
22+
import json
23+
return json.dumps(doc, indent=indent, sort_keys=True)
24+
25+
def dumpFlat(doc, prefix=""):
26+
ret = []
27+
if isinstance(doc, dict):
28+
for k,v in sorted(doc.items()):
29+
ret.extend(dumpFlat(v, prefix+"."+k if prefix else k))
30+
elif isinstance(doc, list):
31+
i = 0
32+
for v in doc:
33+
ret.extend(dumpFlat(v, "{}[{}]".format(prefix, i)))
34+
i += 1
35+
else:
36+
doc = str(doc).replace('\n', '\\n')
37+
ret = [ "{}={}".format(prefix, doc) ]
38+
39+
return ret

0 commit comments

Comments
 (0)