diff --git a/tools/idf.py b/tools/idf.py index 60c002331f..bc4a556108 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -593,8 +593,8 @@ def init_cli(verbose_output=None): all_actions = {} # Load extensions from components dir idf_py_extensions_path = os.path.join(os.environ["IDF_PATH"], "tools", "idf_py_actions") - extra_pathes = os.environ.get("IDF_EXTRA_ACTIONS_PATH", "").split(';') - extension_dirs = [idf_py_extensions_path] + extra_pathes + extra_paths = os.environ.get("IDF_EXTRA_ACTIONS_PATH", "").split(';') + extension_dirs = [idf_py_extensions_path] + extra_paths extensions = {} for directory in extension_dirs: @@ -604,7 +604,7 @@ def init_cli(verbose_output=None): sys.path.append(directory) for _finder, name, _ispkg in sorted(iter_modules([directory])): - if name.startswith('idf_'): + if name.endswith('_ext'): extensions[name] = import_module(name) for name, extension in extensions.items(): diff --git a/tools/idf_py_actions/README.md b/tools/idf_py_actions/README.md index 8b6d2af697..a292495b36 100644 --- a/tools/idf_py_actions/README.md +++ b/tools/idf_py_actions/README.md @@ -1,5 +1,6 @@ # idf.py extensions -Python modules (subdirectories and files) in this directory named `idf_[your_extension]` will be loaded as idf.py extensions. +Python modules (subdirectories and files) in this directory named `[your_extension]_ext` will be loaded as idf.py extensions. +If you want to provide extra extensions just provide `;` separated list of directories with extensions in `IDF_EXTRA_ACTIONS_PATH`. Extensions will be loaded in alphanumeric order. Command line arguments parsing and extension mechanism is implemented on top of [Click](https://click.palletsprojects.com/en/5.x/) (versions >=5.0 are supported). They should define a function `action_extensions(base_actions, project_path)` where: diff --git a/tools/idf_py_actions/contstants.py b/tools/idf_py_actions/constants.py similarity index 100% rename from tools/idf_py_actions/contstants.py rename to tools/idf_py_actions/constants.py diff --git a/tools/idf_py_actions/idf_01_core_actions.py b/tools/idf_py_actions/core_ext.py similarity index 99% rename from tools/idf_py_actions/idf_01_core_actions.py rename to tools/idf_py_actions/core_ext.py index bf9daaf914..7f72a2de76 100644 --- a/tools/idf_py_actions/idf_01_core_actions.py +++ b/tools/idf_py_actions/core_ext.py @@ -4,7 +4,7 @@ import sys import click -from idf_py_actions.contstants import GENERATOR_CMDS, GENERATOR_VERBOSE, SUPPORTED_TARGETS +from idf_py_actions.constants import GENERATOR_CMDS, GENERATOR_VERBOSE, SUPPORTED_TARGETS from idf_py_actions.errors import FatalError from idf_py_actions.global_options import global_options from idf_py_actions.tools import ensure_build_directory, idf_version, merge_action_lists, realpath, run_tool diff --git a/tools/idf_py_actions/idf_02_serial_actions.py b/tools/idf_py_actions/serial_ext.py similarity index 100% rename from tools/idf_py_actions/idf_02_serial_actions.py rename to tools/idf_py_actions/serial_ext.py diff --git a/tools/idf_py_actions/tools.py b/tools/idf_py_actions/tools.py index 5ec6d8b971..bde47bd418 100644 --- a/tools/idf_py_actions/tools.py +++ b/tools/idf_py_actions/tools.py @@ -3,7 +3,7 @@ import re import subprocess import sys -from .contstants import GENERATORS +from .constants import GENERATORS from .errors import FatalError diff --git a/tools/test_idf_py/extra_path/idf_some_module.py b/tools/test_idf_py/extra_path/some_ext.py similarity index 100% rename from tools/test_idf_py/extra_path/idf_some_module.py rename to tools/test_idf_py/extra_path/some_ext.py diff --git a/tools/test_idf_py/test_idf_extensions/idf_test_extension/__init__.py b/tools/test_idf_py/test_idf_extensions/test_ext/__init__.py similarity index 100% rename from tools/test_idf_py/test_idf_extensions/idf_test_extension/__init__.py rename to tools/test_idf_py/test_idf_extensions/test_ext/__init__.py diff --git a/tools/test_idf_py/test_idf_extensions/idf_test_extension/test_extension.py b/tools/test_idf_py/test_idf_extensions/test_ext/test_extension.py similarity index 100% rename from tools/test_idf_py/test_idf_extensions/idf_test_extension/test_extension.py rename to tools/test_idf_py/test_idf_extensions/test_ext/test_extension.py diff --git a/tools/test_idf_py/test_idf_py.py b/tools/test_idf_py/test_idf_py.py index 672b76ac6b..60cc49453d 100755 --- a/tools/test_idf_py/test_idf_py.py +++ b/tools/test_idf_py/test_idf_py.py @@ -32,8 +32,8 @@ except ImportError: current_dir = os.path.dirname(os.path.realpath(__file__)) idf_py_path = os.path.join(current_dir, '..', 'idf.py') -extension_path = os.path.join(current_dir, 'test_idf_extensions', 'idf_test_extension') -link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'idf_test_extension') +extension_path = os.path.join(current_dir, 'test_idf_extensions', 'test_ext') +link_path = os.path.join(current_dir, '..', 'idf_py_actions', 'test_ext') class TestExtensions(unittest.TestCase):