Skip to content

Commit d49862b

Browse files
authored
Merge pull request #6197 from geky/revert-pretty-bars
Revert "Added pretty bar printing for compile output"
2 parents c9cefcc + 011e018 commit d49862b

File tree

3 files changed

+10
-83
lines changed

3 files changed

+10
-83
lines changed

tools/build_api.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -528,24 +528,19 @@ def build_project(src_paths, build_path, target, toolchain_name,
528528
memap_instance = getattr(toolchain, 'memap_instance', None)
529529
memap_table = ''
530530
if memap_instance:
531-
real_stats_depth = stats_depth if stats_depth is not None else 2
532-
memap_table = memap_instance.generate_output('table', real_stats_depth)
531+
# Write output to stdout in text (pretty table) format
532+
memap_table = memap_instance.generate_output('table', stats_depth)
533+
533534
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)
535+
print(memap_table)
541536

542537
# Write output to file in JSON format
543538
map_out = join(build_path, name + "_map.json")
544-
memap_instance.generate_output('json', real_stats_depth, map_out)
539+
memap_instance.generate_output('json', stats_depth, map_out)
545540

546541
# Write output to file in CSV format for the CI
547542
map_csv = join(build_path, name + "_map.csv")
548-
memap_instance.generate_output('csv-ci', real_stats_depth, map_csv)
543+
memap_instance.generate_output('csv-ci', stats_depth, map_csv)
549544

550545
resources.detect_duplicates(toolchain)
551546

tools/make.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"--stats-depth",
119119
type=int,
120120
dest="stats_depth",
121-
default=None,
121+
default=2,
122122
help="Depth level for static memory report")
123123

124124
# Local run

tools/memap.py

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
import re
1111
import csv
1212
import json
13-
import math
1413
from argparse import ArgumentParser
1514
from copy import deepcopy
1615
from prettytable import PrettyTable
17-
from tools.arm_pack_manager import Cache
1816

1917
from .utils import (argparse_filestring_type, argparse_lowercase_hyphen_type,
2018
argparse_uppercase_type)
@@ -509,7 +507,7 @@ def reduce_depth(self, depth):
509507

510508
export_formats = ["json", "csv-ci", "table"]
511509

512-
def generate_output(self, export_format, depth, file_output=None, *args):
510+
def generate_output(self, export_format, depth, file_output=None):
513511
""" Generates summary of memory map data
514512
515513
Positional arguments:
@@ -534,9 +532,8 @@ def generate_output(self, export_format, depth, file_output=None, *args):
534532

535533
to_call = {'json': self.generate_json,
536534
'csv-ci': self.generate_csv,
537-
'table': self.generate_table,
538-
'bars': self.generate_bars}[export_format]
539-
output = to_call(file_desc, *args)
535+
'table': self.generate_table}[export_format]
536+
output = to_call(file_desc)
540537

541538
if file_desc is not stdout:
542539
file_desc.close()
@@ -620,71 +617,6 @@ def generate_table(self, file_desc):
620617

621618
return output
622619

623-
def generate_bars(self, file_desc, device_name=None):
624-
""" Generates nice looking bars that represent the memory consumption
625-
626-
Returns: string containing nice looking bars
627-
"""
628-
629-
# TODO add tty detection, and width detection probably
630-
WIDTH = 72
631-
try:
632-
# NOTE this only works on linux
633-
import sys, fcntl, termios, struct
634-
height, width, _, _ = struct.unpack('HHHH',
635-
fcntl.ioctl(sys.stdout.fileno(), termios.TIOCGWINSZ,
636-
struct.pack('HHHH', 0, 0, 0, 0)))
637-
WIDTH = min(width, WIDTH)
638-
except Exception:
639-
pass
640-
641-
text = self.subtotal['.text']
642-
data = self.subtotal['.data']
643-
bss = self.subtotal['.bss']
644-
rom_used = self.mem_summary['total_flash']
645-
ram_used = self.mem_summary['static_ram']
646-
647-
# No device_name = no cmsis-pack = we don't know the memory layout
648-
if device_name is not None:
649-
try:
650-
cache = Cache(False, False)
651-
cmsis_part = cache.index[device_name]
652-
rom_avail = int(cmsis_part['memory']['IROM1']['size'], 0)
653-
ram_avail = int(cmsis_part['memory']['IRAM1']['size'], 0)
654-
except KeyError:
655-
# If we don't have the expected regions, fall back to no device_name
656-
device_name = None
657-
658-
PREFIXES = ['', 'K', 'M', 'G', 'T', 'P', 'E']
659-
def unit(n, u='B', p=3):
660-
if n == 0:
661-
return '0' + u
662-
663-
scale = math.floor(math.log(n, 1024))
664-
return '{1:.{0}g}{2}{3}'.format(p, n/(1024**scale), PREFIXES[int(scale)], u)
665-
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)]
670-
671-
if device_name is not None:
672-
for region, avail, uses in [
673-
('ROM', rom_avail, [('|', text), ('|', data)]),
674-
('RAM', ram_avail, [('|', bss), ('|', data)])]:
675-
barwidth = WIDTH-17 - len(region)
676-
677-
used = sum(use for c, use in uses)
678-
bars = [(c, (barwidth*use) // avail) for c, use in uses]
679-
bars.append((' ', barwidth - sum(width for c, width in bars)))
680-
bars = ''.join(c*width for c, width in bars)
681-
682-
output.append("{0} [{2:<{1}}] {3:>13}".format(
683-
region, barwidth, bars,
684-
"{}/{}".format(unit(used), unit(avail))))
685-
686-
return '\n'.join(output)
687-
688620
toolchains = ["ARM", "ARM_STD", "ARM_MICRO", "GCC_ARM", "GCC_CR", "IAR"]
689621

690622
def compute_report(self):

0 commit comments

Comments
 (0)