idf-build-apps 2.3.1__tar.gz → 2.4.1.dev0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.pre-commit-config.yaml +2 -0
  2. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/CHANGELOG.md +13 -0
  3. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/PKG-INFO +5 -2
  4. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/README.md +3 -1
  5. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/manifest.md +31 -2
  6. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/__init__.py +1 -1
  7. idf_build_apps-2.4.1.dev0/idf_build_apps/autocompletions.py +54 -0
  8. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/constants.py +35 -1
  9. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/main.py +66 -8
  10. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/manifest/soc_header.py +16 -10
  11. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/utils.py +4 -0
  12. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/pyproject.toml +2 -1
  13. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/setup.py +2 -2
  14. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.editorconfig +0 -0
  15. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.git-blame-ignore-revs +0 -0
  16. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.gitattributes +0 -0
  17. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/dependabot.yml +0 -0
  18. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/check-pre-commit.yml +0 -0
  19. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/issue_comment.yml +0 -0
  20. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/new_issues.yml +0 -0
  21. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/new_prs.yml +0 -0
  22. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/publish-pypi.yml +0 -0
  23. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/test-build-docs.yml +0 -0
  24. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.github/workflows/test-build-idf-apps.yml +0 -0
  25. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.gitignore +0 -0
  26. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/.readthedocs.yml +0 -0
  27. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/CONTRIBUTING.md +0 -0
  28. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/LICENSE +0 -0
  29. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/CHANGELOG.md +0 -0
  30. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/CONTRIBUTING.md +0 -0
  31. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/Makefile +0 -0
  32. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_apidoc_templates/module.rst_t +0 -0
  33. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_apidoc_templates/package.rst_t +0 -0
  34. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_apidoc_templates/toc.rst_t +0 -0
  35. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_static/espressif-logo.svg +0 -0
  36. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_static/theme_overrides.css +0 -0
  37. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/_templates/layout.html +0 -0
  38. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/cli.rst +0 -0
  39. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/conf.py +0 -0
  40. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/config_file.md +0 -0
  41. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/find_build.md +0 -0
  42. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/index.rst +0 -0
  43. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/docs/migration/1.x_to_2.x.md +0 -0
  44. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/__main__.py +0 -0
  45. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/app.py +0 -0
  46. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/build_apps_args.py +0 -0
  47. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/config.py +0 -0
  48. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/finder.py +0 -0
  49. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/junit/__init__.py +0 -0
  50. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/junit/report.py +0 -0
  51. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/junit/utils.py +0 -0
  52. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/log.py +0 -0
  53. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/manifest/__init__.py +0 -0
  54. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/manifest/if_parser.py +0 -0
  55. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/manifest/manifest.py +0 -0
  56. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/session_args.py +0 -0
  57. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/yaml/__init__.py +0 -0
  58. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/idf_build_apps/yaml/parser.py +0 -0
  59. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/license_header.txt +0 -0
  60. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/conftest.py +0 -0
  61. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/test_app.py +0 -0
  62. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/test_build.py +0 -0
  63. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/test_finder.py +0 -0
  64. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/test_manifest.py +0 -0
  65. {idf_build_apps-2.3.1 → idf_build_apps-2.4.1.dev0}/tests/test_utils.py +0 -0
@@ -35,3 +35,5 @@ repos:
35
35
  - types-PyYAML
36
36
  - types-toml
37
37
  - pytest<8 # 8.0.0 does not support python 3.7
38
+ - argcomplete>=3
39
+ - annotated_types<0.7.0 # 0.7.0 does not support python 3.7
@@ -2,6 +2,19 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## v2.4.1.dev0 (2024-06-17)
6
+
7
+ ### Fix
8
+
9
+ - use esp32c5 mp as default path
10
+
11
+ ## v2.4.0 (2024-06-17)
12
+
13
+ ### Feat
14
+
15
+ - support esp32c5 soc header
16
+ - **cli**: add CLI autocompletions
17
+
5
18
  ## v2.3.1 (2024-04-22)
6
19
 
