Skip to content

Commit 54dca6b

Browse files
committed
tools: Bring back memap output by default
Now prints both the table and bars if available
1 parent 5c7cd1f commit 54dca6b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

tools/build_api.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,13 +531,11 @@ def build_project(src_paths, build_path, target, toolchain_name,
531531
real_stats_depth = stats_depth if stats_depth is not None else 2
532532
memap_table = memap_instance.generate_output('table', real_stats_depth)
533533
if not silent:
534-
if not stats_depth:
535-
memap_bars = memap_instance.generate_output('bars',
536-
real_stats_depth, None,
537-
getattr(toolchain.target, 'device_name', None))
538-
print(memap_bars)
539-
else:
540-
print(memap_table)
534+
memap_bars = memap_instance.generate_output('bars',
535+
real_stats_depth, None,
536+
getattr(toolchain.target, 'device_name', None))
537+
print(memap_table)
538+
print(memap_bars)
541539

542540
# Write output to file in JSON format
543541
map_out = join(build_path, name + "_map.json")

tools/memap.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -618,9 +618,9 @@ def generate_table(self, file_desc):
618618
output += "Total Flash memory (text + data): %s bytes\n" % \
619619
str(self.mem_summary['total_flash'])
620620

621-
return output
621+
return output.strip()
622622

623-
def generate_bars(self, file_desc, device_name=None):
623+
def generate_bars(self, file_desc, device_name=None, show_totals=False):
624624
""" Generates nice looking bars that represent the memory consumption
625625
626626
Returns: string containing nice looking bars
@@ -663,10 +663,12 @@ def unit(n, u='B', p=3):
663663
scale = math.floor(math.log(n, 1024))
664664
return '{1:.{0}g}{2}{3}'.format(p, n/(1024**scale), PREFIXES[int(scale)], u)
665665

666-
usage = "Text {} Data {} BSS {}".format(unit(text), unit(data), unit(bss))
667-
avail = "ROM {} RAM {}".format(unit(rom_used), unit(ram_used))
668-
output = ["{0} {1:>{2}}".format(usage, avail,
669-
abs(WIDTH-len(usage)-1) if device_name is not None else 0)]
666+
output =[]
667+
if show_totals:
668+
usage = "Text {} Data {} BSS {}".format(unit(text), unit(data), unit(bss))
669+
avail = "ROM {} RAM {}".format(unit(rom_used), unit(ram_used))
670+
output.append("{0} {1:>{2}}".format(usage, avail,
671+
abs(WIDTH-len(usage)-1) if device_name is not None else 0))
670672

671673
if device_name is not None:
672674
for region, avail, uses in [

0 commit comments

Comments
 (0)