idf-build-apps 2.12.3__py3-none-any.whl → 2.13.1__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.12.3'
11
+ __version__ = '2.13.1'
12
12
 
13
13
  from .session_args import (
14
14
  SessionArgs,
idf_build_apps/app.py CHANGED
@@ -109,6 +109,7 @@ class App(BaseModel):
109
109
  build_status: BuildStatus = BuildStatus.UNKNOWN
110
110
  build_comment: t.Optional[str] = None
111
111
  test_comment: t.Optional[str] = None
112
+ checked_should_build: bool = False
112
113
 
113
114
  _build_duration: float = 0
114
115
  _build_timestamp: t.Optional[datetime] = None
@@ -116,6 +117,7 @@ class App(BaseModel):
116
117
  __EQ_IGNORE_FIELDS__ = [
117
118
  'build_comment',
118
119
  'test_comment',
120
+ 'checked_should_build',
119
121
  ]
120
122
  __EQ_TUNE_FIELDS__ = {
121
123
  'app_dir': lambda x: (os.path.realpath(os.path.expanduser(x))),
@@ -163,9 +165,6 @@ class App(BaseModel):
163
165
  self._kwargs = kwargs
164
166
  self._initialize_hook(**kwargs)
165
167
 
166
- # private attrs, won't be dumped to json
167
- self._checked_should_build = False
168
-
169
168
  self._sdkconfig_files, self._sdkconfig_files_defined_target = self._process_sdkconfig_files()
170
169
 
171
170
  @classmethod
@@ -710,8 +709,12 @@ class App(BaseModel):
710
709
  if os.path.basename(_f_fullpath).endswith('.md'):
711
710
  continue
712
711
 
713
- if _f_fullpath.startswith(_app_dir_fullpath):
714
- return True
712
+ try:
713
+ if os.path.commonpath([_f_fullpath, _app_dir_fullpath]) == _app_dir_fullpath:
714
+ return True
715
+ except ValueError:
716
+ # on Windows, if paths are on different drives, a ValueError will be raised
717
+ continue
715
718
 
716
719
  return False
717
720
 
@@ -750,12 +753,12 @@ class App(BaseModel):
750
753
  self.build_comment += '\n'.join(f'- {clause}' for clause in rule.enable)
751
754
 
752
755
  self.build_status = BuildStatus.DISABLED
753
- self._checked_should_build = True
756
+ self.checked_should_build = True
754
757
  return
755
758
 
756
759
  if not check_app_dependencies:
757
760
  self.build_status = BuildStatus.SHOULD_BE_BUILT
758
- self._checked_should_build = True
761
+ self.checked_should_build = True
759
762
  return
760
763
 
761
764
  if (
@@ -765,26 +768,26 @@ class App(BaseModel):
765
768
  ):
766
769
  self.build_status = BuildStatus.SHOULD_BE_BUILT
767
770
  self.build_comment = 'current build modifies the related manifest rules'
768
- self._checked_should_build = True
771
+ self.checked_should_build = True
769
772
  return
770
773
 
771
774
  if self.is_modified(modified_files):
772
775
  self.build_status = BuildStatus.SHOULD_BE_BUILT
773
776
  self.build_comment = 'current build modifies this app'
774
- self._checked_should_build = True
777
+ self.checked_should_build = True
775
778
  return
776
779
 
777
780
  # if didn't modify any components, and no `depends_filepatterns` defined, skip
778
781
  if modified_components == [] and not self.depends_filepatterns:
779
782
  self.build_status = BuildStatus.SKIPPED
780
783
  self.build_comment = 'current build does not modify any components'
781
- self._checked_should_build = True
784
+ self.checked_should_build = True
782
785
  return
783
786
 
784
787
  # if no special rules defined, we left it unknown and decide with idf.py reconfigure
785
788
  if not self.depends_components and not self.depends_filepatterns:
786
789
  # keep unknown
787
- self._checked_should_build = True
790
+ self.checked_should_build = True
788
791
  self.build_comment = 'no special rules defined, run idf.py reconfigure to decide'
789
792
  return
790
793
 
@@ -795,7 +798,7 @@ class App(BaseModel):
795
798
  # depends components?
796
799
  if self.depends_components and modified_components is not None:
797
800
  if set(self.depends_components).intersection(set(modified_components)):
798
- self._checked_should_build = True
801
+ self.checked_should_build = True
799
802
  self.build_status = BuildStatus.SHOULD_BE_BUILT
800
803
  self.build_comment = (
801
804
  f'Requires components: {", ".join(self.depends_components)}. '
@@ -806,7 +809,7 @@ class App(BaseModel):
806
809
  # or depends file patterns?
807
810
  if self.depends_filepatterns and modified_files is not None:
808
811
  if files_matches_patterns(modified_files, self.depends_filepatterns, manifest_rootpath):
809
- self._checked_should_build = True
812
+ self.checked_should_build = True
810
813
  self.build_status = BuildStatus.SHOULD_BE_BUILT
811
814
  self.build_comment = (
812
815
  f'Requires file patterns: {", ".join(self.depends_filepatterns)}. '
@@ -817,7 +820,7 @@ class App(BaseModel):
817
820
  # special rules defined, but not matched
818
821
  self.build_status = BuildStatus.SKIPPED
819
822
  self.build_comment = 'current build does not modify any components or files required by this app'
820
- self._checked_should_build = True
823
+ self.checked_should_build = True
821
824
 
822
825
  def check_should_test(self) -> None:
823
826
  """Check if testing is disabled for this app and set test_disable_reason."""
@@ -955,7 +958,7 @@ class CMakeApp(App):
955
958
  check_app_dependencies=check_app_dependencies,
956
959
  )
957
960
 
958
- if not self._checked_should_build:
961
+ if not self.checked_should_build:
959
962
  self.check_should_build(
960
963
  manifest_rootpath=manifest_rootpath,
961
964
  modified_components=modified_components,
idf_build_apps/args.py CHANGED
@@ -29,7 +29,7 @@ from pydantic_settings import (
29
29
  from typing_extensions import Concatenate, ParamSpec
30
30
 
31
31
  from . import SESSION_ARGS, App, CMakeApp, MakeApp, setup_logging
32
- from .constants import ALL_TARGETS, IDF_BUILD_APPS_TOML_FN
32
+ from .constants import ALL_TARGETS, IDF_BUILD_APPS_TOML_FN, PREVIEW_TARGETS, SUPPORTED_TARGETS
33
33
  from .manifest.manifest import DEFAULT_BUILD_TARGETS, Manifest, reset_default_build_targets
34
34
  from .utils import InvalidCommand, files_matches_patterns, semicolon_separated_str_to_list, to_absolute_path, to_list
35
35
  from .vendors.pydantic_sources import PyprojectTomlConfigSettingsSource, TomlConfigSettingsSource
@@ -563,17 +563,22 @@ class FindBuildArguments(DependencyDrivenBuildArguments):
563
563
  nargs='+',
564
564
  ),
565
565
  description='space-separated list of the default enabled build targets for the apps. '
566
- 'When not specified, the default value is the targets listed by `idf.py --list-targets`. '
567
- 'Cannot be used together with --enable-preview-targets',
566
+ 'When not specified, the default value is the targets listed by `idf.py --list-targets`.',
567
+ default=None, # type: ignore
568
+ )
569
+ additional_build_targets: t.Optional[t.List[str]] = field(
570
+ FieldMetadata(
571
+ validate_method=[ValidateMethod.TO_LIST],
572
+ nargs='+',
573
+ ),
574
+ description='space-separated list of additional build targets to add to the default enabled build targets',
568
575
  default=None, # type: ignore
569
576
  )
570
577
  enable_preview_targets: bool = field(
571
578
  FieldMetadata(
572
579
  action='store_true',
573
580
  ),
574
- description='When enabled, all targets will be enabled by default, '
575
- 'including the preview targets. As the targets defined in `idf.py --list-targets --preview`. '
576
- 'Cannot be used together with --default-build-targets',
581
+ description='When enabled, PREVIEW_TARGETS will be added to the default enabled build targets',
577
582
  default=False, # type: ignore
578
583
  )
579
584
  disable_targets: t.Optional[t.List[str]] = field(
@@ -616,39 +621,44 @@ class FindBuildArguments(DependencyDrivenBuildArguments):
616
621
  LOGGER.debug('--target is missing. Set --target as "all".')
617
622
  self.target = 'all'
618
623
 
619
- # Validate mutual exclusivity of enable_preview_targets and default_build_targets
620
- if self.enable_preview_targets and self.default_build_targets:
621
- raise InvalidCommand(
622
- 'Cannot specify both --enable-preview-targets and --default-build-targets at the same time. '
623
- 'Please use only one of these options.'
624
- )
625
-
626
624
  reset_default_build_targets() # reset first then judge again
625
+
626
+ # Build the target set by combining the options
627
+ default_build_targets: t.List[str] = []
628
+ # Step 1: Determine base targets
627
629
  if self.default_build_targets:
628
- default_build_targets = []
629
- for target in self.default_build_targets:
630
- if target not in ALL_TARGETS:
631
- LOGGER.warning(
632
- f'Ignoring... Unrecognizable target {target} specified with "--default-build-targets". '
633
- f'Current ESP-IDF available targets: {ALL_TARGETS}'
634
- )
635
- elif target not in default_build_targets:
636
- default_build_targets.append(target)
637
- self.default_build_targets = default_build_targets
638
- LOGGER.info('Overriding default build targets to %s', self.default_build_targets)
639
- DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
640
- elif self.enable_preview_targets:
641
- self.default_build_targets = deepcopy(ALL_TARGETS)
642
- LOGGER.info('Overriding default build targets to %s', self.default_build_targets)
643
- DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
644
-
645
- if self.disable_targets and DEFAULT_BUILD_TARGETS.get():
646
- LOGGER.info('Disable targets: %s', self.disable_targets)
647
- self.default_build_targets = [
648
- _target for _target in DEFAULT_BUILD_TARGETS.get() if _target not in self.disable_targets
649
- ]
650
- DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
630
+ LOGGER.info('--default-build-targets is set, using `%s`', self.default_build_targets)
631
+ default_build_targets = deepcopy(self.default_build_targets)
632
+ elif SUPPORTED_TARGETS:
633
+ LOGGER.info('Using default SUPPORTED_TARGETS: %s', SUPPORTED_TARGETS)
634
+ default_build_targets = deepcopy(SUPPORTED_TARGETS)
635
+
636
+ if self.enable_preview_targets:
637
+ LOGGER.info('--enable-preview-targets is set, adding preview targets `%s`', PREVIEW_TARGETS)
638
+ default_build_targets.extend(PREVIEW_TARGETS)
639
+
640
+ if self.additional_build_targets:
641
+ LOGGER.info('--additional-build-targets is set, adding `%s`', self.additional_build_targets)
642
+ default_build_targets.extend(self.additional_build_targets)
643
+
644
+ res = []
645
+ for _t in set(default_build_targets):
646
+ if _t not in ALL_TARGETS:
647
+ LOGGER.warning(
648
+ f'Ignoring... Unrecognizable target {_t} specified. '
649
+ f'Current ESP-IDF available targets: {ALL_TARGETS}'
650
+ )
651
+ continue
652
+
653
+ if self.disable_targets and _t in self.disable_targets:
654
+ LOGGER.info(f'Ignoring... Target {_t} is in the disabled targets list.')
655
+ continue
656
+
657
+ res.append(_t)
658
+ self.default_build_targets = sorted(res)
659
+ DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
651
660
 
661
+ # Override sdkconfig files/items
652
662
  if self.override_sdkconfig_files or self.override_sdkconfig_items:
653
663
  SESSION_ARGS.set(self)
654
664
 
idf_build_apps/finder.py CHANGED
@@ -16,6 +16,7 @@ from .app import (
16
16
  )
17
17
  from .args import FindArguments
18
18
  from .constants import (
19
+ ALL_TARGETS,
19
20
  BuildStatus,
20
21
  )
21
22
  from .utils import (
@@ -26,6 +27,14 @@ from .utils import (
26
27
  LOGGER = logging.getLogger(__name__)
27
28
 
28
29
 
30
+ def _is_target_specific(filepath: str) -> bool:
31
+ for target in ALL_TARGETS:
32
+ if filepath.endswith(f'.{target}'):
33
+ return True
34
+
35
+ return False
36
+
37
+
29
38
  def _get_apps_from_path(
30
39
  path: str,
31
40
  target: str,
@@ -55,8 +64,8 @@ def _get_apps_from_path(
55
64
  sdkconfig_paths_matched = True # skip the next block for no wildcard config rules
56
65
 
57
66
  for sdkconfig_path in sdkconfig_paths:
58
- if sdkconfig_path.endswith(f'.{target}'):
59
- LOGGER.debug('=> Skipping sdkconfig %s which is target-specific', sdkconfig_path)
67
+ if _is_target_specific(sdkconfig_path):
68
+ LOGGER.debug('=> Skipping sdkconfig file `%s` which is target-specific', sdkconfig_path)
60
69
  continue
61
70
 
62
71
  # Figure out the config name
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: idf-build-apps
3
- Version: 2.12.3
3
+ Version: 2.13.1
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
@@ -1,10 +1,10 @@
1
- idf_build_apps/__init__.py,sha256=-Al5DqtBy-8KSQl5DAXnd0UOIux9w--DGZddOpxQMOg,711
1
+ idf_build_apps/__init__.py,sha256=14b5JmRabCYdF9CHWlu039MnEpZdK3kpn77QHrv0Wm8,711
2
2
  idf_build_apps/__main__.py,sha256=pT6OsFQRjCw39Jg43HAeGKzq8h5E_0m7kHDE2QMqDe0,182
3
- idf_build_apps/app.py,sha256=QXNfn5HVgkjLR6Xswa-wdy3BEWgJJ1k0Zn2-Q9NC92I,39181
4
- idf_build_apps/args.py,sha256=m1tJl75P3yuDIaxQpg4bL8UIe2j_R1tNvQW_vpyR1AU,40099
3
+ idf_build_apps/app.py,sha256=AmYbXGJtHjq88O0Qwg7LeL4CI0TgMloS9MOM6rGsXZc,39370
4
+ idf_build_apps/args.py,sha256=e9d4kxv2q7SEOF42rWn-GS9EfIYYLaMxNUagJ8SPGzk,40140
5
5
  idf_build_apps/autocompletions.py,sha256=2fZQxzgZ21ie_2uk-B-7-xWYCChfOSgRFRYb7I2Onfo,2143
6
6
  idf_build_apps/constants.py,sha256=2iwLPZRhSQcn1v4RAcOJnHbqp1fDTp6A1gHaxn5ciTE,2166
7
- idf_build_apps/finder.py,sha256=gpOcpGrzAGiBVRCgKQ_YW22_OUJv-D-hMApuE-tPhVQ,5644
7
+ idf_build_apps/finder.py,sha256=CKppfxa-nPedHKXfyQ841q1DZc0BimVulXK52EfCD0o,5833
8
8
  idf_build_apps/log.py,sha256=15sSQhv9dJsHShDR2KgFGFp8ByjV0HogLr1X1lHYqGs,3899
9
9
  idf_build_apps/main.py,sha256=P_TsUA2s048qcRb-wVngF-zqNjH_NEYrQsAYKB1GHmU,17960
10
10
  idf_build_apps/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -20,8 +20,8 @@ idf_build_apps/vendors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3
20
20
  idf_build_apps/vendors/pydantic_sources.py,sha256=cxSIPRc3eI5peVMhDxwf58YaGhuG4SCwPRVX2znFEek,4553
21
21
  idf_build_apps/yaml/__init__.py,sha256=R6pYasVsD31maeZ4dWRZnS10hwzM7gXdnfzDsOIRJ-4,167
22
22
  idf_build_apps/yaml/parser.py,sha256=IhY7rCWXOxrzzgEiKipTdPs_8yXDf8JZr-sMewV1pk8,2133
23
- idf_build_apps-2.12.3.dist-info/entry_points.txt,sha256=3pVUirUEsb6jsDRikkQWNUt4hqLK2ci1HvW_Vf8b6uE,59
24
- idf_build_apps-2.12.3.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
25
- idf_build_apps-2.12.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
- idf_build_apps-2.12.3.dist-info/METADATA,sha256=pYpQDcJzaL09UmI1oDiMKvlfBK1TAMKDy44AzjTUkW4,4795
27
- idf_build_apps-2.12.3.dist-info/RECORD,,
23
+ idf_build_apps-2.13.1.dist-info/entry_points.txt,sha256=3pVUirUEsb6jsDRikkQWNUt4hqLK2ci1HvW_Vf8b6uE,59
24
+ idf_build_apps-2.13.1.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
25
+ idf_build_apps-2.13.1.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
+ idf_build_apps-2.13.1.dist-info/METADATA,sha256=9Ti6jZSYSFlemwHp4eBL5FIks6IgveU8xJoEit4eFuw,4795
27
+ idf_build_apps-2.13.1.dist-info/RECORD,,