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