diff --git a/.github/workflows/metric-workflow.yml b/.github/workflows/metric-workflow.yml index 2d2ebbdf4..0a837d2d4 100644 --- a/.github/workflows/metric-workflow.yml +++ b/.github/workflows/metric-workflow.yml @@ -27,7 +27,7 @@ jobs: run: make -j2 -C head epsilon.elf - name: Retrieve binary size analysis id: binary_size - run: echo "::set-output name=table::$(python3 head/build/metrics/binary_size.py base/output/release/device/n0110/epsilon.elf head/output/release/device/n0110/epsilon.elf --labels Base Head --sections .text .rodata .bss .data --escape)" + run: echo "::set-output name=table::$(python3 head/build/metrics/binary_size.py base/output/release/device/n0110/epsilon.elf head/output/release/device/n0110/epsilon.elf --labels Base Head --sections .text .rodata .bss .data --custom 'Total (RAM)' .data .bss --custom 'Total (ROM)' .text .rodata .data --escape)" - name: Prepare comment auth run: echo "::set-env name=GITHUB_TOKEN::$(echo YjgxYTk1YTQ4YzYxNjU4ZTA3YWQzNDYwNTk3ZTI2MTlkODU5MThlOQo= | base64 --decode)" - name: Add comment diff --git a/build/metrics/binary_size.py b/build/metrics/binary_size.py index 867661070..52c661e7d 100644 --- a/build/metrics/binary_size.py +++ b/build/metrics/binary_size.py @@ -118,6 +118,7 @@ parser.add_argument('files', type=str, nargs='+', help='an ELF file') parser.add_argument('--labels', type=str, nargs='+', help='label for ELF file') parser.add_argument('--sections', type=str, nargs='+', help='Section (prefix) to list') parser.add_argument('--escape', action='store_true', help='Escape the output') +parser.add_argument('--custom', type=str, action='append', nargs='+', help='Custom sections, made from the addition of other sections.') args = parser.parse_args() @@ -128,7 +129,14 @@ for i,filename in enumerate(args.files): label = os.path.basename(filename) if args.labels and i < len(args.labels): label = args.labels[i] - table.append({'label': label, 'values': row_for_elf(filename, args.sections)}) + values = row_for_elf(filename, args.sections) + for custom_section in args.custom: + if (len(custom_section) >= 2): + custom_section_size = 0 + for i in range(len(custom_section) - 1): + custom_section_size += values[custom_section[i + 1]] + values[custom_section[0]] = custom_section_size + table.append({'label': label, 'values': values}) formatted_table = format_table(table) if args.escape: