mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-11-16 04:24:45 +00:00
rtems-bsps: Add JSON output
Add a -j / --json flag to output BSP list in JSON.
This commit is contained in:
committed by
Kinsey Moore
parent
a0ab18ed0d
commit
d709f8aac3
21
rtems-bsps
21
rtems-bsps
@@ -152,6 +152,20 @@ class ArchBsps:
|
|||||||
count += len(self.archs[arch])
|
count += len(self.archs[arch])
|
||||||
return count
|
return count
|
||||||
|
|
||||||
|
def json(self):
|
||||||
|
"""Returns BSPs in JSON format by architecture and family"""
|
||||||
|
import json
|
||||||
|
map_arch = {}
|
||||||
|
|
||||||
|
for arch in sorted(self.archs.keys()):
|
||||||
|
map_arch[arch] = []
|
||||||
|
for family in sorted(self.archs[arch].keys()):
|
||||||
|
for bsp in sorted(self.archs[arch][family].keys()):
|
||||||
|
path = os.path.join('bsps', self.archs[arch][family][bsp])
|
||||||
|
map_arch[arch].append((bsp, family, path))
|
||||||
|
|
||||||
|
print(json.dumps(map_arch, sort_keys=True, indent="\t"))
|
||||||
|
|
||||||
def bsps(self, arch=None, family=None):
|
def bsps(self, arch=None, family=None):
|
||||||
"""Returns the number of BSPs we have for an architecture or a family"""
|
"""Returns the number of BSPs we have for an architecture or a family"""
|
||||||
count = 0
|
count = 0
|
||||||
@@ -396,6 +410,11 @@ def run(args):
|
|||||||
'--pairs',
|
'--pairs',
|
||||||
help='Output architectures and BSPs in CPU/BSP format',
|
help='Output architectures and BSPs in CPU/BSP format',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
argsp.add_argument(
|
||||||
|
'-j',
|
||||||
|
'--json',
|
||||||
|
help='Output "arch: [(bsp, family, path)]" in JSON format',
|
||||||
|
action='store_true')
|
||||||
argsp.add_argument(
|
argsp.add_argument(
|
||||||
'-C',
|
'-C',
|
||||||
'--config',
|
'--config',
|
||||||
@@ -419,6 +438,8 @@ def run(args):
|
|||||||
ab.pairs(arch_selector=argopts.arch,
|
ab.pairs(arch_selector=argopts.arch,
|
||||||
family_selector=argopts.family,
|
family_selector=argopts.family,
|
||||||
show_path=argopts.paths)
|
show_path=argopts.paths)
|
||||||
|
elif argopts.json:
|
||||||
|
ab.json()
|
||||||
elif argopts.config:
|
elif argopts.config:
|
||||||
ab.config(arch_selector=argopts.arch, family_selector=argopts.family)
|
ab.config(arch_selector=argopts.arch, family_selector=argopts.family)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user