fbuild 1.1.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.

Potentially problematic release.


This version of fbuild might be problematic. Click here for more details.

Files changed (93) hide show
  1. fbuild/__init__.py +0 -0
  2. fbuild/assets/example.txt +1 -0
  3. fbuild/build/__init__.py +117 -0
  4. fbuild/build/archive_creator.py +186 -0
  5. fbuild/build/binary_generator.py +444 -0
  6. fbuild/build/build_component_factory.py +131 -0
  7. fbuild/build/build_state.py +325 -0
  8. fbuild/build/build_utils.py +98 -0
  9. fbuild/build/compilation_executor.py +422 -0
  10. fbuild/build/compiler.py +165 -0
  11. fbuild/build/compiler_avr.py +574 -0
  12. fbuild/build/configurable_compiler.py +612 -0
  13. fbuild/build/configurable_linker.py +637 -0
  14. fbuild/build/flag_builder.py +186 -0
  15. fbuild/build/library_dependency_processor.py +185 -0
  16. fbuild/build/linker.py +708 -0
  17. fbuild/build/orchestrator.py +67 -0
  18. fbuild/build/orchestrator_avr.py +656 -0
  19. fbuild/build/orchestrator_esp32.py +797 -0
  20. fbuild/build/orchestrator_teensy.py +543 -0
  21. fbuild/build/source_compilation_orchestrator.py +220 -0
  22. fbuild/build/source_scanner.py +516 -0
  23. fbuild/cli.py +566 -0
  24. fbuild/cli_utils.py +312 -0
  25. fbuild/config/__init__.py +16 -0
  26. fbuild/config/board_config.py +457 -0
  27. fbuild/config/board_loader.py +92 -0
  28. fbuild/config/ini_parser.py +209 -0
  29. fbuild/config/mcu_specs.py +88 -0
  30. fbuild/daemon/__init__.py +34 -0
  31. fbuild/daemon/client.py +929 -0
  32. fbuild/daemon/compilation_queue.py +293 -0
  33. fbuild/daemon/daemon.py +474 -0
  34. fbuild/daemon/daemon_context.py +196 -0
  35. fbuild/daemon/error_collector.py +263 -0
  36. fbuild/daemon/file_cache.py +332 -0
  37. fbuild/daemon/lock_manager.py +270 -0
  38. fbuild/daemon/logging_utils.py +149 -0
  39. fbuild/daemon/messages.py +301 -0
  40. fbuild/daemon/operation_registry.py +288 -0
  41. fbuild/daemon/process_tracker.py +366 -0
  42. fbuild/daemon/processors/__init__.py +12 -0
  43. fbuild/daemon/processors/build_processor.py +157 -0
  44. fbuild/daemon/processors/deploy_processor.py +327 -0
  45. fbuild/daemon/processors/monitor_processor.py +146 -0
  46. fbuild/daemon/request_processor.py +401 -0
  47. fbuild/daemon/status_manager.py +216 -0
  48. fbuild/daemon/subprocess_manager.py +316 -0
  49. fbuild/deploy/__init__.py +17 -0
  50. fbuild/deploy/deployer.py +67 -0
  51. fbuild/deploy/deployer_esp32.py +314 -0
  52. fbuild/deploy/monitor.py +495 -0
  53. fbuild/interrupt_utils.py +34 -0
  54. fbuild/packages/__init__.py +53 -0
  55. fbuild/packages/archive_utils.py +1098 -0
  56. fbuild/packages/arduino_core.py +412 -0
  57. fbuild/packages/cache.py +249 -0
  58. fbuild/packages/downloader.py +366 -0
  59. fbuild/packages/framework_esp32.py +538 -0
  60. fbuild/packages/framework_teensy.py +346 -0
  61. fbuild/packages/github_utils.py +96 -0
  62. fbuild/packages/header_trampoline_cache.py +394 -0
  63. fbuild/packages/library_compiler.py +203 -0
  64. fbuild/packages/library_manager.py +549 -0
  65. fbuild/packages/library_manager_esp32.py +413 -0
  66. fbuild/packages/package.py +163 -0
  67. fbuild/packages/platform_esp32.py +383 -0
  68. fbuild/packages/platform_teensy.py +312 -0
  69. fbuild/packages/platform_utils.py +131 -0
  70. fbuild/packages/platformio_registry.py +325 -0
  71. fbuild/packages/sdk_utils.py +231 -0
  72. fbuild/packages/toolchain.py +436 -0
  73. fbuild/packages/toolchain_binaries.py +196 -0
  74. fbuild/packages/toolchain_esp32.py +484 -0
  75. fbuild/packages/toolchain_metadata.py +185 -0
  76. fbuild/packages/toolchain_teensy.py +404 -0
  77. fbuild/platform_configs/esp32.json +150 -0
  78. fbuild/platform_configs/esp32c2.json +144 -0
  79. fbuild/platform_configs/esp32c3.json +143 -0
  80. fbuild/platform_configs/esp32c5.json +151 -0
  81. fbuild/platform_configs/esp32c6.json +151 -0
  82. fbuild/platform_configs/esp32p4.json +149 -0
  83. fbuild/platform_configs/esp32s3.json +151 -0
  84. fbuild/platform_configs/imxrt1062.json +56 -0
  85. fbuild-1.1.0.dist-info/METADATA +447 -0
  86. fbuild-1.1.0.dist-info/RECORD +93 -0
  87. fbuild-1.1.0.dist-info/WHEEL +5 -0
  88. fbuild-1.1.0.dist-info/entry_points.txt +5 -0
  89. fbuild-1.1.0.dist-info/licenses/LICENSE +21 -0
  90. fbuild-1.1.0.dist-info/top_level.txt +2 -0
  91. fbuild_lint/__init__.py +0 -0
  92. fbuild_lint/ruff_plugins/__init__.py +0 -0
  93. fbuild_lint/ruff_plugins/keyboard_interrupt_checker.py +158 -0
