Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: build_api.py
- Revision:
- 22:9e85236d8716
- Parent:
- 17:04753e1e329d
- Child:
- 24:25bff2709c20
--- a/build_api.py Fri Jul 15 22:58:15 2016 +0100
+++ b/build_api.py Sat Jul 16 00:34:03 2016 +0100
@@ -197,7 +197,7 @@
if report != None:
start = time()
-
+
# If project_id is specified, use that over the default name
id_name = project_id.upper() if project_id else name.upper()
description = project_description if project_description else name
@@ -253,6 +253,7 @@
cur_result["elapsed_time"] = end - start
cur_result["output"] = toolchain.get_output()
cur_result["result"] = "OK"
+ cur_result["memory_usage"] = toolchain.map_outputs
add_result_to_report(report, cur_result)
@@ -315,7 +316,7 @@
if report != None:
start = time()
-
+
# If project_id is specified, use that over the default name
id_name = project_id.upper() if project_id else name.upper()
description = name
@@ -398,7 +399,7 @@
toolchain.copy_files(resources.libraries, build_path, resources=resources)
if resources.linker_script:
toolchain.copy_files(resources.linker_script, build_path, resources=resources)
-
+
if resource.hex_files:
toolchain.copy_files(resources.hex_files, build_path, resources=resources)
@@ -416,16 +417,17 @@
cur_result["result"] = "OK"
add_result_to_report(report, cur_result)
+ return True
except Exception, e:
if report != None:
end = time()
-
+
if isinstance(e, ToolException):
cur_result["result"] = "FAIL"
elif isinstance(e, NotSupportedException):
cur_result["result"] = "NOT_SUPPORTED"
-
+
cur_result["elapsed_time"] = end - start
toolchain_output = toolchain.get_output()
@@ -449,7 +451,7 @@
if not lib.is_supported(target, toolchain_name):
print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id, target.name, toolchain)
return False
-
+
# We need to combine macros from parameter list with macros from library definition
MACROS = lib.macros if lib.macros else []
if macros:
@@ -462,7 +464,7 @@
dependencies_paths = lib.dependencies
inc_dirs = lib.inc_dirs
inc_dirs_ext = lib.inc_dirs_ext
-
+
""" src_path: the path of the source directory
build_path: the path of the build directory
target: ['LPC1768', 'LPC11U24', 'LPC2368']
@@ -543,7 +545,7 @@
# Copy Headers
for resource in resources:
toolchain.copy_files(resource.headers, build_path, resources=resource)
-
+
dependencies_include_dir.extend(toolchain.scan_resources(build_path).inc_dirs)
# Compile Sources
@@ -560,6 +562,7 @@
cur_result["result"] = "OK"
add_result_to_report(report, cur_result)
+ return True
except Exception, e:
if report != None:
@@ -737,7 +740,7 @@
perm_counter += 1
else:
text = "-"
-
+
row.append(text)
pt.add_row(row)
@@ -963,6 +966,49 @@
result += "\n"
return result
+def print_build_memory_usage_results(report):
+ """ Generate result table with memory usage values for build results
+ Agregates (puts together) reports obtained from self.get_memory_summary()
+ @param report Report generated during build procedure. See
+ """
+ from prettytable import PrettyTable
+ columns_text = ['name', 'target', 'toolchain']
+ columns_int = ['static_ram', 'stack', 'heap', 'total_ram', 'total_flash']
+ table = PrettyTable(columns_text + columns_int)
+
+ for col in columns_text:
+ table.align[col] = 'l'
+
+ for col in columns_int:
+ table.align[col] = 'r'
+
+ for target in report:
+ for toolchain in report[target]:
+ for name in report[target][toolchain]:
+ for dlist in report[target][toolchain][name]:
+ for dlistelem in dlist:
+ # Get 'memory_usage' record and build table with statistics
+ record = dlist[dlistelem]
+ if 'memory_usage' in record and record['memory_usage']:
+ # Note that summary should be in the last record of
+ # 'memory_usage' section. This is why we are grabbing
+ # last "[-1]" record.
+ row = [
+ record['description'],
+ record['target_name'],
+ 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'],
+ ]
+ table.add_row(row)
+
+ result = "Memory map breakdown for built projects (values in Bytes):\n"
+ result += table.get_string(sortby='name')
+ return result
+
def write_build_report(build_report, template_filename, filename):
build_report_failing = []
build_report_passing = []
@@ -984,14 +1030,14 @@
def scan_for_source_paths(path, exclude_paths=None):
ignorepatterns = []
paths = []
-
+
def is_ignored(file_path):
for pattern in ignorepatterns:
if fnmatch.fnmatch(file_path, pattern):
return True
return False
-
-
+
+
""" os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
When topdown is True, the caller can modify the dirnames list in-place
(perhaps using del or slice assignment), and walk() will only recurse into
