| Filename | Latest commit message | Latest commit date |
|---|---|---|
Add the two newly WASM-ported editors to the web app the same way as the existing tools: - pl_editor (drawing-sheet, .kicad_wks): PL_EDITOR_FRAME overrides OpenProjectFiles, so it gets the generic kicadOpenFile embind hook (wasm/bindings/pl_editor_embind.cpp) for deterministic open. Mapped .kicad_wks -> pl_editor in EXTENSION_TOOL. - symbol_editor (symbol library): SYMBOL_EDIT_FRAME does NOT override OpenProjectFiles, so it's treated as file-less (boot standalone, opens libraries via its own UI). Added to FILELESS_TOOLS. Both boot through single_top.cpp's STARTWIZARD, so both seed config to skip the first-run wizard (TOOL_NEEDS_CONFIG_SEED) and get a /usr/bin/<binary> argv0. contract: add to TOOLS, plus a TOOL_LABELS map for friendly names. The project UI now renders file-less launch links generically from FILELESS_TOOLS and per-file "Open in <label>" links from EXTENSION_TOOL (auto file-type detection), so adding a tool needs no UI edits. Verified in-browser: pl_editor opens a .kicad_wks (renders the sheet), symbol_editor boots wizard-free; both with 0 console errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> |
||
| .. | ||
| bindings | ||
| cmake | ||
| kiplatform | ||
| libcontext | ||
| shims | ||
| stubs | ||
| CMakeLists.txt | ||
| README.md | ||
WASM Compatibility Layer
This directory contains WASM-specific implementations that allow KiCad to run in a web browser without modifying KiCad's source code.
Principle
Instead of patching KiCad source files, we:
- Override include paths to use our headers first
- Provide alternative implementations for platform-specific code
- Link our libraries instead of system libraries
Directory Structure
wasm/
├── CMakeLists.txt # Master CMake for compatibility layer
├── README.md # This file
├── kiplatform/ # Platform abstraction implementations
│ ├── CMakeLists.txt
│ ├── app.cpp # App lifecycle (paths, startup)
│ ├── drivers.cpp # GPU detection (returns "WebGL")
│ ├── environment.cpp # Environment variables (localStorage)
│ ├── io.cpp # File I/O (WASM virtual filesystem)
│ ├── policy.cpp # Security policy (always permissive)
│ ├── secrets.cpp # Credential storage (localStorage)
│ ├── sysinfo.cpp # System information
│ └── printing.cpp # Print support (browser print())
├── libcontext/ # Coroutine/fiber implementation
│ ├── CMakeLists.txt
│ └── fcontext_wasm.cpp # Emscripten Asyncify fibers
├── shims/ # Header overrides
│ └── *.h # Headers that redirect to our impls
└── config/ # Build configuration
├── kicad_wasm_config.h # Version and feature config
└── setup.h # Platform setup
How It Works
Include Path Override
When building KiCad for WASM, we add our directories first in the include path:
-I$PROJECT_ROOT/wasm/shims
-I$PROJECT_ROOT/wasm/kiplatform
-I$PROJECT_ROOT/stubs/include
This means when KiCad includes <kiplatform/app.h>, it finds our version first.
Library Override
We build libkiplatform_wasm.a and link it instead of the native kiplatform:
-L$BUILD_ROOT/wasm -lkiplatform_wasm
CMake Integration
The main KiCad build is configured to find our implementations:
-DCMAKE_MODULE_PATH="$PROJECT_ROOT/cmake"
-DKIPLATFORM_LIBRARY="$BUILD_ROOT/wasm/libkiplatform_wasm.a"
Adding New Implementations
- Create the implementation file in the appropriate directory
- Add it to the CMakeLists.txt
- Ensure the header interface matches KiCad's expected interface
- Test with a minimal build before full integration