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.
@@ -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.4.2'
11
+ __version__ = '2.5.0'
12
12
 
13
13
  from .session_args import (
14
14
  SessionArgs,
idf_build_apps/app.py CHANGED
@@ -26,9 +26,6 @@ from pydantic import (
26
26
  from . import (
27
27
  SESSION_ARGS,
28
28
  )
29
- from .build_apps_args import (
30
- BuildAppsArgs,
31
- )
32
29
  from .constants import (
33
30
  DEFAULT_SDKCONFIG,
34
31
  IDF_PY,
@@ -49,6 +46,7 @@ from .manifest.manifest import (
49
46
  from .utils import (
50
47
  BaseModel,
51
48
  BuildError,
49
+ Literal,
52
50
  files_matches_patterns,
53
51
  find_first_match,
54
52
  rmdir,
@@ -57,15 +55,6 @@ from .utils import (
57
55
  to_list,
58
56
  )
59
57
 
60
- if sys.version_info < (3, 8):
61
- from typing_extensions import (
62
- Literal,
63
- )
64
- else:
65
- from typing import (
66
- Literal,
67
- )
68
-
69
58
 
70
59
  class _AppBuildStageFilter(logging.Filter):
71
60
  def __init__(self, *args, app, **kwargs):
@@ -125,7 +114,6 @@ class App(BaseModel):
125
114
  copy_sdkconfig: bool = False
126
115
 
127
116
  # build_apps() related
128
- build_apps_args: t.Optional[BuildAppsArgs] = None
129
117
  index: t.Optional[int] = None
130
118
 
131
119
  # build status related
@@ -254,8 +242,6 @@ class App(BaseModel):
254
242
 
255
243
  if self.index is not None:
256
244
  path = path.replace(self.INDEX_PLACEHOLDER, str(self.index))
257
- if self.build_apps_args:
258
- path = self.build_apps_args.expand(path)
259
245
  path = path.replace(
260
246
  self.IDF_VERSION_PLACEHOLDER, f'{IDF_VERSION_MAJOR}_{IDF_VERSION_MINOR}_{IDF_VERSION_PATCH}'
261
247
  )
@@ -320,7 +306,7 @@ class App(BaseModel):
320
306
  return os.path.join(self.build_path, self.build_log_filename)
321
307
 
322
308
  # use a temp file if build log path is not specified
323
- return os.path.join(self.build_path, f'.temp.build.{hash(self)}.log')
309
+ return os.path.join(self.build_path, '.temp.build.log')
324
310
 
325
311
  @computed_field # type: ignore
326
312
  @property
@@ -569,6 +555,8 @@ class App(BaseModel):
569
555
 
570
556
  self._post_build()
571
557
 
558
+ self._finalize()
559
+
572
560
  def _post_build(self) -> None:
573
561
  """Post build actions for failed/success builds"""
574
562
  if self.build_status not in (
@@ -615,14 +603,7 @@ class App(BaseModel):
615
603
  self._logger.warning('%s', line)
616
604
  has_unignored_warning = True
617
605
 
618
- # correct build status for originally successful builds
619
- if self.build_status == BuildStatus.SUCCESS:
620
- if self.check_warnings and has_unignored_warning:
621
- self.build_status = BuildStatus.FAILED
622
- self.build_comment = 'build succeeded with warnings'
623
- elif has_unignored_warning:
624
- self.build_comment = 'build succeeded with warnings'
625
-
606
+ # for failed builds, print last few lines to help debug
626
607
  if self.build_status == BuildStatus.FAILED:
627
608
  # print last few lines to help debug
628
609
  self._logger.error(
@@ -632,10 +613,21 @@ class App(BaseModel):
632
613
  )
633
614
  for line in lines[-self.LOG_DEBUG_LINES :]:
634
615
  self._logger.error('%s', line)
616
+ # correct build status for originally successful builds
617
+ elif self.build_status == BuildStatus.SUCCESS:
618
+ if self.check_warnings and has_unignored_warning:
619
+ self.build_status = BuildStatus.FAILED
620
+ self.build_comment = 'build succeeded with warnings'
621
+ elif has_unignored_warning:
622
+ self.build_comment = 'build succeeded with warnings'
635
623
 
624
+ def _finalize(self) -> None:
625
+ """
626
+ Actions for real success builds
627
+ """
628
+ if self.build_status != BuildStatus.SUCCESS:
636
629
  return
637
630
 
638
- # Actions for real success builds
639
631
  # remove temp log file
640
632
  if self._is_build_log_path_temp:
641
633
  os.unlink(self.build_log_path)
@@ -751,9 +743,11 @@ class App(BaseModel):
751
743
 
752
744
  return False
753
745
 
754
- def _check_should_build(
746
+ def check_should_build(
755
747
  self,
748
+ *,
756
749
  manifest_rootpath: t.Optional[str] = None,
750
+ modified_manifest_rules_folders: t.Optional[t.Set[str]] = None,
757
751
  check_app_dependencies: bool = False,
758
752
  modified_components: t.Optional[t.List[str]] = None,
759
753
  modified_files: t.Optional[t.List[str]] = None,
@@ -766,6 +760,16 @@ class App(BaseModel):
766
760
  self._checked_should_build = True
767
761
  return
768
762
 
763
+ if (
764
+ self.MANIFEST
765
+ and modified_manifest_rules_folders
766
+ and self.MANIFEST.most_suitable_rule(self.app_dir).folder in modified_manifest_rules_folders
767
+ ):
768
+ self.build_status = BuildStatus.SHOULD_BE_BUILT
769
+ self.build_comment = 'current build modifies the related manifest rules'
770
+ self._checked_should_build = True
771
+ return
772
+
769
773
  if self.is_modified(modified_files):
770
774
  self.build_status = BuildStatus.SHOULD_BE_BUILT
771
775
  self.build_comment = 'current build modifies this app'
@@ -925,7 +929,7 @@ class CMakeApp(App):
925
929
  )
926
930
 
927
931
  if not self._checked_should_build:
928
- self._check_should_build(
932
+ self.check_should_build(
929
933
  manifest_rootpath=manifest_rootpath,
930
934
  modified_components=modified_components,
931
935
  modified_files=modified_files,