Loading script/size.py 0 → 100755 +40 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 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 = {"section": section_size, "total": total} print(json.dumps(output)) if __name__ == "__main__": main(*sys.argv[1:]) src/arch/arduino-nano/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -173,4 +173,7 @@ arch_info: @echo "Counter Overflow: 65536/255" @echo "Monitor: ${SERIAL_PORT} ${uart_baud}" .PHONY: arch_clean arch_help arch_info monitor program size attributes: build/system.elf ${QUIET}script/size.py avr-size text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program size src/arch/blinkenrocket/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -84,4 +84,7 @@ arch_info: @echo "Counter Overflow: ?/?" @echo "Monitor: ${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py avr-size text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program src/arch/esp8266/Makefile.inc +5 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc OBJCOPY = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objcopy OBJDUMP = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objdump SIZE = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-size ifeq (${aspectc}, 1) CXX = ag++ -r build/repo.acp -v 0 --c_compiler ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++ -p . --Xcompiler Loading Loading @@ -110,4 +111,7 @@ arch_info: @echo "Counter Overflow: 4294967296/0" @echo "Monitor: ${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py ${SIZE} text,irom0.text data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program src/arch/msp430fr5969lp/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -156,4 +156,7 @@ arch_info: @echo "sleep_ms Overflow: 250 500" @echo "Monitor: /dev/${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py ${SIZE} text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program Loading
script/size.py 0 → 100755 +40 −0 Original line number Diff line number Diff line #!/usr/bin/env python3 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 = {"section": section_size, "total": total} print(json.dumps(output)) if __name__ == "__main__": main(*sys.argv[1:])
src/arch/arduino-nano/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -173,4 +173,7 @@ arch_info: @echo "Counter Overflow: 65536/255" @echo "Monitor: ${SERIAL_PORT} ${uart_baud}" .PHONY: arch_clean arch_help arch_info monitor program size attributes: build/system.elf ${QUIET}script/size.py avr-size text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program size
src/arch/blinkenrocket/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -84,4 +84,7 @@ arch_info: @echo "Counter Overflow: ?/?" @echo "Monitor: ${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py avr-size text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program
src/arch/esp8266/Makefile.inc +5 −1 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ AR = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-ar LD = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-gcc OBJCOPY = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objcopy OBJDUMP = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-objdump SIZE = ${TOOLCHAIN_BASE}/xtensa-lx106-elf-size ifeq (${aspectc}, 1) CXX = ag++ -r build/repo.acp -v 0 --c_compiler ${TOOLCHAIN_BASE}/xtensa-lx106-elf-g++ -p . --Xcompiler Loading Loading @@ -110,4 +111,7 @@ arch_info: @echo "Counter Overflow: 4294967296/0" @echo "Monitor: ${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py ${SIZE} text,irom0.text data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program
src/arch/msp430fr5969lp/Makefile.inc +4 −1 Original line number Diff line number Diff line Loading @@ -156,4 +156,7 @@ arch_info: @echo "sleep_ms Overflow: 250 500" @echo "Monitor: /dev/${SERIAL_PORT} 115200" .PHONY: arch_clean arch_help arch_info monitor program attributes: build/system.elf ${QUIET}script/size.py ${SIZE} text,data data,bss .PHONY: arch_clean arch_help arch_info attributes monitor program