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.
- fbuild/__init__.py +390 -0
- fbuild/assets/example.txt +1 -0
- fbuild/build/__init__.py +117 -0
- fbuild/build/archive_creator.py +186 -0
- fbuild/build/binary_generator.py +444 -0
- fbuild/build/build_component_factory.py +131 -0
- fbuild/build/build_info_generator.py +624 -0
- fbuild/build/build_state.py +325 -0
- fbuild/build/build_utils.py +93 -0
- fbuild/build/compilation_executor.py +422 -0
- fbuild/build/compiler.py +165 -0
- fbuild/build/compiler_avr.py +574 -0
- fbuild/build/configurable_compiler.py +664 -0
- fbuild/build/configurable_linker.py +637 -0
- fbuild/build/flag_builder.py +214 -0
- fbuild/build/library_dependency_processor.py +185 -0
- fbuild/build/linker.py +708 -0
- fbuild/build/orchestrator.py +67 -0
- fbuild/build/orchestrator_avr.py +651 -0
- fbuild/build/orchestrator_esp32.py +878 -0
- fbuild/build/orchestrator_rp2040.py +719 -0
- fbuild/build/orchestrator_stm32.py +696 -0
- fbuild/build/orchestrator_teensy.py +580 -0
- fbuild/build/source_compilation_orchestrator.py +218 -0
- fbuild/build/source_scanner.py +516 -0
- fbuild/cli.py +717 -0
- fbuild/cli_utils.py +314 -0
- fbuild/config/__init__.py +16 -0
- fbuild/config/board_config.py +542 -0
- fbuild/config/board_loader.py +92 -0
- fbuild/config/ini_parser.py +369 -0
- fbuild/config/mcu_specs.py +88 -0
- fbuild/daemon/__init__.py +42 -0
- fbuild/daemon/async_client.py +531 -0
- fbuild/daemon/client.py +1505 -0
- fbuild/daemon/compilation_queue.py +293 -0
- fbuild/daemon/configuration_lock.py +865 -0
- fbuild/daemon/daemon.py +585 -0
- fbuild/daemon/daemon_context.py +293 -0
- fbuild/daemon/error_collector.py +263 -0
- fbuild/daemon/file_cache.py +332 -0
- fbuild/daemon/firmware_ledger.py +546 -0
- fbuild/daemon/lock_manager.py +508 -0
- fbuild/daemon/logging_utils.py +149 -0
- fbuild/daemon/messages.py +957 -0
- fbuild/daemon/operation_registry.py +288 -0
- fbuild/daemon/port_state_manager.py +249 -0
- fbuild/daemon/process_tracker.py +366 -0
- fbuild/daemon/processors/__init__.py +18 -0
- fbuild/daemon/processors/build_processor.py +248 -0
- fbuild/daemon/processors/deploy_processor.py +664 -0
- fbuild/daemon/processors/install_deps_processor.py +431 -0
- fbuild/daemon/processors/locking_processor.py +777 -0
- fbuild/daemon/processors/monitor_processor.py +285 -0
- fbuild/daemon/request_processor.py +457 -0
- fbuild/daemon/shared_serial.py +819 -0
- fbuild/daemon/status_manager.py +238 -0
- fbuild/daemon/subprocess_manager.py +316 -0
- fbuild/deploy/__init__.py +21 -0
- fbuild/deploy/deployer.py +67 -0
- fbuild/deploy/deployer_esp32.py +310 -0
- fbuild/deploy/docker_utils.py +315 -0
- fbuild/deploy/monitor.py +519 -0
- fbuild/deploy/qemu_runner.py +603 -0
- fbuild/interrupt_utils.py +34 -0
- fbuild/ledger/__init__.py +52 -0
- fbuild/ledger/board_ledger.py +560 -0
- fbuild/output.py +352 -0
- fbuild/packages/__init__.py +66 -0
- fbuild/packages/archive_utils.py +1098 -0
- fbuild/packages/arduino_core.py +412 -0
- fbuild/packages/cache.py +256 -0
- fbuild/packages/concurrent_manager.py +510 -0
- fbuild/packages/downloader.py +518 -0
- fbuild/packages/fingerprint.py +423 -0
- fbuild/packages/framework_esp32.py +538 -0
- fbuild/packages/framework_rp2040.py +349 -0
- fbuild/packages/framework_stm32.py +459 -0
- fbuild/packages/framework_teensy.py +346 -0
- fbuild/packages/github_utils.py +96 -0
- fbuild/packages/header_trampoline_cache.py +394 -0
- fbuild/packages/library_compiler.py +203 -0
- fbuild/packages/library_manager.py +549 -0
- fbuild/packages/library_manager_esp32.py +725 -0
- fbuild/packages/package.py +163 -0
- fbuild/packages/platform_esp32.py +383 -0
- fbuild/packages/platform_rp2040.py +400 -0
- fbuild/packages/platform_stm32.py +581 -0
- fbuild/packages/platform_teensy.py +312 -0
- fbuild/packages/platform_utils.py +131 -0
- fbuild/packages/platformio_registry.py +369 -0
- fbuild/packages/sdk_utils.py +231 -0
- fbuild/packages/toolchain.py +436 -0
- fbuild/packages/toolchain_binaries.py +196 -0
- fbuild/packages/toolchain_esp32.py +489 -0
- fbuild/packages/toolchain_metadata.py +185 -0
- fbuild/packages/toolchain_rp2040.py +436 -0
- fbuild/packages/toolchain_stm32.py +417 -0
- fbuild/packages/toolchain_teensy.py +404 -0
- fbuild/platform_configs/esp32.json +150 -0
- fbuild/platform_configs/esp32c2.json +144 -0
- fbuild/platform_configs/esp32c3.json +143 -0
- fbuild/platform_configs/esp32c5.json +151 -0
- fbuild/platform_configs/esp32c6.json +151 -0
- fbuild/platform_configs/esp32p4.json +149 -0
- fbuild/platform_configs/esp32s3.json +151 -0
- fbuild/platform_configs/imxrt1062.json +56 -0
- fbuild/platform_configs/rp2040.json +70 -0
- fbuild/platform_configs/rp2350.json +76 -0
- fbuild/platform_configs/stm32f1.json +59 -0
- fbuild/platform_configs/stm32f4.json +63 -0
- fbuild/py.typed +0 -0
- fbuild-1.2.8.dist-info/METADATA +468 -0
- fbuild-1.2.8.dist-info/RECORD +121 -0
- fbuild-1.2.8.dist-info/WHEEL +5 -0
- fbuild-1.2.8.dist-info/entry_points.txt +5 -0
- fbuild-1.2.8.dist-info/licenses/LICENSE +21 -0
- fbuild-1.2.8.dist-info/top_level.txt +2 -0
- fbuild_lint/__init__.py +0 -0
- fbuild_lint/ruff_plugins/__init__.py +0 -0
- 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
|