Skip to content

Memap enhancements #4887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions tools/build_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
macros=None, inc_dirs=None, jobs=1, silent=False,
report=None, properties=None, project_id=None,
project_description=None, extra_verbose=False, config=None,
app_config=None, build_profile=None):
app_config=None, build_profile=None, stats_depth=None):
""" Build a project. A project may be a test or a user program.

Positional arguments:
Expand Down Expand Up @@ -475,6 +475,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
config - a Config object to use instead of creating one
app_config - location of a chosen mbed_app.json file
build_profile - a dict of flags that will be passed to the compiler
stats_depth - depth level for memap to display file/dirs
"""

# Convert src_path to a list if needed
Expand Down Expand Up @@ -553,18 +554,18 @@ def build_project(src_paths, build_path, target, toolchain_name,
memap_table = ''
if memap_instance:
# Write output to stdout in text (pretty table) format
memap_table = memap_instance.generate_output('table')
memap_table = memap_instance.generate_output('table', stats_depth)

if not silent:
print memap_table

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

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

resources.detect_duplicates(toolchain)

Expand All @@ -573,7 +574,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
cur_result["elapsed_time"] = end - start
cur_result["output"] = toolchain.get_output() + memap_table
cur_result["result"] = "OK"
cur_result["memory_usage"] = toolchain.map_outputs
cur_result["memory_usage"] = memap_instance.mem_report
cur_result["bin"] = res
cur_result["elf"] = splitext(res)[0] + ".elf"
cur_result.update(toolchain.report)
Expand Down Expand Up @@ -1163,7 +1164,7 @@ def mcu_toolchain_list(release_version='5'):


def mcu_target_list(release_version='5'):
""" Shows target list
""" Shows target list

"""

Expand Down Expand Up @@ -1323,7 +1324,7 @@ def print_build_memory_usage(report):
"""
from prettytable import PrettyTable
columns_text = ['name', 'target', 'toolchain']
columns_int = ['static_ram', 'stack', 'heap', 'total_ram', 'total_flash']
columns_int = ['static_ram', 'total_flash']
table = PrettyTable(columns_text + columns_int)

for col in columns_text:
Expand All @@ -1350,10 +1351,6 @@ def print_build_memory_usage(report):
record['toolchain_name'],
record['memory_usage'][-1]['summary'][
'static_ram'],
record['memory_usage'][-1]['summary']['stack'],
record['memory_usage'][-1]['summary']['heap'],
record['memory_usage'][-1]['summary'][
'total_ram'],
record['memory_usage'][-1]['summary'][
'total_flash'],
]
Expand Down
110 changes: 63 additions & 47 deletions tools/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,51 +58,66 @@
# Parse Options
parser = get_default_options_parser(add_app_config=True)
group = parser.add_mutually_exclusive_group(required=False)
group.add_argument("-p",
type=argparse_many(test_known),
dest="program",
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))

group.add_argument("-n",
type=argparse_many(test_name_known),
dest="program",
help="The name of the desired test program")

parser.add_argument("-j", "--jobs",
type=int,
dest="jobs",
default=0,
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")

parser.add_argument("-v", "--verbose",
action="store_true",
dest="verbose",
default=False,
help="Verbose diagnostic output")

parser.add_argument("--silent",
action="store_true",
dest="silent",
default=False,
help="Silent diagnostic output (no copy, compile notification)")

parser.add_argument("-D",
action="append",
dest="macros",
help="Add a macro definition")

group.add_argument("-S", "--supported-toolchains",
dest="supported_toolchains",
default=False,
const="matrix",
choices=["matrix", "toolchains", "targets"],
nargs="?",
help="Displays supported matrix of MCUs and toolchains")

parser.add_argument('-f', '--filter',
dest='general_filter_regex',
default=None,
help='For some commands you can use filter to filter out results')
group.add_argument(
"-p",
type=argparse_many(test_known),
dest="program",
help="The index of the desired test program: [0-%d]" % (len(TESTS)-1))

group.add_argument(
"-n",
type=argparse_many(test_name_known),
dest="program",
help="The name of the desired test program")

parser.add_argument(
"-j", "--jobs",
type=int,
dest="jobs",
default=0,
help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)")

parser.add_argument(
"-v", "--verbose",
action="store_true",
dest="verbose",
default=False,
help="Verbose diagnostic output")

parser.add_argument(
"--silent",
action="store_true",
dest="silent",
default=False,
help="Silent diagnostic output (no copy, compile notification)")

parser.add_argument(
"-D",
action="append",
dest="macros",
help="Add a macro definition")

group.add_argument(
"-S", "--supported-toolchains",
dest="supported_toolchains",
default=False,
const="matrix",
choices=["matrix", "toolchains", "targets"],
nargs="?",
help="Displays supported matrix of MCUs and toolchains")

parser.add_argument(
'-f', '--filter',
dest='general_filter_regex',
default=None,
help='For some commands you can use filter to filter out results')

parser.add_argument(
"--stats-depth",
type=int,
dest="stats_depth",
default=2,
help="Depth level for static memory report")

# Local run
parser.add_argument("--automated", action="store_true", dest="automated",
Expand Down Expand Up @@ -277,7 +292,8 @@
inc_dirs=[dirname(MBED_LIBRARIES)],
build_profile=extract_profile(parser,
options,
toolchain))
toolchain),
stats_depth=options.stats_depth)
print 'Image: %s'% bin_file

if options.disk:
Expand Down Expand Up @@ -322,7 +338,7 @@
traceback.print_exc(file=sys.stdout)
else:
print "[ERROR] %s" % str(e)

sys.exit(1)
if options.build_data:
merge_build_data(options.build_data, build_data_blob, "application")
Loading