@@ -0,0 +1,220 @@
1
+ """
2
+ Source file compilation orchestration for Fbuild build system.
3
+
4
+ This module handles the orchestration of compiling multiple source files,
5
+ including caching, progress reporting, and error handling. It provides a
6
+ higher-level interface over the low-level ICompiler interface.
7
+ """
8
+
9
+ from pathlib import Path
10
+ from typing import List
11
+
12
+ from .compiler import ICompiler, CompilerError
13
+
14
+
15
+ class SourceCompilationOrchestratorError(Exception):
16
+ """Exception raised for source compilation orchestration errors."""
17
+ pass
18
+
19
+
20
+ class SourceCompilationOrchestrator:
21
+ """
22
+ Orchestrates compilation of source files with caching and progress reporting.
23
+
24
+ This class provides a higher-level interface for compiling multiple source
25
+ files, handling:
26
+ - Incremental compilation with caching
27
+ - Progress reporting and verbose output
28
+ - Error handling and reporting
29
+ - Categorization by source type (sketch, core, variant)
30
+
31
+ Example usage:
32
+ orchestrator = SourceCompilationOrchestrator(verbose=True)
33
+ objects = orchestrator.compile_sources(
34
+ compiler=compiler,
35
+ sources=[Path("main.cpp"), Path("utils.cpp")],
36
+ output_dir=Path(".fbuild/build/uno/src"),
37
+ source_type="sketch"
38
+ )
39
+ """
40
+
41
+ def __init__(self, verbose: bool = False):
42
+ """
43
+ Initialize source compilation orchestrator.
44
+
45
+ Args:
46
+ verbose: Enable verbose output
47
+ """
48
+ self.verbose = verbose
49
+
50
+ def compile_sources(
51
+ self,
52
+ compiler: ICompiler,
53
+ sources: List[Path],
54
+ output_dir: Path,
55
+ source_type: str
56
+ ) -> List[Path]:
57
+ """
58
+ Compile list of source files.
59
+
60
+ Compiles each source file to an object file, using cached objects when
61
+ possible. Reports progress based on verbose setting.
62
+
63
+ Supports both sync and async compilation modes. When compiler has
64
+ a compilation_queue set, submissions are async and this method waits
65
+ for all jobs to complete before returning.
66
+
67
+ Args:
68
+ compiler: Compiler instance
69
+ sources: List of source files to compile
70
+ output_dir: Output directory for object files
71
+ source_type: Type of sources for logging (e.g., 'sketch', 'core', 'variant')
72
+
73
+ Returns:
74
+ List of compiled object file paths
75
+
76
+ Raises:
77
+ SourceCompilationOrchestratorError: If compilation fails
78
+ """
79
+ # Ensure output directory exists
80
+ output_dir.mkdir(parents=True, exist_ok=True)
81
+
82
+ objects = []
83
+
84
+ for source in sources:
85
+ # Generate output object filename
86
+ obj_name = source.stem + '.o'
87
+ obj_path = output_dir / obj_name
88
+
89
+ # Check if rebuild needed (incremental compilation)
90
+ if not compiler.needs_rebuild(source, obj_path):
91
+ if self.verbose:
92
+ print(f" [{source_type}] {source.name} (cached)")
93
+ objects.append(obj_path)
94
+ continue
95
+
96
+ # Compile source file
97
+ if self.verbose:
98
+ print(f" [{source_type}] {source.name}")
99
+
100
+ try:
101
+ result = compiler.compile(source, obj_path)
102
+
103
+ if not result.success:
104
+ raise SourceCompilationOrchestratorError(
105
+ f"Compilation failed for {source}:\n{result.stderr}"
106
+ )
107
+
108
+ objects.append(obj_path)
109
+
110
+ except CompilerError as e:
111
+ raise SourceCompilationOrchestratorError(
112
+ f"Compilation failed for {source}: {e}"
113
+ )
114
+
115
+ # Wait for all async jobs to complete (if using async mode)
116
+ # This is a no-op for sync compilation
117
+ try:
118
+ if hasattr(compiler, 'wait_all_jobs') and callable(getattr(compiler, 'wait_all_jobs')):
119
+ getattr(compiler, 'wait_all_jobs')()
120
+ except CompilerError as e:
121
+ raise SourceCompilationOrchestratorError(
122
+ f"Async compilation failed: {e}"
123
+ )
124
+
125
+ return objects
126
+
127
+ def compile_multiple_groups(
128
+ self,
129
+ compiler: ICompiler,
130
+ sketch_sources: List[Path],
131
+ core_sources: List[Path],
132
+ variant_sources: List[Path],
133
+ src_build_dir: Path,
134
+ core_build_dir: Path
135
+ ) -> 'MultiGroupCompilationResult':
136
+ """
137
+ Compile multiple groups of sources (sketch, core, variant).
138
+
139
+ Convenience method for compiling all source groups in a typical build.
140
+
141
+ Args:
142
+ compiler: Compiler instance
143
+ sketch_sources: List of sketch source files
144
+ core_sources: List of Arduino core source files
145
+ variant_sources: List of variant source files
146
+ src_build_dir: Build directory for sketch sources
147
+ core_build_dir: Build directory for core and variant sources
148
+
149
+ Returns:
150
+ MultiGroupCompilationResult with all compiled objects
151
+
152
+ Raises:
153
+ SourceCompilationOrchestratorError: If any compilation fails
154
+ """
155
+ # Compile sketch sources
156
+ sketch_objects = self.compile_sources(
157
+ compiler,
158
+ sketch_sources,
159
+ src_build_dir,
160
+ "sketch"
161
+ )
162
+
163
+ # Compile core sources
164
+ core_objects = self.compile_sources(
165
+ compiler,
166
+ core_sources,
167
+ core_build_dir,
168
+ "core"
169
+ )
170
+
171
+ # Compile variant sources
172
+ variant_objects = self.compile_sources(
173
+ compiler,
174
+ variant_sources,
175
+ core_build_dir,
176
+ "variant"
177
+ )
178
+
179
+ # Combine core and variant objects
180
+ all_core_objects = core_objects + variant_objects
181
+
182
+ if self.verbose:
183
+ total_objects = len(sketch_objects) + len(all_core_objects)
184
+ print(f" Compiled {total_objects} objects")
185
+
186
+ return MultiGroupCompilationResult(
187
+ sketch_objects=sketch_objects,
188
+ core_objects=core_objects,
189
+ variant_objects=variant_objects,
190
+ all_core_objects=all_core_objects
191
+ )
192
+
193
+
194
+ class MultiGroupCompilationResult:
195
+ """
196
+ Result of compiling multiple source groups.
197
+
198
+ Contains object files organized by source type.
199
+ """
200
+
201
+ def __init__(
202
+ self,
203
+ sketch_objects: List[Path],
204
+ core_objects: List[Path],
205
+ variant_objects: List[Path],
206
+ all_core_objects: List[Path]
207
+ ):
208
+ """
209
+ Initialize multi-group compilation result.
210
+
211
+ Args:
212
+ sketch_objects: Compiled sketch object files
213
+ core_objects: Compiled core object files
214
+ variant_objects: Compiled variant object files
215
+ all_core_objects: Combined core and variant object files
216
+ """
217
+ self.sketch_objects = sketch_objects
218
+ self.core_objects = core_objects
219
+ self.variant_objects = variant_objects
220
+ self.all_core_objects = all_core_objects