@@ -176,7 +176,7 @@ def build_project(src_path, build_path, target, toolchain_name,
176
176
177
177
if report != None :
178
178
start = time ()
179
-
179
+
180
180
# If project_id is specified, use that over the default name
181
181
id_name = project_id .upper () if project_id else name .upper ()
182
182
description = project_description if project_description else name
@@ -232,6 +232,7 @@ def build_project(src_path, build_path, target, toolchain_name,
232
232
cur_result ["elapsed_time" ] = end - start
233
233
cur_result ["output" ] = toolchain .get_output ()
234
234
cur_result ["result" ] = "OK"
235
+ cur_result ["memory_usage" ] = toolchain .map_outputs
235
236
236
237
add_result_to_report (report , cur_result )
237
238
@@ -294,7 +295,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
294
295
295
296
if report != None :
296
297
start = time ()
297
-
298
+
298
299
# If project_id is specified, use that over the default name
299
300
id_name = project_id .upper () if project_id else name .upper ()
300
301
description = name
@@ -377,7 +378,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
377
378
toolchain .copy_files (resources .libraries , build_path , resources = resources )
378
379
if resources .linker_script :
379
380
toolchain .copy_files (resources .linker_script , build_path , resources = resources )
380
-
381
+
381
382
if resource .hex_files :
382
383
toolchain .copy_files (resources .hex_files , build_path , resources = resources )
383
384
@@ -399,12 +400,12 @@ def build_library(src_paths, build_path, target, toolchain_name,
399
400
except Exception , e :
400
401
if report != None :
401
402
end = time ()
402
-
403
+
403
404
if isinstance (e , ToolException ):
404
405
cur_result ["result" ] = "FAIL"
405
406
elif isinstance (e , NotSupportedException ):
406
407
cur_result ["result" ] = "NOT_SUPPORTED"
407
-
408
+
408
409
cur_result ["elapsed_time" ] = end - start
409
410
410
411
toolchain_output = toolchain .get_output ()
@@ -428,7 +429,7 @@ def build_lib(lib_id, target, toolchain_name, options=None, verbose=False, clean
428
429
if not lib .is_supported (target , toolchain_name ):
429
430
print 'Library "%s" is not yet supported on target %s with toolchain %s' % (lib_id , target .name , toolchain )
430
431
return False
431
-
432
+
432
433
# We need to combine macros from parameter list with macros from library definition
433
434
MACROS = lib .macros if lib .macros else []
434
435
if macros :
@@ -441,7 +442,7 @@ def build_lib(lib_id, target, toolchain_name, options=None, verbose=False, clean
441
442
dependencies_paths = lib .dependencies
442
443
inc_dirs = lib .inc_dirs
443
444
inc_dirs_ext = lib .inc_dirs_ext
444
-
445
+
445
446
""" src_path: the path of the source directory
446
447
build_path: the path of the build directory
447
448
target: ['LPC1768', 'LPC11U24', 'LPC2368']
@@ -522,7 +523,7 @@ def build_lib(lib_id, target, toolchain_name, options=None, verbose=False, clean
522
523
# Copy Headers
523
524
for resource in resources :
524
525
toolchain .copy_files (resource .headers , build_path , resources = resource )
525
-
526
+
526
527
dependencies_include_dir .extend (toolchain .scan_resources (build_path ).inc_dirs )
527
528
528
529
# Compile Sources
@@ -716,7 +717,7 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None):
716
717
perm_counter += 1
717
718
else :
718
719
text = "-"
719
-
720
+
720
721
row .append (text )
721
722
pt .add_row (row )
722
723
@@ -942,6 +943,49 @@ def print_build_results(result_list, build_name):
942
943
result += "\n "
943
944
return result
944
945
946
+ def print_build_memory_usage_results (report ):
947
+ """ Generate result table with memory usage values for build results
948
+ Agregates (puts together) reports obtained from self.get_memory_summary()
949
+ @param report Report generated during build procedure. See
950
+ """
951
+ from prettytable import PrettyTable
952
+ columns_text = ['name' , 'target' , 'toolchain' ]
953
+ columns_int = ['static_ram' , 'stack' , 'heap' , 'total_ram' , 'total_flash' ]
954
+ table = PrettyTable (columns_text + columns_int )
955
+
956
+ for col in columns_text :
957
+ table .align [col ] = 'l'
958
+
959
+ for col in columns_int :
960
+ table .align [col ] = 'r'
961
+
962
+ for target in report :
963
+ for toolchain in report [target ]:
964
+ for name in report [target ][toolchain ]:
965
+ for dlist in report [target ][toolchain ][name ]:
966
+ for dlistelem in dlist :
967
+ # Get 'memory_usage' record and build table with statistics
968
+ record = dlist [dlistelem ]
969
+ if 'memory_usage' in record and record ['memory_usage' ]:
970
+ # Note that summary should be in the last record of
971
+ # 'memory_usage' section. This is why we are grabbing
972
+ # last "[-1]" record.
973
+ row = [
974
+ record ['description' ],
975
+ record ['target_name' ],
976
+ record ['toolchain_name' ],
977
+ record ['memory_usage' ][- 1 ]['summary' ]['static_ram' ],
978
+ record ['memory_usage' ][- 1 ]['summary' ]['stack' ],
979
+ record ['memory_usage' ][- 1 ]['summary' ]['heap' ],
980
+ record ['memory_usage' ][- 1 ]['summary' ]['total_ram' ],
981
+ record ['memory_usage' ][- 1 ]['summary' ]['total_flash' ],
982
+ ]
983
+ table .add_row (row )
984
+
985
+ result = "Memory map breakdown for built projects (values in Bytes):\n "
986
+ result += table .get_string (sortby = 'name' )
987
+ return result
988
+
945
989
def write_build_report (build_report , template_filename , filename ):
946
990
build_report_failing = []
947
991
build_report_passing = []
@@ -963,14 +1007,14 @@ def write_build_report(build_report, template_filename, filename):
963
1007
def scan_for_source_paths (path , exclude_paths = None ):
964
1008
ignorepatterns = []
965
1009
paths = []
966
-
1010
+
967
1011
def is_ignored (file_path ):
968
1012
for pattern in ignorepatterns :
969
1013
if fnmatch .fnmatch (file_path , pattern ):
970
1014
return True
971
1015
return False
972
-
973
-
1016
+
1017
+
974
1018
""" os.walk(top[, topdown=True[, onerror=None[, followlinks=False]]])
975
1019
When topdown is True, the caller can modify the dirnames list in-place
976
1020
(perhaps using del or slice assignment), and walk() will only recurse into
0 commit comments