summaryrefslogtreecommitdiff
path: root/script/nfpvalues.py
diff options
context:
space:
mode:
authorDaniel Friesel <daniel.friesel@uos.de>2021-10-11 09:48:20 +0200
committerDaniel Friesel <daniel.friesel@uos.de>2021-10-11 09:48:20 +0200
commitcecc5e4ed60411e0313c4bfdf836d1b920da7a0f (patch)
tree27c4a86ecabff4e0ccc13aa4d1cf620979d7a207 /script/nfpvalues.py
parentbfea211b190d5dfe06d0ab88ba1b5bfc0781e57b (diff)
add scripts/nfpvalues.py
Diffstat (limited to 'script/nfpvalues.py')
-rwxr-xr-xscript/nfpvalues.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/script/nfpvalues.py b/script/nfpvalues.py
new file mode 100755
index 0000000..b88c3df
--- /dev/null
+++ b/script/nfpvalues.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+#
+# Copyright 2021 Daniel Friesel
+#
+# SPDX-License-Identifier: BSD-2-Clause
+
+import json
+import re
+import subprocess
+import sys
+
+
+def main(size_executable, rom_sections, ram_sections):
+ rom_sections = rom_sections.split(",")
+ ram_sections = ram_sections.split(",")
+
+ status = subprocess.run(
+ [size_executable, "-A", "build/system.elf"],
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ universal_newlines=True,
+ )
+
+ section_size = dict()
+
+ for line in status.stdout.split("\n"):
+ match = re.match("[.](\S+)\s+(\d+)", line)
+ if match:
+ section = match.group(1)
+ size = int(match.group(2))
+ section_size[section] = size
+
+ total = {
+ "ROM": sum(map(lambda section: section_size[section], rom_sections)),
+ "RAM": sum(map(lambda section: section_size[section], ram_sections)),
+ }
+
+ output = {"OS Image": total}
+
+ print(json.dumps(output))
+
+
+if __name__ == "__main__":
+ main(*sys.argv[1:])