2019-01-23 08:31:06 -07:00
|
|
|
# Copyright (c) 2017 Linaro Limited.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
2021-02-23 13:45:38 -08:00
|
|
|
import importlib
|
|
|
|
import logging
|
|
|
|
|
2024-11-23 12:27:03 +01:00
|
|
|
from runners.core import MissingProgram, ZephyrBinaryRunner
|
2019-01-23 08:31:06 -07:00
|
|
|
|
2021-02-23 13:45:38 -08:00
|
|
|
_logger = logging.getLogger('runners')
|
|
|
|
|
|
|
|
def _import_runner_module(runner_name):
|
|
|
|
try:
|
|
|
|
importlib.import_module(f'runners.{runner_name}')
|
2021-03-17 18:35:48 +00:00
|
|
|
except ImportError as ie:
|
2021-02-23 13:45:38 -08:00
|
|
|
# Runners are supposed to gracefully handle failures when they
|
|
|
|
# import anything outside of stdlib, but they sometimes do
|
|
|
|
# not. Catch ImportError to handle this.
|
|
|
|
_logger.warning(f'The module for runner "{runner_name}" '
|
2021-03-17 18:35:48 +00:00
|
|
|
f'could not be imported ({ie}). This most likely '
|
|
|
|
'means it is not handling its dependencies properly. '
|
2021-02-23 13:45:38 -08:00
|
|
|
'Please report this to the zephyr developers.')
|
|
|
|
|
2019-01-23 08:31:06 -07:00
|
|
|
# We import these here to ensure the ZephyrBinaryRunner subclasses are
|
2020-08-21 16:04:56 -07:00
|
|
|
# defined; otherwise, ZephyrBinaryRunner.get_runners() won't work.
|
2019-01-23 08:31:06 -07:00
|
|
|
|
2021-02-23 13:45:38 -08:00
|
|
|
_names = [
|
2024-10-18 15:17:06 +02:00
|
|
|
# zephyr-keep-sorted-start
|
2025-04-24 14:54:35 +02:00
|
|
|
'bflb_mcu_tool',
|
2021-02-23 13:45:38 -08:00
|
|
|
'blackmagicprobe',
|
|
|
|
'bossac',
|
|
|
|
'canopen_program',
|
|
|
|
'dediprog',
|
|
|
|
'dfu',
|
2024-11-16 22:13:20 +01:00
|
|
|
'ecpprog',
|
2021-02-23 13:45:38 -08:00
|
|
|
'esp32',
|
2022-05-12 11:51:08 +02:00
|
|
|
'ezflashcli',
|
2021-09-17 18:29:36 -03:00
|
|
|
'gd32isp',
|
2021-02-23 13:45:38 -08:00
|
|
|
'hifive1',
|
2022-04-06 09:18:53 +08:00
|
|
|
'intel_adsp',
|
2022-04-26 10:54:26 +01:00
|
|
|
'intel_cyclonev',
|
2021-02-23 13:45:38 -08:00
|
|
|
'jlink',
|
2023-05-17 15:54:55 -05:00
|
|
|
'linkserver',
|
2021-02-23 13:45:38 -08:00
|
|
|
'mdb',
|
2024-06-01 22:58:27 +05:30
|
|
|
'minichlink',
|
2021-02-23 13:45:38 -08:00
|
|
|
'misc',
|
2024-02-09 20:32:37 -05:00
|
|
|
'native',
|
2021-02-23 13:45:38 -08:00
|
|
|
'nrfjprog',
|
2023-03-07 11:09:13 +01:00
|
|
|
'nrfutil',
|
2021-02-23 13:45:38 -08:00
|
|
|
'nsim',
|
2023-09-05 10:43:46 +07:00
|
|
|
'nxp_s32dbg',
|
2021-02-23 13:45:38 -08:00
|
|
|
'openocd',
|
2024-04-17 13:21:29 +08:00
|
|
|
'probe_rs',
|
2021-02-23 13:45:38 -08:00
|
|
|
'pyocd',
|
2024-10-18 15:17:06 +02:00
|
|
|
'qemu',
|
2024-03-07 10:30:09 +01:00
|
|
|
'renode',
|
2024-03-07 10:35:06 +01:00
|
|
|
'renode-robot',
|
2025-03-27 14:55:01 -06:00
|
|
|
'rfp',
|
2023-03-31 17:13:32 +02:00
|
|
|
'silabs_commander',
|
2021-05-20 17:31:35 +03:00
|
|
|
'spi_burn',
|
2025-05-09 13:57:16 +08:00
|
|
|
'spsdk',
|
2021-02-23 13:45:38 -08:00
|
|
|
'stm32cubeprogrammer',
|
|
|
|
'stm32flash',
|
2025-03-20 12:19:33 +01:00
|
|
|
'sy1xx',
|
2024-01-21 22:44:08 +01:00
|
|
|
'teensy',
|
2022-08-07 04:25:52 +07:00
|
|
|
'trace32',
|
2023-01-30 00:50:57 -05:00
|
|
|
'uf2',
|
2024-09-25 10:53:01 +05:30
|
|
|
'xsdb',
|
2021-02-23 13:45:38 -08:00
|
|
|
'xtensa',
|
2024-10-18 15:17:06 +02:00
|
|
|
# zephyr-keep-sorted-stop
|
2021-02-23 13:45:38 -08:00
|
|
|
]
|
|
|
|
|
|
|
|
for _name in _names:
|
|
|
|
_import_runner_module(_name)
|
2019-01-23 08:31:06 -07:00
|
|
|
|
|
|
|
def get_runner_cls(runner):
|
|
|
|
'''Get a runner's class object, given its name.'''
|
|
|
|
for cls in ZephyrBinaryRunner.get_runners():
|
|
|
|
if cls.name() == runner:
|
|
|
|
return cls
|
2024-11-20 16:05:28 +01:00
|
|
|
raise ValueError(f'unknown runner "{runner}"')
|
2019-01-23 08:31:06 -07:00
|
|
|
|
2024-11-23 12:27:03 +01:00
|
|
|
__all__ = ['ZephyrBinaryRunner', 'MissingProgram', 'get_runner_cls']
|