idf-build-apps 2.4.3__py3-none-any.whl → 2.5.0rc0__py3-none-any.whl
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.
- idf_build_apps/__init__.py +1 -1
- idf_build_apps/app.py +35 -27
- idf_build_apps/args.py +965 -0
- idf_build_apps/config.py +19 -2
- idf_build_apps/constants.py +17 -28
- idf_build_apps/finder.py +34 -54
- idf_build_apps/log.py +2 -0
- idf_build_apps/main.py +117 -627
- idf_build_apps/manifest/manifest.py +112 -24
- idf_build_apps/utils.py +22 -0
- {idf_build_apps-2.4.3.dist-info → idf_build_apps-2.5.0rc0.dist-info}/METADATA +3 -4
- idf_build_apps-2.5.0rc0.dist-info/RECORD +26 -0
- idf_build_apps/build_apps_args.py +0 -64
- idf_build_apps-2.4.3.dist-info/RECORD +0 -26
- {idf_build_apps-2.4.3.dist-info → idf_build_apps-2.5.0rc0.dist-info}/LICENSE +0 -0
- {idf_build_apps-2.4.3.dist-info → idf_build_apps-2.5.0rc0.dist-info}/WHEEL +0 -0
- {idf_build_apps-2.4.3.dist-info → idf_build_apps-2.5.0rc0.dist-info}/entry_points.txt +0 -0
idf_build_apps/config.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
|
|
1
|
+
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
|
2
2
|
# SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import os
|
|
@@ -7,7 +7,7 @@ from pathlib import (
|
|
|
7
7
|
Path,
|
|
8
8
|
)
|
|
9
9
|
|
|
10
|
-
from
|
|
10
|
+
from .utils import (
|
|
11
11
|
to_absolute_path,
|
|
12
12
|
)
|
|
13
13
|
|
|
@@ -65,6 +65,23 @@ def _get_config_from_path(dirpath: str) -> t.Tuple[t.Optional[dict], str]:
|
|
|
65
65
|
|
|
66
66
|
|
|
67
67
|
def get_valid_config(starts_from: str = os.getcwd(), custom_path: t.Optional[str] = None) -> t.Optional[dict]:
|
|
68
|
+
"""
|
|
69
|
+
Get the valid config from the current directory or its parent directories.
|
|
70
|
+
|
|
71
|
+
If the custom path is provided, it will be used to get the config file.
|
|
72
|
+
|
|
73
|
+
Otherwise, the search will start from the current working directory and go up to the root directory.
|
|
74
|
+
|
|
75
|
+
The search will stop in the following cases:
|
|
76
|
+
|
|
77
|
+
- A valid config file is found.
|
|
78
|
+
- A `.git` directory is found.
|
|
79
|
+
- The root directory is reached.
|
|
80
|
+
|
|
81
|
+
:param starts_from: starting directory to search for the config file. Default is the current working directory.
|
|
82
|
+
:param custom_path: custom path to the config file.
|
|
83
|
+
:return: the valid config dict if found, otherwise None.
|
|
84
|
+
"""
|
|
68
85
|
root_dir = to_absolute_path('/')
|
|
69
86
|
cur_dir = to_absolute_path(starts_from)
|
|
70
87
|
|
idf_build_apps/constants.py
CHANGED
|
@@ -7,7 +7,6 @@ import logging
|
|
|
7
7
|
import os
|
|
8
8
|
import re
|
|
9
9
|
import sys
|
|
10
|
-
import tempfile
|
|
11
10
|
import typing as t
|
|
12
11
|
|
|
13
12
|
from .utils import (
|
|
@@ -16,19 +15,10 @@ from .utils import (
|
|
|
16
15
|
|
|
17
16
|
LOGGER = logging.getLogger(__name__)
|
|
18
17
|
|
|
19
|
-
|
|
20
|
-
if
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if _BUILDING_DOCS:
|
|
25
|
-
_idf_env = tempfile.gettempdir()
|
|
26
|
-
else:
|
|
27
|
-
_idf_env = os.getenv('IDF_PATH') or ''
|
|
28
|
-
if not _idf_env:
|
|
29
|
-
raise SystemExit('environment variable IDF_PATH must be set')
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
_idf_env = os.getenv('IDF_PATH') or ''
|
|
19
|
+
if not _idf_env:
|
|
20
|
+
LOGGER.warning('IDF_PATH environment variable is not set. Entering test mode...')
|
|
21
|
+
LOGGER.warning('- Setting IDF_PATH to current directory...')
|
|
32
22
|
IDF_PATH = os.path.abspath(_idf_env)
|
|
33
23
|
IDF_PY = os.path.join(IDF_PATH, 'tools', 'idf.py')
|
|
34
24
|
IDF_SIZE_PY = os.path.join(IDF_PATH, 'tools', 'idf_size.py')
|
|
@@ -36,15 +26,16 @@ PROJECT_DESCRIPTION_JSON = 'project_description.json'
|
|
|
36
26
|
DEFAULT_SDKCONFIG = 'sdkconfig.defaults'
|
|
37
27
|
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
_idf_py_actions = os.path.join(IDF_PATH, 'tools', 'idf_py_actions')
|
|
30
|
+
sys.path.append(_idf_py_actions)
|
|
31
|
+
try:
|
|
32
|
+
_idf_py_constant_py = importlib.import_module('constants')
|
|
33
|
+
except ModuleNotFoundError:
|
|
34
|
+
LOGGER.warning(
|
|
35
|
+
'- Set supported/preview targets to empty list... (ESP-IDF constants.py module not found under %s)',
|
|
36
|
+
_idf_py_actions,
|
|
37
|
+
)
|
|
38
|
+
_idf_py_constant_py = object() # type: ignore
|
|
48
39
|
SUPPORTED_TARGETS = getattr(_idf_py_constant_py, 'SUPPORTED_TARGETS', [])
|
|
49
40
|
PREVIEW_TARGETS = getattr(_idf_py_constant_py, 'PREVIEW_TARGETS', [])
|
|
50
41
|
ALL_TARGETS = SUPPORTED_TARGETS + PREVIEW_TARGETS
|
|
@@ -53,7 +44,8 @@ ALL_TARGETS = SUPPORTED_TARGETS + PREVIEW_TARGETS
|
|
|
53
44
|
def _idf_version_from_cmake() -> t.Tuple[int, int, int]:
|
|
54
45
|
version_path = os.path.join(IDF_PATH, 'tools', 'cmake', 'version.cmake')
|
|
55
46
|
if not os.path.isfile(version_path):
|
|
56
|
-
|
|
47
|
+
LOGGER.warning('- Setting ESP-IDF version to 1.0.0... (ESP-IDF version.cmake not exists at %s)', version_path)
|
|
48
|
+
return 1, 0, 0
|
|
57
49
|
|
|
58
50
|
regex = re.compile(r'^\s*set\s*\(\s*IDF_VERSION_([A-Z]{5})\s+(\d+)')
|
|
59
51
|
ver = {}
|
|
@@ -70,10 +62,7 @@ def _idf_version_from_cmake() -> t.Tuple[int, int, int]:
|
|
|
70
62
|
raise ValueError(f'Cannot find ESP-IDF version in {version_path}')
|
|
71
63
|
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
IDF_VERSION_MAJOR, IDF_VERSION_MINOR, IDF_VERSION_PATCH = 1, 0, 0
|
|
75
|
-
else:
|
|
76
|
-
IDF_VERSION_MAJOR, IDF_VERSION_MINOR, IDF_VERSION_PATCH = _idf_version_from_cmake()
|
|
65
|
+
IDF_VERSION_MAJOR, IDF_VERSION_MINOR, IDF_VERSION_PATCH = _idf_version_from_cmake()
|
|
77
66
|
|
|
78
67
|
IDF_VERSION = to_version(f'{IDF_VERSION_MAJOR}.{IDF_VERSION_MINOR}.{IDF_VERSION_PATCH}')
|
|
79
68
|
|
idf_build_apps/finder.py
CHANGED
|
@@ -14,13 +14,13 @@ from .app import (
|
|
|
14
14
|
App,
|
|
15
15
|
CMakeApp,
|
|
16
16
|
)
|
|
17
|
+
from .args import FindArguments
|
|
17
18
|
from .constants import (
|
|
18
19
|
BuildStatus,
|
|
19
20
|
)
|
|
20
21
|
from .utils import (
|
|
21
22
|
config_rules_from_str,
|
|
22
23
|
to_absolute_path,
|
|
23
|
-
to_list,
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
LOGGER = logging.getLogger(__name__)
|
|
@@ -29,41 +29,27 @@ LOGGER = logging.getLogger(__name__)
|
|
|
29
29
|
def _get_apps_from_path(
|
|
30
30
|
path: str,
|
|
31
31
|
target: str,
|
|
32
|
+
*,
|
|
32
33
|
app_cls: t.Type[App] = CMakeApp,
|
|
33
|
-
|
|
34
|
-
build_dir: str = 'build',
|
|
35
|
-
config_rules_str: t.Optional[t.List[str]] = None,
|
|
36
|
-
build_log_filename: t.Optional[str] = None,
|
|
37
|
-
size_json_filename: t.Optional[str] = None,
|
|
38
|
-
check_warnings: bool = False,
|
|
39
|
-
preserve: bool = True,
|
|
40
|
-
manifest_rootpath: t.Optional[str] = None,
|
|
41
|
-
modified_components: t.Optional[t.List[str]] = None,
|
|
42
|
-
modified_files: t.Optional[t.List[str]] = None,
|
|
43
|
-
check_app_dependencies: bool = False,
|
|
44
|
-
sdkconfig_defaults_str: t.Optional[str] = None,
|
|
45
|
-
include_skipped_apps: bool = False,
|
|
46
|
-
include_disabled_apps: bool = False,
|
|
34
|
+
args: FindArguments = FindArguments(),
|
|
47
35
|
) -> t.List[App]:
|
|
48
|
-
modified_components = to_list(modified_components)
|
|
49
|
-
modified_files = to_list(modified_files)
|
|
50
|
-
|
|
51
36
|
def _validate_app(_app: App) -> bool:
|
|
52
37
|
if target not in _app.supported_targets:
|
|
53
38
|
LOGGER.debug('=> Ignored. %s only supports targets: %s', _app, ', '.join(_app.supported_targets))
|
|
54
39
|
_app.build_status = BuildStatus.DISABLED
|
|
55
|
-
return include_disabled_apps
|
|
56
|
-
|
|
57
|
-
_app.
|
|
58
|
-
manifest_rootpath=manifest_rootpath,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
40
|
+
return args.include_disabled_apps
|
|
41
|
+
|
|
42
|
+
_app.check_should_build(
|
|
43
|
+
manifest_rootpath=args.manifest_rootpath,
|
|
44
|
+
modified_manifest_rules_folders=args.modified_manifest_rules_folders,
|
|
45
|
+
modified_components=args.modified_components,
|
|
46
|
+
modified_files=args.modified_files,
|
|
47
|
+
check_app_dependencies=args.dependency_driven_build_enabled,
|
|
62
48
|
)
|
|
63
49
|
|
|
64
50
|
# for unknown ones, we keep them to the build stage to judge
|
|
65
51
|
if _app.build_status == BuildStatus.SKIPPED:
|
|
66
|
-
return include_skipped_apps
|
|
52
|
+
return args.include_skipped_apps
|
|
67
53
|
|
|
68
54
|
return True
|
|
69
55
|
|
|
@@ -71,9 +57,7 @@ def _get_apps_from_path(
|
|
|
71
57
|
LOGGER.debug('Skipping. %s is not an app', path)
|
|
72
58
|
return []
|
|
73
59
|
|
|
74
|
-
config_rules = config_rules_from_str(
|
|
75
|
-
if not config_rules:
|
|
76
|
-
config_rules = []
|
|
60
|
+
config_rules = config_rules_from_str(args.config_rules)
|
|
77
61
|
|
|
78
62
|
apps = []
|
|
79
63
|
default_config_name = ''
|
|
@@ -107,13 +91,12 @@ def _get_apps_from_path(
|
|
|
107
91
|
target,
|
|
108
92
|
sdkconfig_path=sdkconfig_path,
|
|
109
93
|
config_name=config_name,
|
|
110
|
-
work_dir=work_dir,
|
|
111
|
-
build_dir=build_dir,
|
|
112
|
-
build_log_filename=build_log_filename,
|
|
113
|
-
size_json_filename=size_json_filename,
|
|
114
|
-
check_warnings=check_warnings,
|
|
115
|
-
|
|
116
|
-
sdkconfig_defaults_str=sdkconfig_defaults_str,
|
|
94
|
+
work_dir=args.work_dir,
|
|
95
|
+
build_dir=args.build_dir,
|
|
96
|
+
build_log_filename=args.build_log_filename,
|
|
97
|
+
size_json_filename=args.size_json_filename,
|
|
98
|
+
check_warnings=args.check_warnings,
|
|
99
|
+
sdkconfig_defaults_str=args.sdkconfig_defaults,
|
|
117
100
|
)
|
|
118
101
|
if _validate_app(app):
|
|
119
102
|
LOGGER.debug('Found app: %s', app)
|
|
@@ -128,13 +111,12 @@ def _get_apps_from_path(
|
|
|
128
111
|
target,
|
|
129
112
|
sdkconfig_path=None,
|
|
130
113
|
config_name=default_config_name,
|
|
131
|
-
work_dir=work_dir,
|
|
132
|
-
build_dir=build_dir,
|
|
133
|
-
build_log_filename=build_log_filename,
|
|
134
|
-
size_json_filename=size_json_filename,
|
|
135
|
-
check_warnings=check_warnings,
|
|
136
|
-
|
|
137
|
-
sdkconfig_defaults_str=sdkconfig_defaults_str,
|
|
114
|
+
work_dir=args.work_dir,
|
|
115
|
+
build_dir=args.build_dir,
|
|
116
|
+
build_log_filename=args.build_log_filename,
|
|
117
|
+
size_json_filename=args.size_json_filename,
|
|
118
|
+
check_warnings=args.check_warnings,
|
|
119
|
+
sdkconfig_defaults_str=args.sdkconfig_defaults,
|
|
138
120
|
)
|
|
139
121
|
|
|
140
122
|
if _validate_app(app):
|
|
@@ -149,30 +131,28 @@ def _get_apps_from_path(
|
|
|
149
131
|
def _find_apps(
|
|
150
132
|
path: str,
|
|
151
133
|
target: str,
|
|
134
|
+
*,
|
|
152
135
|
app_cls: t.Type[App] = CMakeApp,
|
|
153
|
-
|
|
154
|
-
exclude_list: t.Optional[t.List[str]] = None,
|
|
155
|
-
**kwargs,
|
|
136
|
+
args: FindArguments = FindArguments(),
|
|
156
137
|
) -> t.List[App]:
|
|
157
|
-
exclude_list = exclude_list or []
|
|
158
138
|
LOGGER.debug(
|
|
159
139
|
'Looking for %s apps in %s%s with target %s',
|
|
160
140
|
app_cls.__name__,
|
|
161
141
|
path,
|
|
162
|
-
' recursively' if recursive else '',
|
|
142
|
+
' recursively' if args.recursive else '',
|
|
163
143
|
target,
|
|
164
144
|
)
|
|
165
145
|
|
|
166
|
-
if not recursive:
|
|
167
|
-
if
|
|
168
|
-
LOGGER.
|
|
146
|
+
if not args.recursive:
|
|
147
|
+
if args.exclude:
|
|
148
|
+
LOGGER.debug('--exclude option is ignored when used without --recursive')
|
|
169
149
|
|
|
170
|
-
return _get_apps_from_path(path, target, app_cls,
|
|
150
|
+
return _get_apps_from_path(path, target, app_cls=app_cls, args=args)
|
|
171
151
|
|
|
172
152
|
# The remaining part is for recursive == True
|
|
173
153
|
apps = []
|
|
174
154
|
# handle the exclude list, since the config file might use linux style, but run in windows
|
|
175
|
-
exclude_paths_list = [to_absolute_path(p) for p in
|
|
155
|
+
exclude_paths_list = [to_absolute_path(p) for p in args.exclude or []]
|
|
176
156
|
for root, dirs, _ in os.walk(path):
|
|
177
157
|
LOGGER.debug('Entering %s', root)
|
|
178
158
|
root_path = to_absolute_path(root)
|
|
@@ -186,7 +166,7 @@ def _find_apps(
|
|
|
186
166
|
del dirs[:]
|
|
187
167
|
continue
|
|
188
168
|
|
|
189
|
-
_found_apps = _get_apps_from_path(root, target, app_cls,
|
|
169
|
+
_found_apps = _get_apps_from_path(root, target, app_cls=app_cls, args=args)
|
|
190
170
|
if _found_apps: # root has at least one app
|
|
191
171
|
LOGGER.debug('=> Stop iteration sub dirs of %s since it has apps', root)
|
|
192
172
|
del dirs[:]
|
idf_build_apps/log.py
CHANGED
|
@@ -82,5 +82,7 @@ def setup_logging(verbose: int = 0, log_file: t.Optional[str] = None, colored: b
|
|
|
82
82
|
handler = logging.StreamHandler(sys.stderr)
|
|
83
83
|
handler.setFormatter(ColoredFormatter(colored))
|
|
84
84
|
|
|
85
|
+
if package_logger.hasHandlers():
|
|
86
|
+
package_logger.handlers.clear()
|
|
85
87
|
package_logger.addHandler(handler)
|
|
86
88
|
package_logger.propagate = False # don't propagate to root logger
|