1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:52:44 +01:00

tools/compile_like_murdock: Add -m to only check mod/pkgs

This commit is contained in:
MrKevinWeiss 2023-03-06 15:13:46 +01:00
parent df3f0ce71c
commit c9cfd27d3b

View File

@ -134,16 +134,28 @@ def _end(sec, job):
print(f"You could have {val} {thing}")
def __exec_cmd(cmd, shell=False, env=None, cwd=None,
stderr=subprocess.DEVNULL):
out = subprocess.run(
cmd,
shell=shell,
env=env,
cwd=cwd,
stderr=stderr,
check=True,
stdout=subprocess.PIPE,
).stdout
return out.decode("utf-8", errors="replace")
def _all_apps(cwd):
cmd = ['make', 'info-applications', '--no-print-directory']
out = subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.DEVNULL)
return out.decode("utf-8", errors="replace").split()
cmd = ('make', 'info-applications', '--no-print-directory')
return __exec_cmd(cmd, cwd=cwd).split()
def _supported_boards(boards, env, cwd, all_boards=False):
cmd = ['make', 'info-boards-supported', '--no-print-directory']
out = subprocess.check_output(cmd, env=env, cwd=cwd, stderr=subprocess.DEVNULL)
supported_boards = out.decode("utf-8", errors="replace").split()
cmd = ('make', 'info-boards-supported', '--no-print-directory')
supported_boards = __exec_cmd(cmd, env=env, cwd=cwd).split()
if all_boards:
return supported_boards
return [brd for brd in supported_boards if brd in boards]
@ -152,17 +164,42 @@ def _supported_boards(boards, env, cwd, all_boards=False):
def _supported_boards_from_cpu(cpu, env, cwd):
cmd = (f'FEATURES_REQUIRED=cpu_{cpu} make info-boards-supported '
'--no-print-directory')
out = subprocess.check_output(cmd, shell=True, env=env, cwd=cwd, stderr=subprocess.DEVNULL)
return out.decode("utf-8", errors="replace").split()
__exec_cmd(cmd, shell=True, env=env, cwd=cwd).split()
def _print_module_or_pkg_mismatch(app, board, lines, args):
if args.verbose:
for line in lines:
# Reprint the < and > from diff to show if kconfig or make are
# responsible
if line.startswith('< '):
print(" make has:", line[2:])
if line.startswith('> '):
print(" kconfig has:", line[2:])
print(f"{app: <30} {board: <30} FAIL: Kconfig module or pkg mismatch")
def _modules_packages(app, board, jobs, env, cwd, args):
cmd = (f'/bin/bash -c "source .murdock; JOBS={jobs} '
f'kconfig_module_packages_diff {board} {app}"')
try:
out = __exec_cmd(cmd, shell=True, env=env, cwd=cwd,
stderr=subprocess.STDOUT)
if args.very_very_verbose:
print(out)
print(f"{app: <30} {board: <30} PASS")
except subprocess.CalledProcessError as err:
err.output = err.output.decode("utf-8", errors="replace")
lines = err.output.split("\n")
_print_module_or_pkg_mismatch(app, board, lines, args)
def _build(app, board, jobs, env, cwd, args):
cmd = (f'/bin/bash -c "source .murdock; JOBS={jobs} '
f'compile {app} {board}:gnu"')
try:
out = subprocess.check_output(cmd, env=env, shell=True,
cwd=cwd, stderr=subprocess.STDOUT)
out = out.decode("utf-8", errors="replace")
out = __exec_cmd(cmd, shell=True, env=env, cwd=cwd,
stderr=subprocess.STDOUT)
if args.very_very_verbose:
print(out)
print(f"{app: <30} {board: <30} PASS")
@ -171,15 +208,9 @@ def _build(app, board, jobs, env, cwd, args):
lines = err.output.split("\n")
if args.very_very_verbose or args.very_verbose:
print(err.output)
# Check for known diff error outputs
if lines[-3].startswith('< ') or lines[-3].startswith('> '):
if args.verbose:
for line in lines:
if line.startswith('< '):
print("make has:", line[2:])
if line.startswith('> '):
print("kconfig has:", line[2:])
print(f"{app: <30} {board: <30} FAIL: Kconfig module or pkg "
"mismatch")
_print_module_or_pkg_mismatch(app, board, lines, args)
elif "mismatch" in err.output:
print(f"{app: <30} {board: <30} FAIL: Kconfig hash mismatch")
else:
@ -209,6 +240,8 @@ def main():
" without spending super long to compile them"))
parser.add_argument("-j", "--jobs", type=int, default=4,
help=("The amount of jobs to use when compiling."))
parser.add_argument("-m", "--modules-packages", action="store_true",
help=("Only check the diff of modules and packages."))
parser.add_argument("-v", "--verbose", action="store_true",
help=("Shows mismatch info."))
parser.add_argument("-vv", "--very-verbose", action="store_true",
@ -239,10 +272,14 @@ def main():
elif args.boards[0] == "all":
target_boards = _supported_boards(boards, full_env, test_dir, True)
else:
target_boards = _supported_boards(boards, full_env, test_dir, False)
target_boards = _supported_boards(boards, full_env, test_dir,
False)
for board in target_boards:
if args.dry_run:
print(f"{app: <30} {board: <30}")
elif args.modules_packages:
_modules_packages(app, board, args.jobs, full_env, riot_dir,
args)
else:
_build(app, board, args.jobs, full_env, riot_dir, args)
elapse_time = datetime.datetime.now() - start_time