Skip to content

Commit

Permalink
skip print each make example
Browse files Browse the repository at this point in the history
  • Loading branch information
hathach committed Aug 13, 2024
1 parent 6e0697c commit 1e593ac
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions tools/build_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,19 @@ def skip_example(example, board):
return False


def build_size(make_cmd):
size_output = subprocess.run(make_cmd + ' size', 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')
flash_size = int(size_list[0])
sram_size = int(size_list[1]) + int(size_list[2])
return (flash_size, sram_size)

return (0, 0)


def build_example(example, board, make_option):
start_time = time.monotonic()
flash_size = "-"
Expand All @@ -89,43 +102,28 @@ def build_example(example, board, make_option):
# succeeded, failed, skipped
ret = [0, 0, 0]

make_cmd = "make -j -C examples/{} BOARD={} {}".format(example, board, make_option)
make_cmd = f"make -j -C examples/{example} BOARD={board} {make_option}"

# Check if board is skipped
if skip_example(example, board):
status = SKIPPED
ret[2] = 1
print(build_format.format(example, board, status, '-', flash_size, sram_size))
#print(build_format.format(example, board, status, '-', flash_size, sram_size))
else:
#subprocess.run(make_cmd + " clean", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
build_result = subprocess.run(make_cmd + " all", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
build_result = subprocess.run(f"{make_cmd} all", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

if build_result.returncode == 0:
status = SUCCEEDED
ret[0] = 1
(flash_size, sram_size) = build_size(make_cmd)
#subprocess.run(make_cmd + " copy-artifact", shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
#(flash_size, sram_size) = build_size(make_cmd)
else:
status = FAILED
ret[1] = 1

build_duration = time.monotonic() - start_time
print(build_format.format(example, board, status, "{:.2f}s".format(build_duration), flash_size, sram_size))
# build_duration = time.monotonic() - start_time
# print(build_format.format(example, board, status, "{:.2f}s".format(build_duration), flash_size, sram_size))

if build_result.returncode != 0:
print(build_result.stdout.decode("utf-8"))

return ret


def build_size(make_cmd):
size_output = subprocess.run(make_cmd + ' size', 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')
flash_size = int(size_list[0])
sram_size = int(size_list[1]) + int(size_list[2])
return (flash_size, sram_size)

return (0, 0)

0 comments on commit 1e593ac

Please sign in to comment.