eeschema simulator: lazy ngspice_service worker — static sharedspice (XSPICE registry + CIDER), init_dll ifdef, e2e both engines

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2026-07-19 15:59:21 +02:00
commit 703cb010b7
30 changed files with 2872 additions and 82 deletions

View file

@ -235,7 +235,9 @@ else
fi
# Step 2: Build dependencies
# Note: --with-occ for OpenCASCADE, but NOT ngspice since KICAD_SPICE=OFF
# Note: --with-occ for OpenCASCADE. The ngspice dep is NOT needed here — the
# editor links only the sharedspice client stub; the engine is the separate
# ngspice_service app (scripts/kicad/build-ngspice_service.sh builds its dep).
if [ $SKIP_DEPS -eq 0 ]; then
kw_stage deps
log_info "Building dependencies..."
@ -547,7 +549,6 @@ emcmake cmake "${KICAD_DIR}" \
-DwxWidgets_CONFIG_EXECUTABLE="${WX_BUILD}/wx-config" \
\
-DKICAD_BUILD_QA_TESTS=OFF \
-DKICAD_SPICE=OFF \
-DKICAD_USE_EGL=OFF \
-DKICAD_USE_BUNDLED_GLEW=ON \
-DKICAD_BUILD_3D_VIEWER_WASM=${BUILD_3D_VIEWER} \

View file

@ -0,0 +1,60 @@
#!/bin/bash
# Build ngspice_service.{js,wasm} — the eeschema simulator's ngspice worker
# module (wasm/ngspice-service/). Unlike occ_service this does NOT go through
# the kicad CMake tree: the module contains no KiCad/wx code, so it configures
# standalone against the sysroot ngspice artifacts (much faster to iterate,
# and buildable without the full editor dependency set).
#
# Artifacts: ${BUILD_ROOT}/kicad-ngspice_service/ngspice_service/ngspice_service.{js,wasm}
# — the kicad-<app>/<subdir>/ layout every other app uses, so docker/build.sh's
# output copy and tests/scripts/setup-kicad-wasm.sh's docker-volume fallback
# find them without special-casing.
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/../common/env.sh"
# Parse arguments
CLEAN=0
for arg in "$@"; do
case $arg in
--clean)
CLEAN=1
shift
;;
esac
done
NGSPICE_SERVICE_BUILD="${BUILD_ROOT}/kicad-ngspice_service"
if [ $CLEAN -eq 1 ]; then
log_info "Cleaning ngspice_service build..."
rm -rf "${NGSPICE_SERVICE_BUILD}"
fi
# The ngspice dep (sharedspice static lib + code-model archives + spinit) is
# stamped, so this is a no-op when already built.
"${SCRIPT_DIR}/../deps/build-ngspice.sh"
log_info "Building ngspice_service..."
mkdir -p "${NGSPICE_SERVICE_BUILD}"
cd "${NGSPICE_SERVICE_BUILD}"
emcmake cmake "${WASM_COMPAT}/ngspice-service" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY="${NGSPICE_SERVICE_BUILD}/ngspice_service" \
-DNGSPICE_SYSROOT="${SYSROOT}" \
-DNGSPICE_EH_FLAGS="${DEPS_EH_FLAGS}"
emmake make -j${JOBS}
for f in ngspice_service.js ngspice_service.wasm; do
if [ ! -f "${NGSPICE_SERVICE_BUILD}/ngspice_service/$f" ]; then
log_error "ngspice_service build incomplete: missing $f"
exit 1
fi
done
log_info "ngspice_service build complete: ${NGSPICE_SERVICE_BUILD}/ngspice_service/ngspice_service.{js,wasm}"