feat(wasm): kicad_editor — merge the pcbnew+eeschema kifaces into ONE bundle (Part 2)
All four editors (PCB / Footprint / Schematic / Symbol) are now runtime --frame
choices of a single kicad_editor.wasm (178 MB at -O1 vs 147+82 separate; shared
wx/common/boost linked once). One editor per page load, as before; frames pcb /
fpedit / sch / symedit.
- wasm/editor/: the merged executable target (single_top + both kiface library sets,
whole-archive pcbcommon) + the safety-net focus-walk Kiface() dispatch TU. Gated by
KICAD_WASM_MERGED_EDITOR (kicad submodule bump carries the fork side: per-engine
Kiface/getter binding + ODR renames + dual-kiface launcher).
- wasm/bindings/: per-editor collab entries renamed pcbCollab*/schCollab* (JS names
unchanged); duplicate kicadOpenFile/kicadCollabOnSave + shared-name registrations
guarded behind KICAD_MERGED_EMBIND; new kicad_editor_embind.cpp registers each
shared JS name once, dispatching on the live frame.
- Build: kicad_editor app (build wrapper, target case arms, 3-object embind compile
with the ABI-critical flags, STUB_APP=pcbnew); docker/build.sh "all" =
kicad_editor calculator pl_editor gerbview (pcbnew/eeschema stay as explicit debug
apps); scripts/kicad/audit-merged-symbols.sh = repeatable ODR-collision audit (run
on kicad bumps).
- Frontend: Bundle type (bundle ≠ tool); TOOL_BUNDLE maps all four editors to
kicad_editor; explicit --frame tokens for pcbnew (pcb) and eeschema (sch); publish
list = the 4 real bundles.
- Tests/CI: five harnesses load kicad_editor.js with explicit frame tokens;
PCBNEW_FAMILY_SPECS renamed BIG_MODULE_SPECS + the 8 eeschema-family specs (they
now boot the merged module — SpiderMonkey x86 CI OOM routing); frame-runtime spec
covers all four frames from the one bundle.
Validated so far: frame-runtime 4/4 (each frame boots with the right title, no
aborts, no duplicate embind registration); 24-spec merged-module regression green;
3D raytracer renders. Known pre-existing failure: 3d-viewer title-bar drag deadlock,
fixed on main by 7630c7e (2N+8 pthread pre-warm) — picked up by the follow-up rebase.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c6716e6b60
commit
bbeef6d20e
23 changed files with 691 additions and 149 deletions
|
|
@ -8,6 +8,7 @@ import {
|
|||
TOOL_BUNDLE,
|
||||
TOOL_LIB_KIND,
|
||||
TOOL_NEEDS_CONFIG_SEED,
|
||||
type Bundle,
|
||||
} from "./constants";
|
||||
import { installModel3dHandler } from "./libs/models-bridge";
|
||||
import type { Model3dSource } from "./libs/models-source";
|
||||
|
|
@ -125,10 +126,10 @@ function loadScript(src: string): Promise<void> {
|
|||
*/
|
||||
function pthreadWorkerScript(
|
||||
base: string,
|
||||
tool: Tool,
|
||||
bundle: Bundle,
|
||||
traceMask?: string | null,
|
||||
): string | Blob {
|
||||
const abs = new URL(`${base}/${tool}.js`, window.location.href);
|
||||
const abs = new URL(`${base}/${bundle}.js`, window.location.href);
|
||||
// ?trace=<mask>: seed `self.__KICAD_TRACE__` in EVERY pthread worker's scope
|
||||
// before it importScripts the glue. With PROXY_TO_PTHREAD the C main()/UI (and
|
||||
// thus TRACE_MANAGER) run on a pthread, so the trace env must be set in the
|
||||
|
|
@ -143,7 +144,7 @@ function pthreadWorkerScript(
|
|||
{ type: "text/javascript" },
|
||||
);
|
||||
}
|
||||
if (abs.origin === window.location.origin) return `${base}/${tool}.js`;
|
||||
if (abs.origin === window.location.origin) return `${base}/${bundle}.js`;
|
||||
return new Blob([`importScripts(${JSON.stringify(abs.href)});`], {
|
||||
type: "text/javascript",
|
||||
});
|
||||
|
|
@ -204,7 +205,7 @@ async function doBoot(opts: BootOptions): Promise<void> {
|
|||
// The deployed bundle backing this tool. footprint_editor/symbol_editor share
|
||||
// the pcbnew/eeschema engine, so their `.wasm`/`.js`/pthread-worker files are the
|
||||
// parent's; `tool` still drives identity (thisProgram), config-seed and lib-kind.
|
||||
const bundle = TOOL_BUNDLE[tool] ?? tool;
|
||||
const bundle = TOOL_BUNDLE[tool];
|
||||
const w = window as ToolWindow;
|
||||
|
||||
// The wasm reads the top-level frame geometry from a GLOBAL `mainWindow`
|
||||
|
|
|
|||
|
|
@ -35,20 +35,32 @@ export const TOOL_ARGV0: Record<Tool, string> = {
|
|||
};
|
||||
|
||||
/**
|
||||
* Which deployed WASM bundle actually backs each tool. `footprint_editor` and
|
||||
* `symbol_editor` are the SAME compiled engine as `pcbnew` / `eeschema` — they
|
||||
* were only ever a second launcher pinned to a different build-time frame — so
|
||||
* after editor-unification they load the parent bundle and select their frame at
|
||||
* runtime (see `TOOL_FRAME`). Every other tool backs its own bundle. Used to
|
||||
* resolve the CDN asset folder and the `<bundle>.{wasm,js}` filenames.
|
||||
* A deployed WASM bundle (CDN folder + `<bundle>.{wasm,js}` basenames). NOT the same
|
||||
* space as `Tool`: since editor-unification Part 2 the four editor TOOLS (pcbnew,
|
||||
* eeschema, footprint_editor, symbol_editor) are all served by the ONE merged
|
||||
* `kicad_editor` bundle — two engines (kifaces) statically linked, the frame chosen
|
||||
* at runtime (`TOOL_FRAME`). Deliberately not part of the `TOOLS` enum: a bundle is
|
||||
* a delivery artifact, not a user-facing tool/route.
|
||||
*/
|
||||
export const TOOL_BUNDLE: Record<Tool, Tool> = {
|
||||
pcbnew: "pcbnew",
|
||||
eeschema: "eeschema",
|
||||
export type Bundle =
|
||||
| "kicad_editor"
|
||||
| "calculator"
|
||||
| "pl_editor"
|
||||
| "gerbview";
|
||||
|
||||
/**
|
||||
* Which deployed WASM bundle actually backs each tool. The four editors share the
|
||||
* merged `kicad_editor` engine image (editor-unification Part 2); the remaining
|
||||
* tools are genuinely separate engines and back their own bundles. Used to resolve
|
||||
* the CDN asset folder and the `<bundle>.{wasm,js}` filenames.
|
||||
*/
|
||||
export const TOOL_BUNDLE: Record<Tool, Bundle> = {
|
||||
pcbnew: "kicad_editor",
|
||||
eeschema: "kicad_editor",
|
||||
calculator: "calculator",
|
||||
pl_editor: "pl_editor",
|
||||
symbol_editor: "eeschema",
|
||||
footprint_editor: "pcbnew",
|
||||
symbol_editor: "kicad_editor",
|
||||
footprint_editor: "kicad_editor",
|
||||
gerbview: "gerbview",
|
||||
};
|
||||
|
||||
|
|
@ -58,10 +70,13 @@ export const TOOL_BUNDLE: Record<Tool, Tool> = {
|
|||
* opens a specific editor frame. Tools whose bundle already defaults to the right
|
||||
* frame need no token (`undefined`). Tokens mirror `kicad/kicad.cpp`'s `--frame`
|
||||
* parser, plus `symedit` for the symbol editor (which upstream's CLI lacks).
|
||||
* The merged bundle's build-time default is the PCB editor, so every editor tool
|
||||
* passes its token explicitly (pcbnew included — cheap insurance over relying on
|
||||
* the default).
|
||||
*/
|
||||
export const TOOL_FRAME: Record<Tool, string | undefined> = {
|
||||
pcbnew: undefined,
|
||||
eeschema: undefined,
|
||||
pcbnew: "pcb",
|
||||
eeschema: "sch",
|
||||
calculator: undefined,
|
||||
pl_editor: undefined,
|
||||
symbol_editor: "symedit",
|
||||
|
|
|
|||
|
|
@ -43,10 +43,10 @@ export async function resolveWasmBase(
|
|||
): Promise<string> {
|
||||
if (override) return override.replace(/\/+$/, "");
|
||||
if (!WASM_MANIFEST_FILE) return WASM_ROOT; // flat (dev / same-origin)
|
||||
// A tool may be served by a shared bundle (footprint_editor→pcbnew,
|
||||
// symbol_editor→eeschema); resolve the folder/version of the bundle, not the
|
||||
// logical tool (the merged bundles are the only ones published).
|
||||
const bundle = TOOL_BUNDLE[tool] ?? tool;
|
||||
// A tool may be served by a shared bundle (all four editors → kicad_editor);
|
||||
// resolve the folder/version of the bundle, not the logical tool (bundles are
|
||||
// the only thing published/listed in the manifest).
|
||||
const bundle = TOOL_BUNDLE[tool];
|
||||
const manifest = await loadManifest();
|
||||
const ver = manifest.tools?.[bundle];
|
||||
if (!ver) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue