idf-build-apps 2.4.2__py3-none-any.whl → 2.5.0__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.
@@ -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
- _BUILDING_DOCS = bool(os.getenv('BUILDING_DOCS'))
20
- if _BUILDING_DOCS:
21
- print('Building Docs... Faking lots of constant values')
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
- sys.path.append(os.path.join(IDF_PATH, 'tools', 'idf_py_actions'))
40
- if _BUILDING_DOCS:
41
- _idf_py_constant_py = object()
42
- else:
43
- try:
44
- _idf_py_constant_py = importlib.import_module('constants')
45
- except ModuleNotFoundError:
46
- LOGGER.warning('Cannot import constants from idf_py_actions')
47
- _idf_py_constant_py = object()
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
- raise ValueError(f'File {version_path} does not exist')
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
- if _BUILDING_DOCS:
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
 
@@ -130,3 +119,4 @@ fish:
130
119
  # Not required to be in the config file, only run once
131
120
  register-python-argcomplete --shell fish idf-build-apps >~/.config/fish/completions/idf-build-apps.fish
132
121
  """
122
+ IDF_BUILD_APPS_TOML_FN = '.idf_build_apps.toml'
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
- work_dir: t.Optional[str] = None,
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,
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._check_should_build(
58
- manifest_rootpath=manifest_rootpath,
59
- modified_components=modified_components,
60
- modified_files=modified_files,
61
- check_app_dependencies=check_app_dependencies,
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(config_rules_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
- preserve=preserve,
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
- preserve=preserve,
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
- recursive: bool = False,
154
- exclude_list: t.Optional[t.List[str]] = None,
155
- **kwargs,
136
+ args: 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 exclude_list:
168
- LOGGER.warning('--exclude option is ignored when used without --recursive')
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, **kwargs)
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 exclude_list]
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, **kwargs)
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