summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCédric Berger <[email protected]>2026-02-22 21:39:14 +0100
committerGitHub <[email protected]>2026-02-22 21:39:14 +0100
commit942479407e3bfb4e0800aeb428dc2a3d03d77ded (patch)
treef6f65d88bfe1789f06c1d788994bb73f4871cc5f /tools
parent90d0514630d9b0f6d50881aabd82dcd613141f6b (diff)
parentdc072da5cc6a6b326a832f104c0a395d119ce35c (diff)
Merge branch 'hathach:master' into non-blocking-host-v2
Diffstat (limited to 'tools')
-rwxr-xr-xtools/build.py60
-rwxr-xr-xtools/get_deps.py6
2 files changed, 31 insertions, 35 deletions
diff --git a/tools/build.py b/tools/build.py
index d22d06a0b..3c5c3c077 100755
--- a/tools/build.py
+++ b/tools/build.py
@@ -24,7 +24,6 @@ build_separator = '-' * 95
build_status = [STATUS_OK, STATUS_FAILED, STATUS_SKIPPED]
verbose = False
-clean_build = False
parallel_jobs = os.cpu_count()
# CI board control lists (used when running under CI)
@@ -98,15 +97,15 @@ def get_examples(family):
return all_examples
-def print_build_result(board, example, status, duration):
+def print_build_result(board, build_target, status, duration):
if isinstance(duration, (int, float)):
duration = "{:.2f}s".format(duration)
- print(build_format.format(board, example, build_status[status], duration))
+ print(build_format.format(board, build_target, build_status[status], duration))
# -----------------------------
# CMake
# -----------------------------
-def cmake_board(board, build_args, build_flags_on):
+def cmake_board(board, build_args, build_flags_on, build_targets):
ret = [0, 0, 0]
start_time = time.monotonic()
@@ -135,39 +134,36 @@ def cmake_board(board, build_args, build_flags_on):
f'-DBOARD={board}', '-DCMAKE_BUILD_TYPE=MinSizeRel', '-DLINKERMAP_OPTION=-q -f tinyusb/src',
*build_args, *build_flags])
if rcmd.returncode == 0:
- if clean_build:
- run_cmd(["cmake", "--build", build_dir, '--target', 'clean'])
cmd = ["cmake", "--build", build_dir, '--parallel', str(parallel_jobs)]
- rcmd = run_cmd(cmd)
- if rcmd.returncode == 0:
- ret[0] += 1
- run_cmd(["cmake", "--build", build_dir, '--target', 'tinyusb_metrics'])
- # print(rcmd.stdout.decode("utf-8"))
- else:
- ret[1] += 1
+ for target in build_targets:
+ rcmd = run_cmd(cmd + ['--target', target])
+ if rcmd.returncode != 0:
+ break
+ ret[0 if rcmd.returncode == 0 else 1] += 1
- example = 'all'
- print_build_result(board, example, 0 if ret[1] == 0 else 1, time.monotonic() - start_time)
+ print_build_result(board, ','.join(build_targets), 0 if ret[1] == 0 else 1, time.monotonic() - start_time)
return ret
# -----------------------------
# Make
# -----------------------------
-def make_one_example(example, board, make_option):
+def make_one_example(example, board, make_option, build_targets):
# Check if board is skipped
if build_utils.skip_example(example, board):
print_build_result(board, example, 2, '-')
r = 2
else:
start_time = time.monotonic()
- make_args = ["make", "-C", f"examples/{example}", f"BOARD={board}", '-j', str(parallel_jobs)]
+ make_cmd = ["make", "-C", f"examples/{example}", f"BOARD={board}", '-j', str(parallel_jobs)]
if make_option:
- make_args += shlex.split(make_option)
- if clean_build:
- run_cmd(make_args + ["clean"])
- build_result = run_cmd(make_args + ['all'])
- r = 0 if build_result.returncode == 0 else 1
+ make_cmd += shlex.split(make_option)
+ r = 0
+ for target in build_targets:
+ build_result = run_cmd(make_cmd + [target])
+ if build_result.returncode != 0:
+ r = 1
+ break
print_build_result(board, example, r, time.monotonic() - start_time)
ret = [0, 0, 0]
@@ -175,7 +171,7 @@ def make_one_example(example, board, make_option):
return ret
-def make_board(board, build_args):
+def make_board(board, build_args, build_targets):
print(build_separator)
family = find_family(board);
all_examples = get_examples(family)
@@ -186,7 +182,7 @@ def make_board(board, build_args):
final_status = 2
else:
with Pool(processes=os.cpu_count()) as pool:
- pool_args = list((map(lambda e, b=board, o=f"{build_args}": [e, b, o], all_examples)))
+ pool_args = list((map(lambda e, b=board, o=f"{build_args}", t=build_targets: [e, b, o, t], 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))))
@@ -198,16 +194,16 @@ def make_board(board, build_args):
# -----------------------------
# Build Family
# -----------------------------
-def build_boards_list(boards, build_defines, build_system, build_flags_on):
+def build_boards_list(boards, build_defines, build_system, build_flags_on, build_targets):
ret = [0, 0, 0]
for b in boards:
r = [0, 0, 0]
if build_system == 'cmake':
build_args = [f'-D{d}' for d in build_defines]
- r = cmake_board(b, build_args, build_flags_on)
+ r = cmake_board(b, build_args, build_flags_on, build_targets)
elif build_system == 'make':
build_args = ' '.join(f'{d}' for d in build_defines)
- r = make_board(b, build_args)
+ r = make_board(b, build_args, build_targets)
ret[0] += r[0]
ret[1] += r[1]
ret[2] += r[2]
@@ -257,13 +253,11 @@ def get_family_boards(family, one_random, one_first):
# -----------------------------
def main():
global verbose
- global clean_build
global parallel_jobs
parser = argparse.ArgumentParser()
parser.add_argument('families', nargs='*', default=[], help='Families to build')
parser.add_argument('-b', '--board', action='append', default=[], help='Boards to build')
- parser.add_argument('-c', '--clean', action='store_true', default=False, help='Clean before 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')
@@ -273,6 +267,8 @@ def main():
parser.add_argument('--one-first', action='store_true', default=False,
help='Build only the first board (alphabetical) of each specified family')
parser.add_argument('-j', '--jobs', type=int, default=os.cpu_count(), help='Number of jobs to run in parallel')
+ parser.add_argument('-T', '--target', action='append', default=[],
+ help='Build target to use, may be specified multiple times (default: all)')
parser.add_argument('-v', '--verbose', action='store_true', help='Verbose output')
args = parser.parse_args()
@@ -284,8 +280,8 @@ def main():
build_flags_on = args.build_flags_on
one_random = args.one_random
one_first = args.one_first
+ build_targets = args.target if args.target else ['all']
verbose = args.verbose
- clean_build = args.clean
parallel_jobs = args.jobs
build_defines.append(f'TOOLCHAIN={toolchain}')
@@ -295,7 +291,7 @@ def main():
return 1
print(build_separator)
- print(build_format.format('Board', 'Example', '\033[39mResult\033[0m', 'Time'))
+ print(build_format.format('Board', 'Target', '\033[39mResult\033[0m', 'Time'))
total_time = time.monotonic()
# get all families
@@ -314,7 +310,7 @@ def main():
all_boards.extend(get_family_boards(f, one_random, one_first))
# build all boards
- result = build_boards_list(all_boards, build_defines, build_system, build_flags_on)
+ result = build_boards_list(all_boards, build_defines, build_system, build_flags_on, build_targets)
total_time = time.monotonic() - total_time
print(build_separator)
diff --git a/tools/get_deps.py b/tools/get_deps.py
index 954b2ece7..1d596469b 100755
--- a/tools/get_deps.py
+++ b/tools/get_deps.py
@@ -45,7 +45,7 @@ deps_optional = {
'xmc4000'],
'hw/mcu/microchip': ['https://github.com/hathach/microchip_driver.git',
'9e8b37e307d8404033bb881623a113931e1edf27',
- 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg'],
+ 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x samd2x_l2x samg'],
'hw/mcu/mindmotion/mm32sdk': ['https://github.com/hathach/mm32sdk.git',
'b93e856211060ae825216c6a1d6aa347ec758843',
'mm32'],
@@ -252,11 +252,11 @@ deps_optional = {
'hpmicro'],
'lib/CMSIS_5': ['https://github.com/ARM-software/CMSIS_5.git',
'2b7495b8535bdcb306dac29b9ded4cfb679d7e5c',
- 'imxrt kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx rw61x mm32 msp432e4 nrf saml2x '
+ 'imxrt kinetis_k kinetis_k32l2 kinetis_kl lpc51 lpc54 lpc55 mcx rw61x mm32 msp432e4 nrf samd2x_l2x '
'lpc11 lpc13 lpc15 lpc17 lpc18 lpc40 lpc43 '
'stm32c0 stm32f0 stm32f1 stm32f2 stm32f3 stm32f4 stm32f7 stm32g0 stm32g4 stm32h5 '
'stm32h7 stm32h7rs stm32l0 stm32l1 stm32l4 stm32l5 stm32u0 stm32u5 stm32wb stm32wba '
- 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x saml2x samg '
+ 'sam3x samd11 samd21 samd51 samd5x_e5x same5x same7x samd2x_l2x samg '
'tm4c '],
'lib/CMSIS_6': ['https://github.com/ARM-software/CMSIS_6.git',
'6f0a58d01aa9bd2feba212097f9afe7acd991d52',