size_report: cleanup up detection and error handling

We first check to see if we have a valid elf file before doing anything
else.  Otherwise we'd could get script errors instead of just notifying
the user the file doesn't exist.

Signed-off-by: Kumar Gala <kumar.gala@gmail.com>
This commit is contained in:
Kumar Gala 2018-10-28 13:21:10 +00:00 committed by Anas Nashif
commit 73c7cd184b

View file

@ -425,25 +425,25 @@ def main():
stat_file = os.path.join(args.outdir, args.binary + ".stat")
elf_file = os.path.join(args.outdir, args.binary + ".elf")
if not os.path.exists(elf_file):
print("%s does not exist." % (elf_file))
return
if not os.path.exists(bin_file):
FNULL = open(os.devnull, 'w')
subprocess.call([args.bin_objcopy,"-S", "-Obinary", "-R", ".comment", "-R",
"COMMON", "-R", ".eh_frame", elf_file, bin_file],
stdout=FNULL, stderr=subprocess.STDOUT)
if args.outdir and os.path.exists(elf_file):
fp = get_footprint_from_bin_and_statfile(bin_file, stat_file, 0, 0)
base = os.environ['ZEPHYR_BASE']
ram, data = generate_target_memory_section(
args.bin_objdump, args.bin_nm, args.outdir, args.binary,
base + '/', None)
if args.rom:
print_tree(data, fp['total_flash'], args.depth)
if args.ram:
print_tree(ram, fp['total_ram'], args.depth)
else:
print("%s does not exist." % (elf_file))
fp = get_footprint_from_bin_and_statfile(bin_file, stat_file, 0, 0)
base = os.environ['ZEPHYR_BASE']
ram, data = generate_target_memory_section(
args.bin_objdump, args.bin_nm, args.outdir, args.binary,
base + '/', None)
if args.rom:
print_tree(data, fp['total_flash'], args.depth)
if args.ram:
print_tree(ram, fp['total_ram'], args.depth)
if __name__ == "__main__":