Skip to content

Commit 878557e

Browse files
Merge pull request #4392 from MarceloSalazar/memap_enhancements
Enhance memap, and configure depth level
2 parents 7653f65 + 5469be4 commit 878557e

File tree

7 files changed

+607
-354
lines changed

7 files changed

+607
-354
lines changed

tools/build_api.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
446446
macros=None, inc_dirs=None, jobs=1, silent=False,
447447
report=None, properties=None, project_id=None,
448448
project_description=None, extra_verbose=False, config=None,
449-
app_config=None, build_profile=None):
449+
app_config=None, build_profile=None, stats_depth=None):
450450
""" Build a project. A project may be a test or a user program.
451451
452452
Positional arguments:
@@ -475,6 +475,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
475475
config - a Config object to use instead of creating one
476476
app_config - location of a chosen mbed_app.json file
477477
build_profile - a dict of flags that will be passed to the compiler
478+
stats_depth - depth level for memap to display file/dirs
478479
"""
479480

480481
# Convert src_path to a list if needed
@@ -553,18 +554,18 @@ def build_project(src_paths, build_path, target, toolchain_name,
553554
memap_table = ''
554555
if memap_instance:
555556
# Write output to stdout in text (pretty table) format
556-
memap_table = memap_instance.generate_output('table')
557+
memap_table = memap_instance.generate_output('table', stats_depth)
557558

558559
if not silent:
559560
print memap_table
560561

561562
# Write output to file in JSON format
562563
map_out = join(build_path, name + "_map.json")
563-
memap_instance.generate_output('json', map_out)
564+
memap_instance.generate_output('json', stats_depth, map_out)
564565

565566
# Write output to file in CSV format for the CI
566567
map_csv = join(build_path, name + "_map.csv")
567-
memap_instance.generate_output('csv-ci', map_csv)
568+
memap_instance.generate_output('csv-ci', stats_depth, map_csv)
568569

569570
resources.detect_duplicates(toolchain)
570571

@@ -573,7 +574,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
573574
cur_result["elapsed_time"] = end - start
574575
cur_result["output"] = toolchain.get_output() + memap_table
575576
cur_result["result"] = "OK"
576-
cur_result["memory_usage"] = toolchain.map_outputs
577+
cur_result["memory_usage"] = memap_instance.mem_report
577578
cur_result["bin"] = res
578579
cur_result["elf"] = splitext(res)[0] + ".elf"
579580
cur_result.update(toolchain.report)
@@ -1163,7 +1164,7 @@ def mcu_toolchain_list(release_version='5'):
11631164

11641165

11651166
def mcu_target_list(release_version='5'):
1166-
""" Shows target list
1167+
""" Shows target list
11671168
11681169
"""
11691170

@@ -1323,7 +1324,7 @@ def print_build_memory_usage(report):
13231324
"""
13241325
from prettytable import PrettyTable
13251326
columns_text = ['name', 'target', 'toolchain']
1326-
columns_int = ['static_ram', 'stack', 'heap', 'total_ram', 'total_flash']
1327+
columns_int = ['static_ram', 'total_flash']
13271328
table = PrettyTable(columns_text + columns_int)
13281329

13291330
for col in columns_text:
@@ -1350,10 +1351,6 @@ def print_build_memory_usage(report):
13501351
record['toolchain_name'],
13511352
record['memory_usage'][-1]['summary'][
13521353
'static_ram'],
1353-
record['memory_usage'][-1]['summary']['stack'],
1354-
record['memory_usage'][-1]['summary']['heap'],
1355-
record['memory_usage'][-1]['summary'][
1356-
'total_ram'],
13571354
record['memory_usage'][-1]['summary'][
13581355
'total_flash'],
13591356
]

tools/make.py

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -58,51 +58,66 @@
5858
# Parse Options
5959
parser = get_default_options_parser(add_app_config=True)
6060
group = parser.add_mutually_exclusive_group(required=False)
61-
group.add_argument("-p",
62-
type=argparse_many(test_known),
63-
dest="program",
64-
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
65-
66-
group.add_argument("-n",
67-
type=argparse_many(test_name_known),
68-
dest="program",
69-
help="The name of the desired test program")
70-
71-
parser.add_argument("-j", "--jobs",
72-
type=int,
73-
dest="jobs",
74-
default=0,
75-
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
76-
77-
parser.add_argument("-v", "--verbose",
78-
action="store_true",
79-
dest="verbose",
80-
default=False,
81-
help="Verbose diagnostic output")
82-
83-
parser.add_argument("--silent",
84-
action="store_true",
85-
dest="silent",
86-
default=False,
87-
help="Silent diagnostic output (no copy, compile notification)")
88-
89-
parser.add_argument("-D",
90-
action="append",
91-
dest="macros",
92-
help="Add a macro definition")
93-
94-
group.add_argument("-S", "--supported-toolchains",
95-
dest="supported_toolchains",
96-
default=False,
97-
const="matrix",
98-
choices=["matrix", "toolchains", "targets"],
99-
nargs="?",
100-
help="Displays supported matrix of MCUs and toolchains")
101-
102-
parser.add_argument('-f', '--filter',
103-
dest='general_filter_regex',
104-
default=None,
105-
help='For some commands you can use filter to filter out results')
61+
group.add_argument(
62+
"-p",
63+
type=argparse_many(test_known),
64+
dest="program",
65+
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))
66+
67+
group.add_argument(
68+
"-n",
69+
type=argparse_many(test_name_known),
70+
dest="program",
71+
help="The name of the desired test program")
72+
73+
parser.add_argument(
74+
"-j", "--jobs",
75+
type=int,
76+
dest="jobs",
77+
default=0,
78+
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")
79+
80+
parser.add_argument(
81+
"-v", "--verbose",
82+
action="store_true",
83+
dest="verbose",
84+
default=False,
85+
help="Verbose diagnostic output")
86+
87+
parser.add_argument(
88+
"--silent",
89+
action="store_true",
90+
dest="silent",
91+
default=False,
92+
help="Silent diagnostic output (no copy, compile notification)")
93+
94+
parser.add_argument(
95+
"-D",
96+
action="append",
97+
dest="macros",
98+
help="Add a macro definition")
99+
100+
group.add_argument(
101+
"-S", "--supported-toolchains",
102+
dest="supported_toolchains",
103+
default=False,
104+
const="matrix",
105+
choices=["matrix", "toolchains", "targets"],
106+
nargs="?",
107+
help="Displays supported matrix of MCUs and toolchains")
108+
109+
parser.add_argument(
110+
'-f', '--filter',
111+
dest='general_filter_regex',
112+
default=None,
113+
help='For some commands you can use filter to filter out results')
114+
115+
parser.add_argument(
116+
"--stats-depth",
117+
type=int,
118+
dest="stats_depth",
119+
default=2,
120+
help="Depth level for static memory report")
106121

107122
# Local run
108123
parser.add_argument("--automated", action="store_true", dest="automated",
@@ -277,7 +292,8 @@
277292
inc_dirs=[dirname(MBED_LIBRARIES)],
278293
build_profile=extract_profile(parser,
279294
options,
280-
toolchain))
295+
toolchain),
296+
stats_depth=options.stats_depth)
281297
print 'Image: %s'% bin_file
282298

283299
if options.disk:
@@ -322,7 +338,7 @@
322338
traceback.print_exc(file=sys.stdout)
323339
else:
324340
print "[ERROR] %s" % str(e)
325-
341+
326342
sys.exit(1)
327343
if options.build_data:
328344
merge_build_data(options.build_data, build_data_blob, "application")

0 commit comments

Comments
 (0)