automation: Add automation.analyze task
This can be used to start a static code analysis for a instance.
(Only supported for stm32cube and nrfconnect at the moment)
@@ -26,6 +26,7 @@ class Command(Enum):
FLASH = 2
LOG = 3
TEST = 4
+ STATIC_ANALYZE = 5
def eprint(*args, **kwargs):
"""Helper function for writing to stderr"""
@@ -65,6 +66,12 @@ def instance_command(ctx, instance_str, cmd):
toolchain = u_data.get_toolchain_for_instance(db_data, instance)
description = u_data.get_description_for_instance(db_data, instance)
+ # CodeChecker needs some special handling but will only change the
+ # "TEST" command to "STATIC_ANALYZE"
+ if platform.lower().startswith("codechecker:") and cmd == Command.TEST:
+ cmd = Command.STATIC_ANALYZE
+ platform = platform.split(":", 2)[1]
+
# Defines may be provided via an environment
# variable, in a list separated with semicolons, e.g.:
# set U_UBXLIB_DEFINES=THING_1;ANOTHER_THING=123;ONE_MORE=boo
@@ -121,6 +128,8 @@ def instance_command(ctx, instance_str, cmd):
nrfconnect.log(ctx, output_name="", build_dir=ctx.build_dir, debugger_serial=serial)
elif cmd == Command.TEST:
check_return_code(u_run_log.run(instance, ctx.build_dir, ctx.reporter, ctx.test_report))
+ elif cmd == Command.STATIC_ANALYZE:
+ nrfconnect.analyze(ctx, board_name=board, output_name="", build_dir=ctx.build_dir, u_flags=defines)
else:
raise Exit(f"Unsupported command for MCU '{mcu}' on platform: '{platform}'")
else:
