- enable --one-per-family to build 1 board per family, also skip family if board specified in -b also present
- minimize ci run for push event
  - only build one board per family
  - skip hil test on both pi4 and hfp
- full build will be runn for PR event
- IAR always build 1 board per family regardless of event 
- update build.py to optimize make
- remove all setup python since we don't really need it
This commit is contained in:
Ha Thach
2024-05-13 20:27:49 +07:00
committed by GitHub
parent 6f47746e5f
commit 7cf1bdd284
15 changed files with 163 additions and 161 deletions

View File

@@ -1,4 +1,5 @@
import argparse
import random
import os
import sys
import time
@@ -96,32 +97,61 @@ def build_board_cmake(board, toolchain):
return ret
def build_family(family, toolchain, build_system):
def build_board_make_all_examples(board, toolchain, all_examples):
start_time = time.monotonic()
ret = [0, 0, 0]
with Pool(processes=os.cpu_count()) as pool:
pool_args = list((map(lambda e, b=board, o=f"TOOLCHAIN={toolchain}": [e, b, o], all_examples)))
r = pool.starmap(build_utils.build_example, pool_args)
# sum all element of same index (column sum)
rsum = list(map(sum, list(zip(*r))))
ret[0] += rsum[0]
ret[1] += rsum[1]
ret[2] += rsum[2]
duration = time.monotonic() - start_time
if ret[1] == 0:
status = SUCCEEDED
else:
status = FAILED
flash_size = "-"
sram_size = "-"
example = 'all'
title = build_utils.build_format.format(example, board, status, "{:.2f}s".format(duration), flash_size, sram_size)
print(title)
return ret
def build_family(family, toolchain, build_system, one_per_family, boards):
all_boards = []
for entry in os.scandir(f"hw/bsp/{family}/boards"):
if entry.is_dir() and entry.name != 'pico_sdk':
all_boards.append(entry.name)
all_boards.sort()
# success, failed, skipped
ret = [0, 0, 0]
if build_system == 'cmake':
for board in all_boards:
if build_board_cmake(board, toolchain):
ret[0] += 1
else:
ret[1] += 1
elif build_system == 'make':
all_examples = get_examples(family)
for example in all_examples:
with Pool(processes=os.cpu_count()) as pool:
pool_args = list((map(lambda b, e=example, o=f"TOOLCHAIN={toolchain}": [e, b, o], all_boards)))
r = pool.starmap(build_utils.build_example, pool_args)
# sum all element of same index (column sum)
rsum = list(map(sum, list(zip(*r))))
ret[0] += rsum[0]
ret[1] += rsum[1]
ret[2] += rsum[2]
# If only-one flag is set, select one random board
if one_per_family:
for b in boards:
# skip if -b already specify one in this family
if find_family(b) == family:
return ret
all_boards = [random.choice(all_boards)]
# success, failed, skipped
all_examples = get_examples(family)
for board in all_boards:
r = [0, 0, 0]
if build_system == 'cmake':
r = build_board_cmake(board, toolchain)
elif build_system == 'make':
r = build_board_make_all_examples(board, toolchain, all_examples)
ret[0] += r[0]
ret[1] += r[1]
ret[2] += r[2]
return ret
@@ -131,12 +161,14 @@ def main():
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build')
parser.add_argument('-t', '--toolchain', default='gcc', help='Toolchain to use, default is gcc')
parser.add_argument('-s', '--build-system', default='cmake', help='Build system to use, default is cmake')
parser.add_argument('-1', '--one-per-family', action='store_true', default=False, help='Build only one random board inside a family')
args = parser.parse_args()
families = args.families
boards = args.board
toolchain = args.toolchain
build_system = args.build_system
one_per_family = args.one_per_family
if len(families) == 0 and len(boards) == 0:
print("Please specify families or board to build")
@@ -145,50 +177,42 @@ def main():
print(build_separator)
print(build_utils.build_format.format('Example', 'Board', '\033[39mResult\033[0m', 'Time', 'Flash', 'SRAM'))
total_time = time.monotonic()
total_result = [0, 0, 0]
result = [0, 0, 0]
# build families: cmake, make
if families is not None:
all_families = []
if 'all' in families:
for entry in os.scandir("hw/bsp"):
if entry.is_dir() and entry.name != 'espressif' and os.path.isfile(entry.path + "/family.cmake"):
all_families.append(entry.name)
else:
all_families = list(families)
all_families.sort()
# build families
all_families = []
if 'all' in families:
for entry in os.scandir("hw/bsp"):
if entry.is_dir() and entry.name != 'espressif' and os.path.isfile(entry.path + "/family.cmake"):
all_families.append(entry.name)
else:
all_families = list(families)
all_families.sort()
# succeeded, failed
for f in all_families:
fret = build_family(f, toolchain, build_system)
total_result[0] += fret[0]
total_result[1] += fret[1]
total_result[2] += fret[2]
# succeeded, failed
for f in all_families:
fret = build_family(f, toolchain, build_system, one_per_family, boards)
result[0] += fret[0]
result[1] += fret[1]
result[2] += fret[2]
# build board (only cmake)
if boards is not None:
for b in boards:
if build_system == 'cmake':
r = build_board_cmake(b, toolchain)
total_result[0] += r[0]
total_result[1] += r[1]
total_result[2] += r[2]
elif build_system == 'make':
all_examples = get_examples(find_family(b))
with Pool(processes=os.cpu_count()) as pool:
pool_args = list((map(lambda e, bb=b, o=f"TOOLCHAIN={toolchain}": [e, bb, o], all_examples)))
r = pool.starmap(build_utils.build_example, pool_args)
# sum all element of same index (column sum)
rsum = list(map(sum, list(zip(*r))))
total_result[0] += rsum[0]
total_result[1] += rsum[1]
total_result[2] += rsum[2]
# build boards
for b in boards:
r = [0, 0, 0]
if build_system == 'cmake':
r = build_board_cmake(b, toolchain)
elif build_system == 'make':
all_examples = get_examples(find_family(b))
r = build_board_make_all_examples(b, toolchain, all_examples)
result[0] += r[0]
result[1] += r[1]
result[2] += r[2]
total_time = time.monotonic() - total_time
print(build_separator)
print(f"Build Summary: {total_result[0]} {SUCCEEDED}, {total_result[1]} {FAILED} and took {total_time:.2f}s")
print(f"Build Summary: {result[0]} {SUCCEEDED}, {result[1]} {FAILED} and took {total_time:.2f}s")
print(build_separator)
return total_result[1]
return result[1]
if __name__ == '__main__':