From 956d1c9c4e6c26e1c7de70c1c2e01a5380dd3dfe Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 6 Mar 2023 10:33:04 +0700 Subject: [PATCH] update size to fix macos ci --- examples/make.mk | 2 +- tools/build_utils.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/examples/make.mk b/examples/make.mk index 8a0b6db6b..e02d226b6 100644 --- a/examples/make.mk +++ b/examples/make.mk @@ -61,7 +61,7 @@ ifdef USE_IAR AS = iasmarm LD = ilinkarm OBJCOPY = ielftool - SIZE = echo "size not available for IAR" + SIZE = size else CC = $(CROSS_COMPILE)gcc diff --git a/tools/build_utils.py b/tools/build_utils.py index ad1daf8c7..0dbfd3356 100644 --- a/tools/build_utils.py +++ b/tools/build_utils.py @@ -114,9 +114,15 @@ def build_example(example, board, make_option): def build_size(example, board): - elf_file = 'examples/{}/_build/{}/*.elf'.format(example, board) - size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8") - size_list = size_output.split('\n')[1].split('\t') + size_cmd = 'make -j -C examples/{} BOARD={} size'.format(example, board) + size_output = subprocess.run(size_cmd, shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8").splitlines() + for i, l in enumerate(size_output): + text_title = 'text data bss dec' + if text_title in l: + size_list = size_output[i+1].split('\t') + break + flash_size = int(size_list[0]) sram_size = int(size_list[1]) + int(size_list[2]) return (flash_size, sram_size) +