7
20
  ### Fix
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: idf-build-apps
3
- Version: 2.3.1
3
+ Version: 2.4.1.dev0
4
4
  Summary: Tools for building ESP-IDF related apps.
5
5
  Author-email: Fu Hanxi <fuhanxi@espressif.com>
6
6
  Requires-Python: >=3.7
@@ -18,6 +18,7 @@ Requires-Dist: pyyaml
18
18
  Requires-Dist: packaging
19
19
  Requires-Dist: toml; python_version < '3.11'
20
20
  Requires-Dist: pydantic~=2.0
21
+ Requires-Dist: argcomplete>=3
21
22
  Requires-Dist: typing-extensions ; extra == "dev" and ( python_version < '3.8')
22
23
  Requires-Dist: sphinx ; extra == "doc"
23
24
  Requires-Dist: sphinx-rtd-theme ; extra == "doc"
@@ -68,10 +69,11 @@ pipx install idf-build-apps
68
69
 
69
70
  `idf-build-apps` is a python package that could be used as a library or a CLI tool.
70
71
 
71
- As a CLI tool, it contains two sub-commands.
72
+ As a CLI tool, it contains three sub-commands.
72
73
 
73
74
  - `find` to find the buildable applications
74
75
  - `build` to build the found applications
76
+ - `completions` to activate autocompletions or print instructions for manual activation
75
77
 
76
78
  For detailed explanation to all CLI options, you may run
77
79
 
@@ -79,6 +81,7 @@ For detailed explanation to all CLI options, you may run
79
81
  idf-build-apps -h
80
82
  idf-build-apps find -h
81
83
  idf-build-apps build -h
84
+ idf-build-apps completions -h
82
85
  ```
83
86
 
84
87
  As a library, you may check the [API documentation][api-doc] for more information. Overall it provides
@@ -31,10 +31,11 @@ pipx install idf-build-apps
31
31
 
32
32
  `idf-build-apps` is a python package that could be used as a library or a CLI tool.
33
33
 
34
- As a CLI tool, it contains two sub-commands.
34
+ As a CLI tool, it contains three sub-commands.
35
35
 
36
36
  - `find` to find the buildable applications
37
37
  - `build` to build the found applications
38
+ - `completions` to activate autocompletions or print instructions for manual activation
38
39
 
39
40
  For detailed explanation to all CLI options, you may run
40
41
 
@@ -42,6 +43,7 @@ For detailed explanation to all CLI options, you may run
42
43
  idf-build-apps -h
43
44
  idf-build-apps find -h
44
45
  idf-build-apps build -h
46
+ idf-build-apps completions -h
45
47
  ```
46
48
 
47
49
  As a library, you may check the [API documentation][api-doc] for more information. Overall it provides
@@ -19,6 +19,33 @@ One typical manifest file look like this:
19
19
  - ...
