fbuild 1.2.8__py3-none-any.whl → 1.2.15__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 (47) hide show
  1. fbuild/__init__.py +5 -1
  2. fbuild/build/configurable_compiler.py +49 -6
  3. fbuild/build/configurable_linker.py +14 -9
  4. fbuild/build/orchestrator_esp32.py +6 -3
  5. fbuild/build/orchestrator_rp2040.py +6 -2
  6. fbuild/cli.py +300 -5
  7. fbuild/config/ini_parser.py +13 -1
  8. fbuild/daemon/__init__.py +11 -0
  9. fbuild/daemon/async_client.py +5 -4
  10. fbuild/daemon/async_client_lib.py +1543 -0
  11. fbuild/daemon/async_protocol.py +825 -0
  12. fbuild/daemon/async_server.py +2100 -0
  13. fbuild/daemon/client.py +425 -13
  14. fbuild/daemon/configuration_lock.py +13 -13
  15. fbuild/daemon/connection.py +508 -0
  16. fbuild/daemon/connection_registry.py +579 -0
  17. fbuild/daemon/daemon.py +517 -164
  18. fbuild/daemon/daemon_context.py +72 -1
  19. fbuild/daemon/device_discovery.py +477 -0
  20. fbuild/daemon/device_manager.py +821 -0
  21. fbuild/daemon/error_collector.py +263 -263
  22. fbuild/daemon/file_cache.py +332 -332
  23. fbuild/daemon/firmware_ledger.py +46 -123
  24. fbuild/daemon/lock_manager.py +508 -508
  25. fbuild/daemon/messages.py +431 -0
  26. fbuild/daemon/operation_registry.py +288 -288
  27. fbuild/daemon/processors/build_processor.py +34 -1
  28. fbuild/daemon/processors/deploy_processor.py +1 -3
  29. fbuild/daemon/processors/locking_processor.py +7 -7
  30. fbuild/daemon/request_processor.py +457 -457
  31. fbuild/daemon/shared_serial.py +7 -7
  32. fbuild/daemon/status_manager.py +238 -238
  33. fbuild/daemon/subprocess_manager.py +316 -316
  34. fbuild/deploy/docker_utils.py +182 -2
  35. fbuild/deploy/monitor.py +1 -1
  36. fbuild/deploy/qemu_runner.py +71 -13
  37. fbuild/ledger/board_ledger.py +46 -122
  38. fbuild/output.py +238 -2
  39. fbuild/packages/library_compiler.py +15 -5
  40. fbuild/packages/library_manager.py +12 -6
  41. fbuild-1.2.15.dist-info/METADATA +569 -0
  42. {fbuild-1.2.8.dist-info → fbuild-1.2.15.dist-info}/RECORD +46 -39
  43. fbuild-1.2.8.dist-info/METADATA +0 -468
  44. {fbuild-1.2.8.dist-info → fbuild-1.2.15.dist-info}/WHEEL +0 -0
  45. {fbuild-1.2.8.dist-info → fbuild-1.2.15.dist-info}/entry_points.txt +0 -0
  46. {fbuild-1.2.8.dist-info → fbuild-1.2.15.dist-info}/licenses/LICENSE +0 -0
  47. {fbuild-1.2.8.dist-info → fbuild-1.2.15.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,569 @@
1
+ Metadata-Version: 2.4
2
+ Name: fbuild
3
+ Version: 1.2.15
4
+ Summary: Modern replacement for PlatformIO with URL-based platform/toolchain management and bug-free architecture
5
+ Home-page: https://github.com/fastled/fbuild
6
+ Maintainer: Zachary Vorhies
7
+ License: BSD 3-Clause License
8
+ Keywords: embedded,arduino,platformio,compiler,toolchain,firmware,microcontroller
9
+ Classifier: Programming Language :: Python :: 3
10
+ Requires-Python: >=3.10
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: requests>=2.28.0
14
+ Requires-Dist: tqdm>=4.64.0
15
+ Requires-Dist: pyserial>=3.5
16
+ Requires-Dist: esptool>=4.6.0
17
+ Requires-Dist: psutil>=5.9.0
18
+ Provides-Extra: dev
19
+ Requires-Dist: pytest>=7.0; extra == "dev"
20
+ Requires-Dist: pytest-cov; extra == "dev"
21
+ Requires-Dist: pytest-xdist; extra == "dev"
22
+ Dynamic: home-page
23
+ Dynamic: license-file
24
+ Dynamic: maintainer
25
+
26
+ ![fbuild](https://github.com/user-attachments/assets/7db78eba-b10f-44c7-ae32-7fc0b5e46642)
27
+
28
+ [![Build Arduino Uno](https://github.com/fastled/fbuild/actions/workflows/build-uno.yml/badge.svg)](https://github.com/fastled/fbuild/actions/workflows/build-uno.yml) [![Build ESP32 Dev](https://github.com/fastled/fbuild/actions/workflows/build-esp32dev.yml/badge.svg)](https://github.com/fastled/fbuild/actions/workflows/build-esp32dev.yml) [![Build ESP32-C6](https://github.com/fastled/fbuild/actions/workflows/build-esp32c6.yml/badge.svg)](https://github.com/fastled/fbuild/actions/workflows/build-esp32c6.yml) [![Build ESP32-S3](https://github.com/fastled/fbuild/actions/workflows/build-esp32s3.yml/badge.svg)](https://github.com/fastled/fbuild/actions/workflows/build-esp32s3.yml) [![Build ESP32-C2](https://github.com/fastled/fbuild/actions/workflows/build-esp32c2.yml/badge.svg)](https://github.com/fastled/fbuild/actions/workflows/build-esp32c2.yml)
29
+
30
+ *A fast, next-generation multi-platform compiler, deployer, and monitor for embedded development, directly compatible with platformio*
31
+
32
+ # fbuild
33
+
34
+ Fbuild is a next-generation embedded development tool featuring a clean, transparent architecture. It provides fast incremental builds, URL-based package management, and soon to be comprehensive multi-platform support for Arduino and ESP32 development.
35
+
36
+ **platformio.ini compatible**
37
+
38
+ fbuiold uses the same `platformio.ini` already used in platformio sketches.
39
+
40
+ **Design Goals**
41
+
42
+ * Replaces `platformio` in `FastLED` repo builders
43
+ * Correct and parallel package management system
44
+ * locking is done through a daemon process
45
+ * packages are fingerprinted to their version and cached, download only once
46
+ * sccache for caching compiles
47
+ * Eesily add features via AI
48
+ * This codebase is designed and implemented by AI, just fork it and ask ai to make your change Please send us a PR!
49
+
50
+ **Current Status**: v1.1.0 - Full Arduino Uno / esp32c6 support with working build system
51
+
52
+ ## Examples
53
+
54
+ **Quick start** - Build, deploy, and monitor in one command:
55
+
56
+ ```bash
57
+ # install
58
+ pip install fbuild
59
+ ```
60
+
61
+ ```bash
62
+ # Default action: build + deploy
63
+ fbuild tests/esp32c6
64
+ ```
65
+
66
+ ```bash
67
+ # Default action: build + deploy + monitor
68
+ fbuild tests/esp32c6 --monitor
69
+ ```
70
+
71
+
72
+ **Deploy commands:**
73
+
74
+ ```bash
75
+ # Deploy with clean build
76
+ uv run fbuild deploy tests/esp32c6 --clean
77
+
78
+ # Deploy with monitoring and test patterns
79
+ uv run fbuild deploy tests/esp32c6 --monitor="--timeout 60 --halt-on-error \"TEST FAILED\" --halt-on-success \"TEST PASSED\""
80
+ ```
81
+
82
+ **Monitor command:**
83
+
84
+ ```bash
85
+ # Monitor serial output with pattern matching
86
+ uv run fbuild monitor --timeout 60 --halt-on-error "TEST FAILED" --halt-on-success "TEST PASSED"
87
+ ```
88
+
89
+ * Serial monitoring requires pyserial to attach to the USB device
90
+ * Port auto-detection works similarly to PlatformIO
91
+
92
+ ## Key Features
93
+
94
+ - **URL-based Package Management**: Direct URLs to toolchains and platforms - no hidden registries
95
+ - **Library Management**: Download and compile Arduino libraries from GitHub URLs
96
+ - **Fast Incremental Builds**: 0.76s rebuilds, 3s full builds (cached)
97
+ - **LTO Support**: Link-Time Optimization for optimal code size
98
+ - **Transparent Architecture**: Know exactly what's happening at every step
99
+ - **Real Downloads, No Mocks**: All packages are real, validated, and checksummed
100
+ - **Cross-platform Support**: Windows, macOS, and Linux
101
+ - **Modern Python**: 100% type-safe, PEP 8 compliant, tested
102
+
103
+ ## Installation
104
+
105
+ ```bash
106
+ # Install from PyPI (when published)
107
+ pip install fbuild
108
+
109
+ # Or install from source
110
+ git clone https://github.com/yourusername/fbuild.git
111
+ cd fbuild
112
+ pip install -e .
113
+ ```
114
+
115
+ ## Quick Start
116
+
117
+ ### Building an Arduino Uno Project
118
+
119
+ 1. **Create project structure**:
120
+ ```bash
121
+ mkdir my-project && cd my-project
122
+ mkdir src
123
+ ```
124
+
125
+ 2. **Create platformio.ini**:
126
+ ```ini
127
+ [env:uno]
128
+ platform = atmelavr
129
+ board = uno
130
+ framework = arduino
131
+ ```
132
+
133
+ 3. **Write your sketch** (`src/main.ino`):
134
+ ```cpp
135
+ void setup() {
136
+ pinMode(LED_BUILTIN, OUTPUT);
137
+ }
138
+
139
+ void loop() {
140
+ digitalWrite(LED_BUILTIN, HIGH);
141
+ delay(1000);
142
+ digitalWrite(LED_BUILTIN, LOW);
143
+ delay(1000);
144
+ }
145
+ ```
146
+
147
+ 4. **Build**:
148
+ ```bash
149
+ fbuild build
150
+ ```
151
+
152
+ On first build, Fbuild will:
153
+ - Download AVR-GCC toolchain (50MB, one-time)
154
+ - Download Arduino AVR core (5MB, one-time)
155
+ - Compile your sketch
156
+ - Generate `firmware.hex` in `.fbuild/build/uno/`
157
+
158
+ **Build time**: ~19s first build, ~3s subsequent builds, <1s incremental
159
+
160
+ ## CLI Usage
161
+
162
+ ### Build Command
163
+
164
+ ```bash
165
+ # Build with auto-detected environment
166
+ fbuild build
167
+
168
+ # Build specific environment
169
+ fbuild build --environment uno
170
+ fbuild build -e mega
171
+
172
+ # Clean build (remove all build artifacts)
173
+ fbuild build --clean
174
+
175
+ # Verbose output (shows all compiler commands)
176
+ fbuild build --verbose
177
+
178
+ # Build in different directory
179
+ fbuild build --project-dir /path/to/project
180
+ ```
181
+
182
+ ### Output
183
+
184
+ ```
185
+ Building environment: uno
186
+ Downloading toolchain: avr-gcc 7.3.0-atmel3.6.1-arduino7
187
+ Downloading: 100% ████████████████████ 50.1MB/50.1MB
188
+ Extracting package...
189
+ Toolchain ready at: .fbuild/cache/...
190
+ Downloading Arduino core: 1.8.6
191
+ Compiling sketch...
192
+ Compiling Arduino core...
193
+ Linking firmware...
194
+ Converting to Intel HEX...
195
+
196
+ ✓ Build successful!
197
+
198
+ Firmware: .fbuild/build/uno/firmware.hex
199
+ Program: 1058 bytes (3.3% of 32256 bytes)
200
+ RAM: 9 bytes (0.4% of 2048 bytes)
201
+ Build time: 3.06s
202
+ ```
203
+
204
+ ## Configuration
205
+
206
+ ### platformio.ini Reference
207
+
208
+ **Minimal configuration**:
209
+ ```ini
210
+ [env:uno]
211
+ platform = atmelavr
212
+ board = uno
213
+ framework = arduino
214
+ ```
215
+
216
+ **Full configuration**:
217
+ ```ini
218
+ [platformio]
219
+ default_envs = uno
220
+
221
+ [env:uno]
222
+ platform = atmelavr
223
+ board = uno
224
+ framework = arduino
225
+ upload_port = COM3 # Future: for uploading
226
+ monitor_speed = 9600 # Future: for serial monitor
227
+ build_flags =
228
+ -DDEBUG
229
+ -DLED_PIN=13
230
+ lib_deps =
231
+ https://github.com/FastLED/FastLED
232
+ https://github.com/adafruit/Adafruit_NeoPixel
233
+ ```
234
+
235
+ ### Library Dependencies
236
+
237
+ Fbuild supports downloading and compiling Arduino libraries directly from GitHub URLs:
238
+
239
+ ```ini
240
+ [env:uno]
241
+ platform = atmelavr
242
+ board = uno
243
+ framework = arduino
244
+ lib_deps =
245
+ https://github.com/FastLED/FastLED
246
+ ```
247
+
248
+ **Features**:
249
+ - Automatic GitHub URL optimization (converts repo URLs to zip downloads)
250
+ - Automatic branch detection (main vs master)
251
+ - Proper Arduino library structure handling
252
+ - LTO (Link-Time Optimization) for optimal code size
253
+ - Support for complex libraries with assembly optimizations
254
+
255
+ **Example build with FastLED**:
256
+ ```
257
+ ✓ Build successful!
258
+ Firmware: tests/uno/.fbuild/build/uno/firmware.hex
259
+ Size: 12KB (4318 bytes program, 3689 bytes RAM)
260
+ Build time: 78.59 seconds
261
+ ```
262
+
263
+
264
+ ### Supported Platforms and Boards
265
+
266
+ **Arduino AVR Platform** - Fully Supported ✓
267
+ - **Arduino Uno** (atmega328p, 16MHz) - Fully tested ✓
268
+
269
+ **ESP32 Platform** - Supported ✓
270
+ - **ESP32 Dev** (esp32dev) - Supported ✓
271
+ - **ESP32-C3** (esp32-c3-devkitm-1) - Supported ✓
272
+ - **ESP32-C6** (esp32c6-devkit) - Supported ✓
273
+ - **ESP32-S3** (esp32-s3-devkitc-1) - Supported ✓
274
+ - **ESP32-S2** - Supported ✓
275
+ - **ESP32-H2** - Supported ✓
276
+ - **ESP32-P4** - Supported ✓
277
+ - **ESP32-C2** - Supported ✓ (v0.1.0+)
278
+ - Uses skeleton library approach with ROM linker scripts
279
+ - Full Arduino framework support
280
+ - 220KB firmware size typical
281
+
282
+ **Planned Support**:
283
+ - Arduino Mega
284
+ - Arduino Nano
285
+ - Arduino Leonardo
286
+ - More AVR boards
287
+ - Teensy 3.x/4.x platforms
288
+ ## Performance
289
+
290
+ **Benchmarks** (Arduino Uno Blink sketch):
291
+
292
+ | Build Type | Time | Description |
293
+ |------------|------|-------------|
294
+ | First build | 19.25s | Includes toolchain download (50MB) |
295
+ | Full build | 3.06s | All packages cached |
296
+ | Incremental | 0.76s | No source changes |
297
+ | Clean build | 2.58s | Rebuild from cache |
298
+
299
+ **Firmware Size** (Blink):
300
+ - Program: 1,058 bytes (3.3% of 32KB flash)
301
+ - RAM: 9 bytes (0.4% of 2KB RAM)
302
+
303
+ ## Key Benefits
304
+
305
+ ### Transparency
306
+ Direct URLs and hash-based caching mean you know exactly what you're downloading. No hidden package registries or opaque dependency resolution.
307
+
308
+ ### Reliability
309
+ Real downloads with checksum verification ensure consistent, reproducible builds. No mocks in production code.
310
+
311
+ ### Speed
312
+ Optimized incremental builds complete in under 1 second, with intelligent caching for full rebuilds in 2-5 seconds.
313
+
314
+ ### Code Quality
315
+ 100% type-safe (mypy), PEP 8 compliant, and comprehensive test coverage ensure a maintainable and reliable codebase.
316
+
317
+ ### Clear Error Messages
318
+ Actionable error messages with suggestions help you quickly identify and fix issues without requiring forum searches.
319
+
320
+ ## Architecture
321
+
322
+ See [docs/build-system.md](docs/build-system.md) for comprehensive architecture documentation.
323
+ See [docs/architecture.dot](docs/architecture.dot) for a Graphviz diagram (render with `dot -Tpng`).
324
+
325
+ ```
326
+ ┌─────────────────────────────────────────────────────────────────────────────────────────┐
327
+ │ CLI LAYER │
328
+ │ ┌─────────────────────────────────────────────────────────────────────────────────┐ │
329
+ │ │ cli.py │ │
330
+ │ │ ├── build command ──────┐ │ │
331
+ │ │ ├── deploy command ─────┼──► daemon/client.py ──► IPC (file-based) ──┐ │ │
332
+ │ │ └── monitor command ────┘ │ │ │
333
+ │ └────────────────────────────────────────────────────────────────────────│────────┘ │
334
+ └───────────────────────────────────────────────────────────────────────────│─────────────┘
335
+
336
+ ┌─────────────────────────────────────────────────────────────────────────────────────────┐
337
+ │ DAEMON LAYER (Background Process) │
338
+ │ │
339
+ │ ┌──────────────────────────────────────────────────────────────────────────────────┐ │
340
+ │ │ daemon.py (Server) │ │
341
+ │ │ ├── lock_manager.py (ResourceLockManager) ◄── Memory-based locks only! │ │
342
+ │ │ ├── status_manager.py │ │
343
+ │ │ ├── process_tracker.py │ │
344
+ │ │ └── device_manager.py ──► device_discovery.py │ │
345
+ │ │ └── shared_serial.py │ │
346
+ │ └──────────────────────────────────────────────────────────────────────────────────┘ │
347
+ │ │ │
348
+ │ ▼ │
349
+ │ ┌─────────────────────────────────────────────────────────────────────────────────┐ │
350
+ │ │ Request Processors (daemon/processors/) │ │
351
+ │ │ ├── build_processor.py ────────────► BUILD LAYER │ │
352
+ │ │ ├── deploy_processor.py ───────────► DEPLOY LAYER │ │
353
+ │ │ ├── monitor_processor.py ──────────► monitor.py │ │
354
+ │ │ └── install_deps_processor.py ─────► PACKAGES LAYER │ │
355
+ │ └─────────────────────────────────────────────────────────────────────────────────┘ │
356
+ └─────────────────────────────────────────────────────────────────────────────────────────┘
357
+
358
+ ┌──────────────────┼──────────────────┐
359
+ ▼ ▼ ▼
360
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────────────────────────────────────┐
361
+ │ CONFIG LAYER │ │ PACKAGES LAYER │ │ BUILD LAYER │
362
+ │ │ │ │ │ │
363
+ │ ┌─────────────┐ │ │ ┌─────────────┐ │ │ ┌─────────────────────────────────────────────┐ │
364
+ │ │ ini_parser │ │ │ │ cache.py │ │ │ │ Platform Orchestrators │ │
365
+ │ │ .py │ │ │ │ │ │ │ │ │ orchestrator.py (IBuildOrchestrator) │ │
366
+ │ │ (PlatformIO │ │ │ │ ▼ │ │ │ │ │ │ │
367
+ │ │ Config) │ │ │ │ downloader │ │ │ │ ├── orchestrator_avr.py │ │
368
+ │ │ │ │ │ │ │ .py │ │ │ │ ├── orchestrator_esp32.py │ │
369
+ │ │ ▼ │ │ │ └──────┬──────┘ │ │ │ ├── orchestrator_rp2040.py │ │
370
+ │ │board_config │ │ │ │ │ │ │ ├── orchestrator_stm32.py │ │
371
+ │ │ .py │ │ │ ▼ │ │ │ └── orchestrator_teensy.py │ │
372
+ │ │ │ │ │ │ ┌─────────────┐ │ │ └─────────────────────────────────────────────┘ │
373
+ │ │ ▼ │ │ │ │ Toolchains │ │ │ │ │
374
+ │ │board_loader │ │ │ │ toolchain │ │ │ ▼ │
375
+ │ │ .py │ │ │ │ .py (AVR) │ │ │ ┌─────────────────────────────────────────────┐ │
376
+ │ │ │ │ │ │ │ toolchain_ │ │ │ │ Compilation │ │
377
+ │ │ ▼ │ │ │ │ esp32.py │ │ │ │ source_scanner.py ──► compiler.py │ │
378
+ │ │ mcu_specs │ │ │ │ toolchain_ │ │ │ │ │ │ │
379
+ │ │ .py │ │ │ │ rp2040.py │ │ │ │ configurable_compiler.py │ │ │
380
+ │ └─────────────┘ │ │ │ ... │ │ │ │ │ │ │ │
381
+ │ │ │ └─────────────┘ │ │ │ ▼ ▼ │ │
382
+ │ │ │ │ │ │ │ flag_builder.py ──► compilation_executor │ │
383
+ │ │ │ ▼ │ │ └─────────────────────────────────────────────┘ │
384
+ │ │ │ ┌─────────────┐ │ │ │ │
385
+ │ │ │ │ Frameworks │ │ │ ▼ │
386
+ │ │ │ │arduino_core │ │ │ ┌─────────────────────────────────────────────┐ │
387
+ │ │ │ │ .py │ │ │ │ Linking │ │
388
+ │ │ │ │ framework_ │ │ │ │ linker.py ──► archive_creator.py │ │
389
+ │ │ │ │ esp32.py │ │ │ │ │ │ │
390
+ │ │ │ │ ... │ │ │ │ ▼ │ │
391
+ │ │ │ └─────────────┘ │ │ │ configurable_linker.py │ │
392
+ │ │ │ │ │ │ │ │ │ │
393
+ │ │ │ ▼ │ │ │ ▼ │ │
394
+ │ │ │ ┌─────────────┐ │ │ │ binary_generator.py ──► firmware.hex/.bin │ │
395
+ │ │ │ │ Libraries │ │ │ └─────────────────────────────────────────────┘ │
396
+ │ │ │ │ library_ │ │ │ │
397
+ │ │ │ │ manager.py │ │ │ build_state.py (BuildStateTracker) │
398
+ │ │ │ │ │ │ │ └─────────────────────────────────────────────────┘
399
+ │ │ │ │ ▼ │ │
400
+ │ │ │ │ library_ │ │
401
+ │ │ │ │ compiler.py │ │
402
+ │ │ │ │ │ │ │
403
+ │ │ │ │ ▼ │ │
404
+ │ │ │ │github_utils │ │
405
+ │ │ │ │platformio_ │ │
406
+ │ │ │ │ registry.py │ │
407
+ │ │ │ └─────────────┘ │
408
+ └─────────────────┘ └─────────────────┘
409
+
410
+ ┌─────────────────────────────────────────────────────────────────────────────────────────┐
411
+ │ DEPLOY LAYER │
412
+ │ │
413
+ │ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ │
414
+ │ │ deployer.py │ │ deployer_esp32 │ │ monitor.py │ │ qemu_runner.py │ │
415
+ │ │ (IDeployer) │ │ .py │ │ (Serial Monitor)│ │ (Emulator) │ │
416
+ │ │ │ │ │ (esptool) │ │ │ │ │ │
417
+ │ │ ▼ │ └────────┬────────┘ └────────┬────────┘ └────────┬────────┘ │
418
+ │ │ [avrdude] │ │ │ │ │
419
+ │ └────────┬────────┘ │ │ │ │
420
+ │ └────────────────────┴────────────────────┴────────────────────┘ │
421
+ │ │ │
422
+ │ ▼ │
423
+ │ ┌──────────────────────────────┐ │
424
+ │ │ External Dependencies │ │
425
+ │ │ esptool, avrdude, pyserial │ │
426
+ │ │ Docker (QEMU) │ │
427
+ │ └──────────────────────────────┘ │
428
+ └─────────────────────────────────────────────────────────────────────────────────────────┘
429
+
430
+ ┌─────────────────────────────────────────────────────────────────────────────────────────┐
431
+ │ LEDGER LAYER │
432
+ │ ┌─────────────────────────────────┐ ┌─────────────────────────────────┐ │
433
+ │ │ ledger/board_ledger.py │ │ daemon/firmware_ledger.py │ │
434
+ │ │ (Board tracking) │ │ (Firmware tracking) │ │
435
+ │ └─────────────────────────────────┘ └─────────────────────────────────┘ │
436
+ └─────────────────────────────────────────────────────────────────────────────────────────┘
437
+ ```
438
+
439
+ **Key Data Flows:**
440
+
441
+ 1. **Build Request**: CLI → Daemon Client → Daemon Server → Build Processor → Platform Orchestrator → Compiler → Linker → firmware.hex/.bin
442
+ 2. **Deploy Request**: CLI → Daemon Client → Daemon Server → Deploy Processor → Deployer (esptool/avrdude) → Device
443
+ 3. **Package Download**: Orchestrator → Cache → Downloader → fingerprint verification → extracted packages
444
+
445
+ ### Library System Architecture
446
+
447
+ The library management system handles downloading, compiling, and linking Arduino libraries:
448
+
449
+ 1. **Library Downloading**
450
+ - Optimizes GitHub URLs to direct zip downloads
451
+ - Detects and uses appropriate branch (main/master)
452
+ - Extracts libraries with proper directory structure
453
+
454
+ 2. **Library Compilation**
455
+ - Compiles C/C++ library sources with LTO flags (`-flto -fno-fat-lto-objects`)
456
+ - Resolves include paths for Arduino library structure
457
+ - Generates LTO bytecode objects for optimal linking
458
+
459
+ 3. **Library Linking**
460
+ - Passes library object files directly to linker (no archiving)
461
+ - LTO-aware linking with `--allow-multiple-definition` for symbol resolution
462
+ - Proper handling of weak symbols and ISR handlers
463
+
464
+ **Technical Solutions**:
465
+ - **LTO Bytecode**: Generate only LTO bytecode to avoid AVR register limitations during compilation
466
+ - **Direct Object Linking**: Pass object files directly to linker instead of archiving for better LTO integration
467
+ - **Multiple Definition Handling**: Support libraries that define symbols in multiple files (e.g., FastLED ISR handlers)
468
+
469
+ ## Project Structure
470
+
471
+ ```
472
+ my-project/
473
+ ├── platformio.ini # Configuration file
474
+ ├── src/
475
+ │ ├── main.ino # Your Arduino sketch
476
+ │ └── helpers.cpp # Additional C++ files
477
+ └── .fbuild/ # Build artifacts (auto-generated)
478
+ ├── cache/
479
+ │ ├── packages/ # Downloaded toolchains
480
+ │ └── extracted/ # Arduino cores
481
+ └── build/
482
+ └── uno/
483
+ ├── src/ # Compiled sketch objects
484
+ ├── core/ # Compiled Arduino core
485
+ └── firmware.hex # Final output ← Upload this!
486
+ ```
487
+
488
+ ## Testing
489
+
490
+ Fbuild includes comprehensive integration tests:
491
+
492
+ ```bash
493
+ # Run all tests
494
+ pytest tests/
495
+
496
+ # Run integration tests only
497
+ pytest tests/integration/
498
+
499
+ # Run with verbose output
500
+ pytest -v tests/integration/
501
+
502
+ # Test results: 11/11 passing
503
+ ```
504
+
505
+ **Test Coverage**:
506
+ - Full build success path
507
+ - Incremental builds
508
+ - Clean builds
509
+ - Firmware size validation
510
+ - HEX format validation
511
+ - Error handling (missing config, syntax errors, etc.)
512
+
513
+ ## Troubleshooting
514
+
515
+ ### Build fails with "platformio.ini not found"
516
+
517
+ Make sure you're in the project directory or use `-d`:
518
+ ```bash
519
+ fbuild build -d /path/to/project
520
+ ```
521
+
522
+ ### Build fails with checksum mismatch
523
+
524
+ Clear cache and rebuild:
525
+ ```bash
526
+ rm -rf .fbuild/cache/
527
+ fbuild build
528
+ ```
529
+
530
+ ### Compiler errors in sketch
531
+
532
+ Check the error message for line numbers:
533
+ ```
534
+ Error: src/main.ino:5:1: error: expected ';' before '}' token
535
+ ```
536
+
537
+ Common issues:
538
+ - Missing semicolon
539
+ - Missing closing brace
540
+ - Undefined function (missing #include or prototype)
541
+
542
+ ### Slow builds
543
+
544
+ - First build with downloads: 15-30s (expected)
545
+ - Cached builds: 2-5s (expected)
546
+ - Incremental: <1s (expected)
547
+
548
+ If slower, check:
549
+ - Network speed (for downloads)
550
+ - Disk speed (SSD recommended)
551
+ - Use `--verbose` to see what's slow
552
+
553
+ See [docs/build-system.md](docs/build-system.md) for more troubleshooting.
554
+
555
+ ## Development
556
+
557
+ To develop Fbuild, run `. ./activate.sh`
558
+
559
+ ### Windows
560
+
561
+ This environment requires you to use `git-bash`.
562
+
563
+ ### Linting
564
+
565
+ Run `./lint.sh` to find linting errors using `pylint`, `flake8` and `mypy`.
566
+
567
+ ## License
568
+
569
+ BSD 3-Clause License