4.2 KiB
Symbol Editor WASM port — design notes
Goal
Bring up KiCad's Symbol Editor (FRAME_SCH_SYMBOL_EDITOR, the .kicad_sym
library editor) in the browser, to the same "boots, canvas visible, click
around" level as the other ported apps. Scope is launch-only — library
load/save and the symbol viewer/chooser sub-frames are out of scope for now.
Key insight
Unlike pcbnew / pl_editor, the symbol editor is not a separate program. It is
served by the eeschema kiface: its sources already compile into
eeschema_kiface_objects (EESCHEMA_LIBEDIT_SRCS + the symbol_editor_* tools in
kicad/eeschema/CMakeLists.txt). KiCad's universal launcher common/single_top.cpp
opens whichever frame the compile-time TOP_FRAME macro names.
So the port is just a second launcher executable (symbol_editor) that links the
same eeschema kiface but compiles single_top.cpp with
TOP_FRAME=FRAME_SCH_SYMBOL_EDITOR — no new sources, no new kiface, no extracting
symbol-editor code. The eeschema kiface (deps, navlib, stubs, libraries) is reused
verbatim.
Changes
kicad submodule (2 files)
-
kicad/eeschema/CMakeLists.txt— a WASM-only (if( EMSCRIPTEN )) block adds thesymbol_editorexecutable. Becausesingle_top.cpp'sCOMPILE_DEFINITIONSare directory-scoped (already pinned toTOP_FRAME=FRAME_SCHfor theeeschemaexe), weconfigure_file-copy it to a private TU (symbol_editor_single_top.cpp) and set that copy'sTOP_FRAME=FRAME_SCH_SYMBOL_EDITOR;PGM_DATA_FILE_EXT="kicad_sym". The exe linksEESCHEMA_KIFACE_LIBRARIESdirectly withLINKER:--allow-multiple-definition, mirroring the eeschema/pcbnew static-link pattern. -
kicad/eeschema/eeschema.cpp—IFACE::CreateKiWindow'sFRAME_SCH_SYMBOL_EDITORcase was stubbed toreturn nullptron__EMSCRIPTEN__during the eeschema MVP (see../schematic/0001-eeschema-iface-stubs.md). That stub is now removed so the frame is constructed in WASM like the native build. This was THE blocker: with the stub,Kiway.Player(FRAME_SCH_SYMBOL_EDITOR)returned null,single_top'sOnInitbailed, and the app sat idle with a blank canvas (no abort, no error).The symbol viewer (
FRAME_SCH_VIEWER) and chooser (FRAME_SYMBOL_CHOOSER) remain stubbed — out of scope, and the chooser needs bundled libraries we don't ship.
Root repo
scripts/kicad/build-symbol_editor.sh— thin wrapper aroundbuild-kicad-target.sh symbol_editor.scripts/kicad/build-kicad-target.sh— addssymbol_editorto thecase. CMake target issymbol_editorbut its build subdir iseeschema(it's part of that kiface), so aKICAD_SUBDIRvariable now distinguishes target name from subdir for the output-path log and embind include.docker/build.sh— addssymbol_editorto valid apps, theallloop, andkicad_subdir_for(symbol_editor → eeschema); artifacts land atbuild-wasm/kicad-symbol_editor/eeschema/symbol_editor.{js,wasm}.tests/apps/kicad/symbol_editor.html— browser shell (copy of eeschema.html with title +thisProgram=/usr/bin/symbol_editor+symbol_editor.js).tests/scripts/setup-kicad-wasm.sh—copy_app symbol_editor+ subdir map entry.tests/kicad/symbol_editor.spec.ts+tests/package.json— launch-scope smoke test (canvas visible, registry populated, toolbars present, no WASM abort), mirroring eeschema's wizard-aware flow.
wxwidgets submodule
No changes needed — the file-dialog and double-click fixes landed with the pl_editor port.
Build & verify
./docker/build.sh symbol_editor
cd tests && npm run setup:kicad && npm run test:symbol_editor
# or serve tests/apps/kicad and open symbol_editor.html
Expect: the symbol editor window opens — menu bar, top + left + right toolbars (incl. pin/rect/circle/line drawing tools), the symbol library tree pane with the filter box, the gridded canvas with the symbol-origin crosshair, and a status bar.
Known limitations
- No bundled symbol libraries, so the library tree is empty (
SyncLibrariesreportslibCount=0). Opening/creating/saving.kicad_symfiles is untested (out of scope). - Symbol viewer and symbol chooser frames are still stubbed out for WASM.
- No persistent storage (MEMFS only).