idf-build-apps 2.10.2__py3-none-any.whl → 2.10.3__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.10.2'
11
+ __version__ = '2.10.3'
12
12
 
13
13
  from .session_args import (
14
14
  SessionArgs,
idf_build_apps/app.py CHANGED
@@ -39,7 +39,7 @@ from .constants import (
39
39
  BuildStatus,
40
40
  )
41
41
  from .manifest.manifest import (
42
- FolderRule,
42
+ DEFAULT_BUILD_TARGETS,
43
43
  Manifest,
44
44
  )
45
45
  from .utils import (
@@ -436,7 +436,7 @@ class App(BaseModel):
436
436
  if self.sdkconfig_files_defined_idf_target:
437
437
  return [self.sdkconfig_files_defined_idf_target]
438
438
 
439
- return FolderRule.DEFAULT_BUILD_TARGETS
439
+ return DEFAULT_BUILD_TARGETS.get()
440
440
 
441
441
  @property
442
442
  def verified_targets(self) -> t.List[str]:
@@ -820,7 +820,7 @@ class MakeApp(App):
820
820
  if self.sdkconfig_files_defined_idf_target:
821
821
  return [self.sdkconfig_files_defined_idf_target]
822
822
 
823
- return ['esp8266', *FolderRule.DEFAULT_BUILD_TARGETS]
823
+ return ['esp8266', *DEFAULT_BUILD_TARGETS.get()]
824
824
 
825
825
  def _build(
826
826
  self,
idf_build_apps/args.py CHANGED
@@ -29,8 +29,8 @@ 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, SUPPORTED_TARGETS
33
- from .manifest.manifest import FolderRule, Manifest
32
+ from .constants import ALL_TARGETS, IDF_BUILD_APPS_TOML_FN
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
36
36
 
@@ -519,15 +519,17 @@ class FindBuildArguments(DependencyDrivenBuildArguments):
519
519
  nargs='+',
520
520
  ),
521
521
  description='space-separated list of the default enabled build targets for the apps. '
522
- 'When not specified, the default value is the targets listed by `idf.py --list-targets`',
522
+ 'When not specified, the default value is the targets listed by `idf.py --list-targets`. '
523
+ 'Cannot be used together with --enable-preview-targets',
523
524
  default=None, # type: ignore
524
525
  )
525
526
  enable_preview_targets: bool = field(
526
527
  FieldMetadata(
527
528
  action='store_true',
528
529
  ),
529
- description='When enabled, the default build targets will be set to all apps, '
530
- 'including the preview targets. As the targets defined in `idf.py --list-targets --preview`',
530
+ description='When enabled, all targets will be enabled by default, '
531
+ 'including the preview targets. As the targets defined in `idf.py --list-targets --preview`. '
532
+ 'Cannot be used together with --default-build-targets',
531
533
  default=False, # type: ignore
532
534
  )
533
535
  disable_targets: t.Optional[t.List[str]] = field(
@@ -570,6 +572,14 @@ class FindBuildArguments(DependencyDrivenBuildArguments):
570
572
  LOGGER.debug('--target is missing. Set --target as "all".')
571
573
  self.target = 'all'
572
574
 
575
+ # Validate mutual exclusivity of enable_preview_targets and default_build_targets
576
+ if self.enable_preview_targets and self.default_build_targets:
577
+ raise InvalidCommand(
578
+ 'Cannot specify both --enable-preview-targets and --default-build-targets at the same time. '
579
+ 'Please use only one of these options.'
580
+ )
581
+
582
+ reset_default_build_targets() # reset first then judge again
573
583
  if self.default_build_targets:
574
584
  default_build_targets = []
575
585
  for target in self.default_build_targets:
@@ -582,21 +592,18 @@ class FindBuildArguments(DependencyDrivenBuildArguments):
582
592
  default_build_targets.append(target)
583
593
  self.default_build_targets = default_build_targets
584
594
  LOGGER.info('Overriding default build targets to %s', self.default_build_targets)
585
- FolderRule.DEFAULT_BUILD_TARGETS = self.default_build_targets
595
+ DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
586
596
  elif self.enable_preview_targets:
587
597
  self.default_build_targets = deepcopy(ALL_TARGETS)
588
598
  LOGGER.info('Overriding default build targets to %s', self.default_build_targets)
589
- FolderRule.DEFAULT_BUILD_TARGETS = self.default_build_targets
590
- else:
591
- # restore default build targets
592
- FolderRule.DEFAULT_BUILD_TARGETS = SUPPORTED_TARGETS
599
+ DEFAULT_BUILD_TARGETS.set(self.default_build_targets) # type: ignore
593
600
 
594
- if self.disable_targets and FolderRule.DEFAULT_BUILD_TARGETS:
601
+ if self.disable_targets and DEFAULT_BUILD_TARGETS.get():
595
602
  LOGGER.info('Disable targets: %s', self.disable_targets)
596
603
  self.default_build_targets = [
597
- _target for _target in FolderRule.DEFAULT_BUILD_TARGETS if _target not in self.disable_targets
604
+ _target for _target in DEFAULT_BUILD_TARGETS.get() if _target not in self.disable_targets
598
605
  ]
599
- FolderRule.DEFAULT_BUILD_TARGETS = self.default_build_targets
606
+ DEFAULT_BUILD_TARGETS.set(self.default_build_targets)
600
607
 
601
608
  if self.override_sdkconfig_files or self.override_sdkconfig_items:
602
609
  SESSION_ARGS.set(self)
idf_build_apps/finder.py CHANGED
@@ -18,6 +18,7 @@ from .args import FindArguments
18
18
  from .constants import (
19
19
  BuildStatus,
20
20
  )
21
+ from .manifest.manifest import DEFAULT_BUILD_TARGETS
21
22
  from .utils import (
22
23
  config_rules_from_str,
23
24
  to_absolute_path,
@@ -33,13 +34,23 @@ def _get_apps_from_path(
33
34
  app_cls: t.Type[App] = CMakeApp,
34
35
  args: FindArguments,
35
36
  ) -> t.List[App]:
36
- # trigger test
37
37
  def _validate_app(_app: App) -> bool:
38
38
  if target not in _app.supported_targets:
39
39
  LOGGER.debug('=> Ignored. %s only supports targets: %s', _app, ', '.join(_app.supported_targets))
40
40
  _app.build_status = BuildStatus.DISABLED
41
41
  return args.include_disabled_apps
42
42
 
43
+ if target == 'all' and _app.target not in DEFAULT_BUILD_TARGETS.get():
44
+ LOGGER.debug(
45
+ '=> Ignored. %s is not in the default build targets: %s', _app.target, DEFAULT_BUILD_TARGETS.get()
46
+ )
47
+ _app.build_status = BuildStatus.DISABLED
48
+ return args.include_disabled_apps
49
+ elif _app.target != target:
50
+ LOGGER.debug('=> Ignored. %s is not for target %s', _app, target)
51
+ _app.build_status = BuildStatus.DISABLED
52
+ return args.include_disabled_apps
53
+
43
54
  _app.check_should_build(
44
55
  manifest_rootpath=args.manifest_rootpath,
45
56
  modified_manifest_rules_folders=args.modified_manifest_rules_folders,
idf_build_apps/main.py CHANGED
@@ -31,7 +31,7 @@ from .app import (
31
31
  AppDeserializer,
32
32
  )
33
33
  from .autocompletions import activate_completions
34
- from .constants import ALL_TARGETS, BuildStatus, completion_instructions
34
+ from .constants import BuildStatus, completion_instructions
35
35
  from .finder import (
36
36
  _find_apps,
37
37
  )
@@ -41,6 +41,7 @@ from .junit import (
41
41
  TestSuite,
42
42
  )
43
43
  from .manifest.manifest import (
44
+ DEFAULT_BUILD_TARGETS,
44
45
  Manifest,
45
46
  )
46
47
  from .utils import (
@@ -88,8 +89,8 @@ def find_apps(
88
89
 
89
90
  apps: t.Set[App] = set()
90
91
  if find_arguments.target == 'all':
91
- targets = ALL_TARGETS
92
- LOGGER.info('Searching for apps by all targets')
92
+ targets = DEFAULT_BUILD_TARGETS.get()
93
+ LOGGER.info('Searching for apps by default build targets: %s', targets)
93
94
  else:
94
95
  targets = [find_arguments.target]
95
96
  LOGGER.info('Searching for apps by target: %s', find_arguments.target)
@@ -7,11 +7,11 @@ Manifest file
7
7
 
8
8
  from esp_bool_parser import register_addition_attribute
9
9
 
10
- from .manifest import FolderRule
10
+ from .manifest import DEFAULT_BUILD_TARGETS
11
11
 
12
12
 
13
13
  def folder_rule_attr(target, **kwargs):
14
- return 1 if target in FolderRule.DEFAULT_BUILD_TARGETS else 0
14
+ return 1 if target in DEFAULT_BUILD_TARGETS.get() else 0
15
15
 
16
16
 
17
17
  register_addition_attribute('INCLUDE_DEFAULT', folder_rule_attr)
@@ -1,8 +1,10 @@
1
1
  # SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
2
2
  # SPDX-License-Identifier: Apache-2.0
3
+ import contextvars
3
4
  import logging
4
5
  import os
5
6
  import typing as t
7
+ import warnings
6
8
  from hashlib import sha512
7
9
 
8
10
  from esp_bool_parser import BoolStmt, parse_bool_expr
@@ -26,6 +28,16 @@ from ..yaml import (
26
28
 
27
29
  LOGGER = logging.getLogger(__name__)
28
30
 
31
+ # Context variable for default build targets
32
+ DEFAULT_BUILD_TARGETS: contextvars.ContextVar[t.List[str]] = contextvars.ContextVar(
33
+ 'default_build_targets', default=SUPPORTED_TARGETS
34
+ )
35
+
36
+
37
+ def reset_default_build_targets() -> None:
38
+ """Reset DEFAULT_BUILD_TARGETS to the default value (SUPPORTED_TARGETS)"""
39
+ DEFAULT_BUILD_TARGETS.set(SUPPORTED_TARGETS)
40
+
29
41
 
30
42
  class IfClause:
31
43
  def __init__(self, stmt: str, temporary: bool = False, reason: t.Optional[str] = None) -> None:
@@ -78,8 +90,65 @@ class SwitchClause:
78
90
  )
79
91
 
80
92
 
81
- class FolderRule:
82
- DEFAULT_BUILD_TARGETS = SUPPORTED_TARGETS
93
+ def _getattr_default_build_targets(name: str) -> t.Any:
94
+ if name == 'DEFAULT_BUILD_TARGETS':
95
+ warnings.warn(
96
+ 'FolderRule.DEFAULT_BUILD_TARGETS is deprecated. Use DEFAULT_BUILD_TARGETS.get() directly.',
97
+ DeprecationWarning,
98
+ stacklevel=2,
99
+ )
100
+ return DEFAULT_BUILD_TARGETS.get()
101
+ return None
102
+
103
+
104
+ def _setattr_default_build_targets(name: str, value: t.Any) -> bool:
105
+ if name == 'DEFAULT_BUILD_TARGETS':
106
+ warnings.warn(
107
+ 'FolderRule.DEFAULT_BUILD_TARGETS is deprecated. Use DEFAULT_BUILD_TARGETS.set() directly.',
108
+ DeprecationWarning,
109
+ stacklevel=2,
110
+ )
111
+ if not isinstance(value, list):
112
+ raise TypeError('Default build targets must be a list')
113
+ DEFAULT_BUILD_TARGETS.set(value)
114
+ return True
115
+ return False
116
+
117
+
118
+ class _FolderRuleMeta(type):
119
+ """Metaclass to handle class-level assignments to DEFAULT_BUILD_TARGETS"""
120
+
121
+ def __getattribute__(cls, name):
122
+ result = _getattr_default_build_targets(name)
123
+ if result is not None:
124
+ return result
125
+ return super().__getattribute__(name)
126
+
127
+ def __setattr__(cls, name, value):
128
+ if _setattr_default_build_targets(name, value):
129
+ return
130
+ super().__setattr__(name, value)
131
+
132
+ def __delattr__(cls, name):
133
+ if name == 'DEFAULT_BUILD_TARGETS':
134
+ # Don't actually delete anything, just ignore the deletion
135
+ # This handles monkeypatch teardown issues
136
+ pass
137
+ else:
138
+ super().__delattr__(name)
139
+
140
+
141
+ class FolderRule(metaclass=_FolderRuleMeta):
142
+ def __getattribute__(self, name): # instance attr
143
+ result = _getattr_default_build_targets(name)
144
+ if result is not None:
145
+ return result
146
+ return super().__getattribute__(name)
147
+
148
+ def __setattr__(self, name, value):
149
+ if _setattr_default_build_targets(name, value):
150
+ return
151
+ super().__setattr__(name, value)
83
152
 
84
153
  def __init__(
85
154
  self,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: idf-build-apps
3
- Version: 2.10.2
3
+ Version: 2.10.3
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,27 +1,27 @@
1
- idf_build_apps/__init__.py,sha256=zkzOAoCvbSslS9KdGqm47Zsd9VZD_XBc_R7g7ODZBTI,711
1
+ idf_build_apps/__init__.py,sha256=flY7hiaet_0R_QNgtqucTKZAd4e5K99pTLbdxVDGevY,711
2
2
  idf_build_apps/__main__.py,sha256=pT6OsFQRjCw39Jg43HAeGKzq8h5E_0m7kHDE2QMqDe0,182
3
- idf_build_apps/app.py,sha256=wwwpEciOFwjTmkb-IoucM1CeIqAYVSPxNAEsxti-Frg,36914
4
- idf_build_apps/args.py,sha256=BBTDk87nBaHodn_VLp65jvhtwjLsskX7qZLTDLRH6kY,37968
3
+ idf_build_apps/app.py,sha256=Z4TZegsyushNPvWcdSv4jJG1TIkuBMGdQ5FkpOSDFlE,36915
4
+ idf_build_apps/args.py,sha256=nyKUDZjP_urzZDmJbkmq_32y0t6wwt-3N59MjLYHWPE,38414
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=wayWyUSCyMvkY72xU-b7IW7I48cv6C-pRqJHMHQsh0c,5794
7
+ idf_build_apps/finder.py,sha256=yJnsYdcbX-TzUDrp8h1YJrLfBziQW4RiyLiJ47sHRY4,6375
8
8
  idf_build_apps/log.py,sha256=15sSQhv9dJsHShDR2KgFGFp8ByjV0HogLr1X1lHYqGs,3899
9
- idf_build_apps/main.py,sha256=BOCAlcN019NkV7s4wBWlNht911Gh9BVT-x9JIj3IlOE,17927
9
+ idf_build_apps/main.py,sha256=GQWx7KH6Qn6z43iZMpdh0myyCJRywf0wmLWFEqRDlL0,17980
10
10
  idf_build_apps/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  idf_build_apps/session_args.py,sha256=yM-78vFzCDCdhXHNxTALmzE4w2NSmka8yVBbh3wtvC8,2985
12
12
  idf_build_apps/utils.py,sha256=cQJ5N-53vrASa4d8WW0AQCPJzendArXyU3kB5Vx-AH8,10880
13
13
  idf_build_apps/junit/__init__.py,sha256=ljILW1rfeBAIlwZIw8jstYrVbugErlmCYzSzJwNFC2I,231
14
14
  idf_build_apps/junit/report.py,sha256=yzt5SiJEA_AUlw2Ld23J7enYlfDluvmKAcCnAM8ccqE,6565
15
15
  idf_build_apps/junit/utils.py,sha256=idBrLgsz6Co2QUQqq1AiyzRHnqbJf_EoykEAxCkjHZw,1303
16
- idf_build_apps/manifest/__init__.py,sha256=LYGR9doEKGPEdsJPuHnmJmV-qw2kuAipV0bodkhY_JE,399
17
- idf_build_apps/manifest/manifest.py,sha256=k33elhIdlYj7sEwLzlxA499_l_Ah6zBolMMk-nioVsg,15368
16
+ idf_build_apps/manifest/__init__.py,sha256=TxNrtn6uiSI4Uh8mQWxws5F7Gd6Lr3rMuBzGyl3yFCE,405
17
+ idf_build_apps/manifest/manifest.py,sha256=ROMK3m3bNfb1Up5pD9cTZOVvAbqVAYAdlGlXHLiQvhg,17693
18
18
  idf_build_apps/manifest/soc_header.py,sha256=_F6H5-HP6ateAqKUGlRGH-SUtQ8NJ1RI0hBeCFvsDYA,172
19
19
  idf_build_apps/vendors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
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.10.2.dist-info/entry_points.txt,sha256=3pVUirUEsb6jsDRikkQWNUt4hqLK2ci1HvW_Vf8b6uE,59
24
- idf_build_apps-2.10.2.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
25
- idf_build_apps-2.10.2.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
- idf_build_apps-2.10.2.dist-info/METADATA,sha256=jaqohtgOUpOEjjxZX4MAOyuIRA-t8QEbxH0yR__bW_k,4795
27
- idf_build_apps-2.10.2.dist-info/RECORD,,
23
+ idf_build_apps-2.10.3.dist-info/entry_points.txt,sha256=3pVUirUEsb6jsDRikkQWNUt4hqLK2ci1HvW_Vf8b6uE,59
24
+ idf_build_apps-2.10.3.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
25
+ idf_build_apps-2.10.3.dist-info/WHEEL,sha256=G2gURzTEtmeR8nrdXUJfNiB3VYVxigPQ-bEQujpNiNs,82
26
+ idf_build_apps-2.10.3.dist-info/METADATA,sha256=9T4kiw8GB4e5qFzKD7W76N4ufKqT1HeXd5H_YOw47vU,4795
27
+ idf_build_apps-2.10.3.dist-info/RECORD,,