瀏覽代碼

Merge branch 'bugfix/archive_details_always_run_like_diff_v4.4' into 'release/v4.4'

tools: fix bug with idf_size argument archive_details (v4.4)

See merge request espressif/esp-idf!15774
Roland Dobai 4 年之前
父節點
當前提交
cd97e95a12
共有 2 個文件被更改,包括 485 次插入464 次删除
  1. 16 6
      tools/idf_size.py
  2. 469 458
      tools/test_idf_size/expected_output

+ 16 - 6
tools/idf_size.py

@@ -1079,7 +1079,7 @@ class StructureForArchiveSymbols(object):
 
 
 def get_archive_symbols(sections: Dict, archive: str, as_json: bool=False, sections_diff: Dict=None) -> str:
-    diff_en = sections_diff is not None
+    diff_en = bool(sections_diff)
     current = StructureForArchiveSymbols.get(archive, sections)
     reference = StructureForArchiveSymbols.get(archive, sections_diff) if sections_diff else {}
 
@@ -1103,19 +1103,29 @@ def get_archive_symbols(sections: Dict, archive: str, as_json: bool=False, secti
         def _get_item_pairs(name: str, section: collections.OrderedDict) -> collections.OrderedDict:
             return collections.OrderedDict([(key.replace(name + '.', ''), val) for key, val in iteritems(section)])
 
+        def _get_max_len(symbols_dict: Dict) -> Tuple[int, int]:
+            # the lists have 0 in them because max() doesn't work with empty lists
+            names_max_len = 0
+            numbers_max_len = 0
+            for t, s in iteritems(symbols_dict):
+                numbers_max_len = max([numbers_max_len, *[len(str(x)) for _, x in iteritems(s)]])
+                names_max_len = max([names_max_len, *[len(x) for x in _get_item_pairs(t, s)]])
+
+            return names_max_len, numbers_max_len
+
         def _get_output(section_symbols: Dict) -> str:
             output = ''
+            names_max_len, numbers_max_len  = _get_max_len(section_symbols)
             for t, s in iteritems(section_symbols):
                 output += '{}Symbols from section: {}{}'.format(os.linesep, t, os.linesep)
                 item_pairs = _get_item_pairs(t, s)
-                output += ' '.join(['{}({})'.format(key, val) for key, val in iteritems(item_pairs)])
+                for key, val in iteritems(item_pairs):
+                    output += ' '.join([('\t{:<%d} : {:>%d}\n' % (names_max_len,numbers_max_len)).format(key, val)])
                 section_total = sum([val for _, val in iteritems(item_pairs)])
-                output += '{}Section total: {}{}'.format(os.linesep if section_total > 0 else '',
-                                                         section_total,
-                                                         os.linesep)
+                output += 'Section total: {}{}'.format(section_total, os.linesep)
             return output
 
-        output = 'Symbols within the archive: {} (Not all symbols may be reported){}'.format(archive, os.linesep)
+        output = '{}Symbols within the archive: {} (Not all symbols may be reported){}'.format(os.linesep, archive, os.linesep)
         if diff_en:
 
             def _generate_line_tuple(curr: collections.OrderedDict, ref: collections.OrderedDict, name: str) -> Tuple[str, int, int, str]:

文件差異過大導致無法顯示
+ 469 - 458
tools/test_idf_size/expected_output


部分文件因文件數量過多而無法顯示