summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorhathach <[email protected]>2026-03-06 12:05:54 +0700
committerhathach <[email protected]>2026-03-06 12:05:54 +0700
commit558abb93af64eda51420d5bfe03355c89e4b421a (patch)
tree237e3a81563dc0edf081616f4152d965550371e6 /tools
parentdbfbfcf48b45ccc1e6534c454f7b2807b9ae88bd (diff)
parent06a4c6d7190ef83f76b2a65496f2a48a54a8c134 (diff)
Merge branch 'refs/heads/master' into fork/remiberthoz/device-class-printer
Diffstat (limited to 'tools')
-rwxr-xr-xtools/build.py60
-rw-r--r--tools/codespell/ignore-words.txt21
-rwxr-xr-xtools/get_deps.py35
3 files changed, 53 insertions, 63 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/codespell/ignore-words.txt b/tools/codespell/ignore-words.txt
index 957cbd86b..5b6e2e98b 100644
--- a/tools/codespell/ignore-words.txt
+++ b/tools/codespell/ignore-words.txt
@@ -1,14 +1,15 @@
-synopsys
-sie
-tre
-thre
-hsi
-fro
-dout
-mot
-te
attch
+busses
+dout
endianess
+fro
+hsi
+inout
+mot
pris
-busses
ser
+sie
+synopsys
+te
+thre
+tre
diff --git a/tools/get_deps.py b/tools/get_deps.py
index 773445adc..696914251 100755
--- a/tools/get_deps.py
+++ b/tools/get_deps.py
@@ -14,6 +14,9 @@ deps_mandatory = {
'lib/lwip': ['https://github.com/lwip-tcpip/lwip.git',
'159e31b689577dbf69cf0683bbaffbd71fa5ee10',
'all'],
+ 'lib/threadx': ['https://github.com/eclipse-threadx/threadx.git',
+ '4b6e8100d932a3a67b34c6eb17f84f3bffb9e2ae',
+ 'all'],
'tools/linkermap': ['https://github.com/hathach/linkermap.git',
'8e1f440fa15c567aceb5aa0d14f6d18c329cc67f',
'all'],
@@ -45,7 +48,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'],
@@ -209,7 +212,7 @@ deps_optional = {
'9442fbb71f855ff2e64fbf662b7726beba511a24',
'stm32wba'],
'hw/mcu/ti': ['https://github.com/hathach/ti_driver.git',
- '143ed6cc20a7615d042b03b21e070197d473e6e5',
+ '083944907e7d08fcb1f614b47598ce45935b8da1',
'msp430 msp432e4 tm4c'],
'hw/mcu/wch/ch32v103': ['https://github.com/openwch/ch32v103.git',
'7578cae0b21f86dd053a1f781b2fc6ab99d0ec17',
@@ -252,11 +255,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',
@@ -330,18 +333,16 @@ def main():
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()
families = args.families
boards = args.board
- print_only = args.print
status = 0
- deps = list(deps_mandatory.keys())
+ deps = []
if 'all' in families:
- deps += deps_optional.keys()
+ deps.extend(deps_optional.keys())
else:
families = list(families)
if boards is not None:
@@ -349,24 +350,16 @@ def main():
f = find_family(b)
if f is not None:
families.append(f)
-
for f in families:
for d in deps_optional:
if d not in deps and f in deps_optional[d][2].split():
deps.append(d)
+ if len(deps) == 0:
+ print('WARN: no additional dependencies found for given boards or families')
- if print_only:
- pvalue = {}
- # print only without arguments, always add CMSIS_5
- if len(families) == 0 and len(boards) == 0:
- deps.append('lib/CMSIS_5')
- for d in deps:
- commit = deps_all[d][1]
- pvalue[d] = commit
- print(pvalue)
- else:
- with Pool() as pool:
- status = sum(pool.map(get_a_dep, deps))
+ deps.extend(deps_mandatory.keys())
+ with Pool() as pool:
+ status = sum(pool.map(get_a_dep, deps))
return status