Skip to content

Commit a3469a0

Browse files
wangnuannuannashif
authored andcommitted
script: add ram and rom total size to json file
It's easier and safer to parse json file rather than extract total size from stdout Now the .json file has two keys: { "symbols": { "children": [ ... ], "identifier": ":", "name": "root", "size": 2220 }, "total_size": 34272 } Signed-off-by: Jingru Wang <[email protected]>
1 parent 6af80f4 commit a3469a0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

scripts/footprint/size_report

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import os
1212
import sys
1313
import re
1414
from pathlib import Path
15+
import json
1516

1617
from distutils.version import LooseVersion
1718

@@ -30,7 +31,7 @@ if LooseVersion(elftools.__version__) < LooseVersion('0.24'):
3031
from colorama import init, Fore
3132

3233
from anytree import RenderTree, NodeMixin, findall_by_attr
33-
from anytree.exporter import JsonExporter
34+
from anytree.exporter import DictExporter
3435

3536

3637
# ELF section flags
@@ -634,10 +635,12 @@ def main():
634635
print_any_tree(root, symsize, args.depth)
635636

636637
if args.json:
637-
exporter = JsonExporter(indent=2, sort_keys=True)
638-
data = exporter.export(root)
638+
exporter = DictExporter()
639+
data = dict()
640+
data["symbols"] = exporter.export(root)
641+
data["total_size"] = symsize
639642
with open(args.json, "w") as fp:
640-
fp.write(data)
643+
json.dump(data, fp, indent=4)
641644

642645

643646
if __name__ == "__main__":

0 commit comments

Comments
 (0)