add option to pass symbol defines to ci build.py
add build.args option for hil json add MAX3421_HOST=1 for metro m4 express
This commit is contained in:
@@ -3,9 +3,6 @@ set(SAM_FAMILY samd51)
|
||||
set(JLINK_DEVICE ATSAMD51J19)
|
||||
set(LD_FILE_GNU ${CMAKE_CURRENT_LIST_DIR}/${BOARD}.ld)
|
||||
|
||||
# force max3421e for testing with hardware-in-the-loop
|
||||
set(MAX3421_HOST 1)
|
||||
|
||||
function(update_board TARGET)
|
||||
target_compile_definitions(${TARGET} PUBLIC
|
||||
__SAMD51J19A__
|
||||
|
@@ -28,14 +28,20 @@ def main():
|
||||
else:
|
||||
toolchain = 'arm-gcc'
|
||||
|
||||
if 'build' in board and 'flags_on' in board['build']:
|
||||
for f in board['build']['flags_on']:
|
||||
if f == '':
|
||||
matrix[toolchain].append(f'-b {name}')
|
||||
else:
|
||||
matrix[toolchain].append(f'-b {name} -f1 {f.replace(" ", " -f1 ")}')
|
||||
build_board = f'-b {name}'
|
||||
if 'build' in board:
|
||||
if 'args' in board['build']:
|
||||
build_board += ' ' + ' '.join(f'-D{a}' for a in board['build']['args'])
|
||||
if 'flags_on' in board['build']:
|
||||
for f in board['build']['flags_on']:
|
||||
if f == '':
|
||||
matrix[toolchain].append(build_board)
|
||||
else:
|
||||
matrix[toolchain].append(f'{build_board} -f1 {f.replace(" ", " -f1 ")}')
|
||||
else:
|
||||
matrix[toolchain].append(build_board)
|
||||
else:
|
||||
matrix[toolchain].append(f'-b {name}')
|
||||
matrix[toolchain].append(build_board)
|
||||
|
||||
print(json.dumps(matrix))
|
||||
|
||||
|
@@ -61,6 +61,9 @@
|
||||
{
|
||||
"name": "metro_m4_express",
|
||||
"uid": "9995AD485337433231202020FF100A34",
|
||||
"build" : {
|
||||
"args": ["MAX3421_HOST=1"]
|
||||
},
|
||||
"tests": {
|
||||
"device": true, "host": false, "dual": true,
|
||||
"dev_attached": [{"vid_pid": "1a86_55d4", "serial": "52D2002130"}]
|
||||
|
@@ -82,7 +82,7 @@ def print_build_result(board, example, status, duration):
|
||||
# -----------------------------
|
||||
# CMake
|
||||
# -----------------------------
|
||||
def cmake_board(board, toolchain, build_flags_on):
|
||||
def cmake_board(board, build_args, build_flags_on):
|
||||
ret = [0, 0, 0]
|
||||
start_time = time.monotonic()
|
||||
|
||||
@@ -106,7 +106,7 @@ def cmake_board(board, toolchain, build_flags_on):
|
||||
ret[0 if rcmd.returncode == 0 else 1] += 1
|
||||
else:
|
||||
rcmd = run_cmd(f'cmake examples -B {build_dir} -G Ninja -DBOARD={board} -DCMAKE_BUILD_TYPE=MinSizeRel '
|
||||
f'-DTOOLCHAIN={toolchain} {build_flags}')
|
||||
f'{build_args} {build_flags}')
|
||||
if rcmd.returncode == 0:
|
||||
cmd = f"cmake --build {build_dir}"
|
||||
njobs = parallel_jobs
|
||||
@@ -152,7 +152,7 @@ def make_one_example(example, board, make_option):
|
||||
return ret
|
||||
|
||||
|
||||
def make_board(board, toolchain):
|
||||
def make_board(board, build_args):
|
||||
print(build_separator)
|
||||
family = find_family(board);
|
||||
all_examples = get_examples(family)
|
||||
@@ -163,7 +163,7 @@ def make_board(board, toolchain):
|
||||
final_status = 2
|
||||
else:
|
||||
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)))
|
||||
pool_args = list((map(lambda e, b=board, o=f"{build_args}": [e, b, o], all_examples)))
|
||||
r = pool.starmap(make_one_example, pool_args)
|
||||
# sum all element of same index (column sum)
|
||||
ret = list(map(sum, list(zip(*r))))
|
||||
@@ -175,21 +175,23 @@ def make_board(board, toolchain):
|
||||
# -----------------------------
|
||||
# Build Family
|
||||
# -----------------------------
|
||||
def build_boards_list(boards, toolchain, build_system, build_flags_on):
|
||||
def build_boards_list(boards, build_defines, build_system, build_flags_on):
|
||||
ret = [0, 0, 0]
|
||||
for b in boards:
|
||||
r = [0, 0, 0]
|
||||
if build_system == 'cmake':
|
||||
r = cmake_board(b, toolchain, build_flags_on)
|
||||
build_args = ' '.join(f'-D{d}' for d in build_defines)
|
||||
r = cmake_board(b, build_args, build_flags_on)
|
||||
elif build_system == 'make':
|
||||
r = make_board(b, toolchain)
|
||||
build_args = ' '.join(f'{d}' for d in build_defines)
|
||||
r = make_board(b, build_args)
|
||||
ret[0] += r[0]
|
||||
ret[1] += r[1]
|
||||
ret[2] += r[2]
|
||||
return ret
|
||||
|
||||
|
||||
def build_family(family, toolchain, build_system, build_flags_on, one_per_family, boards):
|
||||
def build_family(family, build_defines, build_system, build_flags_on, one_per_family, boards):
|
||||
skip_ci = ['pico_sdk']
|
||||
if os.getenv('GITHUB_ACTIONS') or os.getenv('CIRCLECI'):
|
||||
skip_ci_file = Path(f"hw/bsp/{family}/skip_ci.txt")
|
||||
@@ -210,7 +212,7 @@ def build_family(family, toolchain, build_system, build_flags_on, one_per_family
|
||||
return ret
|
||||
all_boards = [random.choice(all_boards)]
|
||||
|
||||
ret = build_boards_list(all_boards, toolchain, build_system, build_flags_on)
|
||||
ret = build_boards_list(all_boards, build_defines, build_system, build_flags_on)
|
||||
return ret
|
||||
|
||||
|
||||
@@ -226,6 +228,7 @@ 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('-D', '--define-symbol', action='append', default=[], help='Define to pass to build system')
|
||||
parser.add_argument('-f1', '--build-flags-on', action='append', default=[], help='Build flag to pass to build system')
|
||||
parser.add_argument('-1', '--one-per-family', action='store_true', default=False, help='Build only one random board inside a family')
|
||||
parser.add_argument('-j', '--jobs', type=int, default=os.cpu_count(), help='Number of jobs to run in parallel')
|
||||
@@ -236,11 +239,14 @@ def main():
|
||||
boards = args.board
|
||||
toolchain = args.toolchain
|
||||
build_system = args.build_system
|
||||
build_defines = args.define_symbol
|
||||
build_flags_on = args.build_flags_on
|
||||
one_per_family = args.one_per_family
|
||||
verbose = args.verbose
|
||||
parallel_jobs = args.jobs
|
||||
|
||||
build_defines.append(f'TOOLCHAIN={toolchain}')
|
||||
|
||||
if len(families) == 0 and len(boards) == 0:
|
||||
print("Please specify families or board to build")
|
||||
return 1
|
||||
@@ -262,13 +268,13 @@ def main():
|
||||
|
||||
# succeeded, failed, skipped
|
||||
for f in all_families:
|
||||
r = build_family(f, toolchain, build_system, build_flags_on, one_per_family, boards)
|
||||
r = build_family(f, build_defines, build_system, build_flags_on, one_per_family, boards)
|
||||
result[0] += r[0]
|
||||
result[1] += r[1]
|
||||
result[2] += r[2]
|
||||
|
||||
# build boards
|
||||
r = build_boards_list(boards, toolchain, build_system, build_flags_on)
|
||||
r = build_boards_list(boards, build_defines, build_system, build_flags_on)
|
||||
result[0] += r[0]
|
||||
result[1] += r[1]
|
||||
result[2] += r[2]
|
||||
|
@@ -286,6 +286,7 @@ def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('families', nargs='*', default=[], help='Families to fetch')
|
||||
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to fetch')
|
||||
parser.add_argument('-D', '--define', action='append', default=[], help='Have no effect')
|
||||
parser.add_argument('-f1', '--build-flags-on', action='append', default=[], help='Have no effect')
|
||||
parser.add_argument('--print', action='store_true', help='Print commit hash only')
|
||||
args = parser.parse_args()
|
||||
|
Reference in New Issue
Block a user