20
20
  ```
21
21
 
22
+ ## Terms
23
+
24
+ ### Supported Targets
25
+
26
+ This refers to the targets that are fully supported by the ESP-IDF project. You may check the supported targets by running `idf.py --list-targets`.
27
+
28
+ `idf-build-apps` will get this information dynamically from your `$IDF_PATH`. For ESP-IDF release 5.3, the supported targets are:
29
+
30
+ - esp32
31
+ - esp32s2
32
+ - esp32c3
33
+ - esp32s3
34
+ - esp32c2
35
+ - esp32c6
36
+ - esp32h2
37
+ - esp32p4
38
+
39
+ ### Preview Targets
40
+
41
+ This refers to the targets that are still in preview status. You may check the preview targets by running `idf.py --list-targets --preview`.
42
+
43
+ `idf-build-apps` will get this information dynamically from your `$IDF_PATH`. For ESP-IDF release 5.3, the preview targets are:
44
+
45
+ - linux
46
+ - esp32c5
47
+ - esp32c61
48
+
22
49
  ## `if` Clauses
23
50
 
24
51
  ### Operands
@@ -30,7 +57,7 @@ One typical manifest file look like this:
30
57
  - `IDF_VERSION_MAJOR`
31
58
  - `IDF_VERSION_MINOR`
32
59
  - `IDF_VERSION_PATCH`
33
- - `INCLUDE_DEFAULT` (The default value of officially supported targets is 1, otherwise is 0)
60
+ - `INCLUDE_DEFAULT` (The default value of supported targets is 1, and the default value of preview targets is 0)
34
61
  - `CONFIG_NAME` (config name defined in [](project:#config-rules))
35
62
  - environment variables, default to `0` if not set
36
63
  - String, must be double-quoted. e.g., `"esp32"`, `"12345"`
@@ -53,7 +80,9 @@ All operators are binary operators. For more than two operands, you may use the
53
80
 
54
81
  ## Enable/Disable Rules
55
82
 
56
- By default, we enable build and test for all supported targets. In other words, if an app supports all supported targets, it does not need to be added in a manifest file. The manifest files are files that set the violation rules for apps.
83
+ By default, we enable build and test for all supported targets. In other words, all preview targets are disabled.
84
+
85
+ To simplify the manifest file, if an app needs to be build and tested on all supported targets, it does not need to be added in a manifest file. The manifest files are files that set the violation rules for apps.
57
86
 
58
87
  Three rules (disable rules are calculated after the `enable` rule):
59
88
  - `enable`: run CI build/test jobs for targets that match any of the specified conditions only
@@ -8,7 +8,7 @@ Tools for building ESP-IDF related apps.
8
8
  # ruff: noqa: E402
9
9
  # avoid circular imports
10
10
 
11
- __version__ = '2.3.1'
11
+ __version__ = '2.4.1.dev0'
12
12
 
13
13
  from .session_args import (
14
14
  SessionArgs,
@@ -0,0 +1,54 @@
1
+ # SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import os
5
+ from typing import Optional
6
+
7
+ from .utils import AutocompleteActivationError
8
+
9
+
10
+ def append_to_file(file_path: str, content: str) -> None:
11
+ """Add commands to shell configuration file
12
+
13
+ :param file_path: path to shell configurations file
14
+ :param content: commands to add
15
+ """
16
+ if os.path.exists(file_path):
17
+ with open(file_path) as file:
18
+ if content.strip() in file.read():
19
+ print(f'Autocompletion already set up in {file_path}')
20
+ return
21
+ with open(file_path, 'a') as file:
22
+ file.write(f'\n# Begin added by idf-build-apps \n{content} \n# End added by idf-build-apps')
23
+ print(f'Autocompletion added to {file_path}')
24
+
25
+
26
+ def activate_completions(shell_type: Optional[str]) -> None:
27
+ """Activates autocompletion for supported shells.
28
+
29
+ :raises AutocompleteActivationError: if the $SHELL env variable is empty, or if the detected shell is unsupported.
30
+ """
31
+ supported_shells = ['bash', 'zsh', 'fish']
32
+
33
+ if shell_type == 'auto':
34
+ shell_type = os.path.basename(os.environ.get('SHELL', ''))
35
+
36
+ if not shell_type:
37
+ raise AutocompleteActivationError('$SHELL is empty. Please provide your shell type with the `--shell` option')
38
+
39
+ if shell_type not in supported_shells:
40
+ raise AutocompleteActivationError('Unsupported shell. Autocompletion is supported for bash, zsh and fish.')
41
+
42
+ if shell_type == 'bash':
43
+ completion_command = 'eval "$(register-python-argcomplete idf-build-apps)"'
44
+ elif shell_type == 'zsh':
45
+ completion_command = (
46
+ 'autoload -U bashcompinit && bashcompinit && eval "$(register-python-argcomplete idf-build-apps)"'
47
+ )
48
+ elif shell_type == 'fish':
49
+ completion_command = 'register-python-argcomplete --shell fish idf-build-apps | source'
50
+
51
+ rc_file = {'bash': '~/.bashrc', 'zsh': '~/.zshrc', 'fish': '~/.config/fish/completions/idf-build-apps.fish'}
52
+
53
+ shell_rc = os.path.expanduser(rc_file[shell_type])
54
+ append_to_file(shell_rc, completion_command)
@@ -1,4 +1,4 @@
1
- # SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
1
+ # SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2
2
  # SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import enum
@@ -95,3 +95,37 @@ class BuildStage(str, enum.Enum):
95
95
  @classmethod
96
96
  def max_length(cls) -> int:
97
97
  return max(len(v.value) for v in cls.__members__.values())
98
+
99
+
100
+ completion_instructions = """
101
+ With `--activate` option detect your shell type and add the appropriate commands to your shell's config file
102
+ so that it is run on startup. You will likely have to restart
103
+ or re-login for the autocompletion to start working.
104
+
105
+ You can also specify your shell by the `--shell` option.
106
+
107
+ If you do not want automaticall modifying your shell config file
108
+ you can manually add commands provided below to activate autocompletion
109
+ or run them in your current terminal session for one-time activation.
110
+
111
+ Once again, you will likely have to restart
112
+ or re-login for the autocompletion to start working.
113
+
114
+ bash:
115
+ eval "$(register-python-argcomplete idf-build-apps)"
116
+
117
+ zsh:
118
+ To activate completions in zsh, first make sure compinit is marked for
119
+ autoload and run autoload:
120
+
121
+ autoload -U compinit
122
+ compinit
123
+
124
+ Afterwards you can enable completions for idf-build-apps:
125
+
126
+ eval "$(register-python-argcomplete idf-build-apps)"
127
+
128
+ fish:
129
+ # Not required to be in the config file, only run once
130
+ register-python-argcomplete --shell fish idf-build-apps >~/.config/fish/completions/idf-build-apps.fish
131
+ """
@@ -1,3 +1,5 @@
1
+ # PYTHON_ARGCOMPLETE_OK
2
+
1
3
  # SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2
4
  # SPDX-License-Identifier: Apache-2.0
3
5
 
@@ -10,6 +12,7 @@ import sys
10
12
  import textwrap
11
13
  import typing as t
12
14
 
15
+ import argcomplete
13
16
  from pydantic import (
14
17
  Field,
15
18
  create_model,
@@ -24,16 +27,14 @@ from .app import (
24
27
  CMakeApp,
25
28
  MakeApp,
26
29
  )
30
+ from .autocompletions import activate_completions
27
31
  from .build_apps_args import (
28
32
  BuildAppsArgs,
29
33
  )
30
34
  from .config import (
31
35
  get_valid_config,
32
36
  )
33
- from .constants import (
34
- ALL_TARGETS,
35
- BuildStatus,
36
- )
37
+ from .constants import ALL_TARGETS, BuildStatus, completion_instructions
37
38
  from .finder import (
38
39
  _find_apps,
39
40
  )
@@ -50,6 +51,7 @@ from .manifest.manifest import (
50
51
  Manifest,
51
52
  )
52
53
  from .utils import (
54
+ AutocompleteActivationError,
53
55
  InvalidCommand,
54
56
  files_matches_patterns,
55
57
  get_parallel_start_stop,
@@ -606,10 +608,27 @@ def get_parser() -> argparse.ArgumentParser:
606
608
  help='enable colored output by default on UNIX-like systems. enable this flag to make the logs uncolored.',
607
609
  )
608
610
 
609
- find_parser = actions.add_parser('find', parents=[common_args], formatter_class=IdfBuildAppsCliFormatter)
611
+ find_parser = actions.add_parser(
612
+ 'find',
613
+ help='Find the buildable applications. Run `idf-build-apps find --help` for more information on a command',
614
+ description='Find the buildable applications in the given path or paths for specified chips. '
615
+ '`--path` and `--target` options must be provided. '
616
+ 'By default, print the found apps in stdout. '
617
+ 'To find apps for all chips use the `--target` option with the `all` argument.',
618
+ parents=[common_args],
619
+ formatter_class=IdfBuildAppsCliFormatter,
620
+ )
621
+
610
622
  find_parser.add_argument('-o', '--output', help='Print the found apps to the specified file instead of stdout')
611
623
 
612
- build_parser = actions.add_parser('build', parents=[common_args], formatter_class=IdfBuildAppsCliFormatter)
624
+ build_parser = actions.add_parser(
625
+ 'build',
626
+ help='Build the found applications. Run `idf-build-apps build --help` for more information on a command',
627
+ description='Build the application in the given path or paths for specified chips. '
628
+ '`--path` and `--target` options must be provided.',
629
+ parents=[common_args],
630
+ formatter_class=IdfBuildAppsCliFormatter,
631
+ )
613
632
  build_parser.add_argument(
614
633
  '--build-verbose',
615
634
  action='store_true',
@@ -674,14 +693,48 @@ def get_parser() -> argparse.ArgumentParser:
674
693
  help='Path to the junitxml file. If specified, the junitxml file will be generated. Can expand placeholder @p',
675
694
  )
676
695
 
696
+ completions_parser = actions.add_parser(
697
+ 'completions',
698
+ help='Add the autocompletion activation script to the shell rc file. '
699
+ 'Run `idf-build-apps complations --help` for more information on a command',
700
+ description='Without `--activate` option print instructions for manual activation. '
701
+ 'With `--activate` option add the autocompletion activation script to the shell rc file '
702
+ 'for bash, zsh, or fish. Other shells are not supported. '
703
+ 'The `--shell` option used only with the `--activate` option, '
704
+ 'if provided, add the autocompletion activation script to the given shell; '
705
+ 'without this argument, will detect shell type automatically. '
706
+ 'May need to restart or re-login for the autocompletion to start working',
707
+ formatter_class=IdfBuildAppsCliFormatter,
708
+ )
709
+ completions_parser.add_argument(
710
+ '-a', '--activate', action='store_true', help='Activate autocompletion automatically and permanently'
711
+ )
712
+ completions_parser.add_argument(
713
+ '-s',
714
+ '--shell',
715
+ choices=['bash', 'zsh', 'fish'],
716
+ help='Specify the shell type for the autocomplite activation script. ',
717
+ )
718
+
677
719
  return parser
678
720
 
679
721
 
722
+ def handle_completions(args: argparse.Namespace) -> None:
723
+ if args.activate:
724
+ if not args.shell:
725
+ args.shell = 'auto'
726
+ activate_completions(args.shell)
727
+ elif not args.activate and args.shell:
728
+ raise AutocompleteActivationError('The --shell option can only be used with the --activate option.')
729
+ else:
730
+ print(completion_instructions)
731
+
732
+
680
733
  def validate_args(parser: argparse.ArgumentParser, args: argparse.Namespace) -> None:
681
734
  # validate cli subcommands
682
- if args.action not in ['find', 'build']:
735
+ if args.action not in ['find', 'build', 'completions']:
683
736
  parser.print_help()
684
- raise InvalidCommand('subcommand is required. {find, build}')
737
+ raise InvalidCommand('subcommand is required. {find, build, completions}')
685
738
 
686
739
  if not args.paths:
687
740
  raise InvalidCommand(
@@ -728,8 +781,13 @@ def apply_config_args(args: argparse.Namespace) -> None:
728
781
 
729
782
  def main():
730
783
  parser = get_parser()
784
+ argcomplete.autocomplete(parser)
731
785
  args = parser.parse_args()
732
786
 
787
+ if args.action == 'completions':
788
+ handle_completions(args)
789
+ sys.exit(0)
790
+
733
791
  apply_config_args(args)
734
792
  validate_args(parser, args)
735
793
 
@@ -82,35 +82,41 @@ class SocHeader(dict):
82
82
  super().__init__(**soc_header_dict)
83
83
 
84
84
  @staticmethod
85
- def _get_dir_from_candidates(candidates: t.List[str]) -> t.Optional[str]:
85
+ def _get_dirs_from_candidates(candidates: t.List[str]) -> t.List[str]:
86
+ dirs = []
86
87
  for d in candidates:
87
88
  if not os.path.isdir(d):
88
89
  LOGGER.debug('folder "%s" not found. Skipping...', os.path.abspath(d))
89
90
  else:
90
- return d
91
+ dirs.append(d)
91
92
 
92
- return None
93
+ return dirs
93
94
 
94
95
  @classmethod
95
96
  def _parse_soc_header(cls, target: str) -> t.Dict[str, t.Any]:
96
- soc_headers_dir = cls._get_dir_from_candidates([
97
+ soc_headers_dirs = cls._get_dirs_from_candidates([
98
+ # master c5 mp
99
+ os.path.abspath(os.path.join(IDF_PATH, 'components', 'soc', target, 'mp', 'include', 'soc')),
97
100
  # other branches
98
101
  os.path.abspath(os.path.join(IDF_PATH, 'components', 'soc', target, 'include', 'soc')),
99
102
  # release/v4.2
100
103
  os.path.abspath(os.path.join(IDF_PATH, 'components', 'soc', 'soc', target, 'include', 'soc')),
101
104
  ])
102
- esp_rom_headers_dir = cls._get_dir_from_candidates([
103
- os.path.join(IDF_PATH, 'components', 'esp_rom', target),
105
+ esp_rom_headers_dirs = cls._get_dirs_from_candidates([
106
+ # master c5 mp
107
+ os.path.abspath(os.path.join(IDF_PATH, 'components', 'esp_rom', target, 'mp', target)),
108
+ # others
109
+ os.path.abspath(os.path.join(IDF_PATH, 'components', 'esp_rom', target)),
104
110
  ])
105
111
 
106
112
  header_files: t.List[str] = []
107
- if soc_headers_dir:
108
- header_files += [str(p.resolve()) for p in Path(soc_headers_dir).glob(cls.CAPS_HEADER_FILEPATTERN)]
109
- if esp_rom_headers_dir:
110
- header_files += [str(p.resolve()) for p in Path(esp_rom_headers_dir).glob(cls.CAPS_HEADER_FILEPATTERN)]
113
+ for d in [*soc_headers_dirs, *esp_rom_headers_dirs]:
114
+ LOGGER.debug('Checking dir %s', d)
115
+ header_files += [str(p.resolve()) for p in Path(d).glob(cls.CAPS_HEADER_FILEPATTERN)]
111
116
 
112
117
  output_dict = {}
113
118
  for f in header_files:
119
+ LOGGER.debug('Checking header file %s', f)
114
120
  for line in get_defines(f):
115
121
  try:
116
122
  res = parse_define(line)
@@ -85,6 +85,10 @@ class BuildError(RuntimeError):
85
85
  pass
86
86
 
87
87
 
88
+ class AutocompleteActivationError(SystemExit):
89
+ pass
90
+
91
+
88
92
  class InvalidCommand(SystemExit):
89
93
  def __init__(self, msg: str) -> None:
90
94
  super().__init__('Invalid Command: ' + msg.strip())
@@ -28,6 +28,7 @@ dependencies = [
28
28
  "packaging",
29
29
  "toml; python_version < '3.11'",
30
30
  "pydantic~=2.0",
31
+ "argcomplete>=3"
31
32
  ]
32
33
 
33
34
  [project.optional-dependencies]
@@ -60,7 +61,7 @@ idf-build-apps = "idf_build_apps:main.main"
60
61
 
61
62
  [tool.commitizen]
62
63
  name = "cz_conventional_commits"
63
- version = "2.3.1"
64
+ version = "2.4.1.dev0"
64
65
  tag_format = "v$version"
65
66
  version_files = [
66
67
  "idf_build_apps/__init__.py",
@@ -13,7 +13,7 @@ package_data = \
13
13
  {'': ['*']}
14
14
 
15
15
  install_requires = \
16
- ['pyparsing', 'pyyaml', 'packaging', 'pydantic~=2.0']
16
+ ['pyparsing', 'pyyaml', 'packaging', 'pydantic~=2.0', 'argcomplete>=3']
17
17
 
18
18
  extras_require = \
19
19
  {":python_version < '3.11'": ['toml'],
@@ -30,7 +30,7 @@ entry_points = \
30
30
  {'console_scripts': ['idf-build-apps = idf_build_apps:main.main']}
31
31
 
32
32
  setup(name='idf-build-apps',
33
- version='2.3.1',
33
+ version='2.4.1.dev0',
34
34
  description='Tools for building ESP-IDF related apps.',
35
35
  author=None,
36
36
  author_email='Fu Hanxi <fuhanxi@espressif.com>',