Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation
Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Build ngspice for WebAssembly
|
|
|
|
|
# ngspice provides SPICE simulation for KiCad's Eeschema
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
source "${SCRIPT_DIR}/../common/env.sh"
|
|
|
|
|
source "${SCRIPT_DIR}/../common/versions.sh"
|
|
|
|
|
source "${SCRIPT_DIR}/../common/functions.sh"
|
|
|
|
|
|
|
|
|
|
NGSPICE_DIR="${DEPS_ROOT}/ngspice-${NGSPICE_VERSION}"
|
|
|
|
|
NGSPICE_BUILD="${BUILD_ROOT}/deps/ngspice"
|
|
|
|
|
NGSPICE_STAMP="${BUILD_ROOT}/stamps/ngspice.stamp"
|
|
|
|
|
|
|
|
|
|
# Parse arguments
|
|
|
|
|
CLEAN=0
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
|
case $arg in
|
|
|
|
|
--clean)
|
|
|
|
|
CLEAN=1
|
|
|
|
|
shift
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
if [ $CLEAN -eq 1 ]; then
|
|
|
|
|
log_info "Cleaning ngspice build..."
|
|
|
|
|
rm -rf "${NGSPICE_BUILD}" "${NGSPICE_STAMP}"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Check if already built
|
|
|
|
|
if check_stamp "${NGSPICE_STAMP}"; then
|
|
|
|
|
log_info "ngspice already built, skipping..."
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Download if needed
|
|
|
|
|
if [ ! -d "${NGSPICE_DIR}" ]; then
|
|
|
|
|
log_info "Downloading ngspice ${NGSPICE_VERSION}..."
|
|
|
|
|
mkdir -p "${DEPS_ROOT}"
|
|
|
|
|
cd "${DEPS_ROOT}"
|
|
|
|
|
|
|
|
|
|
NGSPICE_URL="https://sourceforge.net/projects/ngspice/files/ng-spice-rework/${NGSPICE_VERSION}/ngspice-${NGSPICE_VERSION}.tar.gz/download"
|
|
|
|
|
curl -L "${NGSPICE_URL}" -o "ngspice-${NGSPICE_VERSION}.tar.gz"
|
|
|
|
|
tar -xzf "ngspice-${NGSPICE_VERSION}.tar.gz"
|
|
|
|
|
rm "ngspice-${NGSPICE_VERSION}.tar.gz"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
log_info "Building ngspice ${NGSPICE_VERSION} for WASM..."
|
|
|
|
|
|
|
|
|
|
mkdir -p "${NGSPICE_BUILD}"
|
|
|
|
|
cd "${NGSPICE_BUILD}"
|
|
|
|
|
|
|
|
|
|
# ngspice uses autoconf
|
2025-12-12 14:51:38 +01:00
|
|
|
# Set compiler flags based on debug mode
|
|
|
|
|
if [ "${DEBUG_BUILD:-1}" = "1" ]; then
|
|
|
|
|
export CFLAGS="-g -O0 -pthread"
|
|
|
|
|
export CXXFLAGS="-g -O0 -pthread"
|
|
|
|
|
NGSPICE_DEBUG_FLAG="--enable-debug"
|
|
|
|
|
else
|
|
|
|
|
export CFLAGS="-O2 -pthread"
|
|
|
|
|
export CXXFLAGS="-O2 -pthread"
|
|
|
|
|
NGSPICE_DEBUG_FLAG="--disable-debug"
|
|
|
|
|
fi
|
Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation
Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00
|
|
|
export LDFLAGS="-pthread"
|
|
|
|
|
|
2025-12-08 18:26:57 +01:00
|
|
|
# Configure ngspice as a static library for WASM
|
|
|
|
|
# Note: --with-ngshared requires shared libs which WASM doesn't support
|
|
|
|
|
# We build static lib instead
|
Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation
Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00
|
|
|
emconfigure "${NGSPICE_DIR}/configure" \
|
|
|
|
|
--prefix="${SYSROOT}" \
|
|
|
|
|
--host=wasm32-unknown-emscripten \
|
|
|
|
|
--build=$(uname -m)-linux-gnu \
|
2025-12-08 18:26:57 +01:00
|
|
|
--disable-shared \
|
|
|
|
|
--enable-static \
|
2025-12-12 14:51:38 +01:00
|
|
|
${NGSPICE_DEBUG_FLAG} \
|
Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation
Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00
|
|
|
--disable-dependency-tracking \
|
2025-12-08 18:26:57 +01:00
|
|
|
--disable-openmp \
|
Add KiCad WASM build infrastructure and dependency scripts
- Add build environment setup (scripts/common/env.sh, versions.sh, functions.sh)
- Add dependency build scripts for Zstd, GLM, FreeType, HarfBuzz, Pixman, Cairo
- Add placeholder scripts for OpenCASCADE, ngspice, protobuf
- Add WASM compatibility layer (wasm/kiplatform/, wasm/libcontext/)
- Add CMake modules for KiCad WASM cross-compilation
- Add PCBnew test infrastructure (tests/kicad/)
- Add build plan documentation
Successfully tested builds: Zstd 1.5.5, GLM 0.9.9.8, FreeType 2.13.2,
HarfBuzz 8.3.0, Pixman 0.42.2, Cairo 1.18.0
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 13:15:04 +01:00
|
|
|
--enable-cider \
|
|
|
|
|
--enable-xspice \
|
|
|
|
|
--without-x \
|
|
|
|
|
--without-readline \
|
|
|
|
|
--without-editline
|
|
|
|
|
|
|
|
|
|
emmake make -j${JOBS}
|
|
|
|
|
emmake make install
|
|
|
|
|
|
|
|
|
|
create_stamp "${NGSPICE_STAMP}"
|
|
|
|
|
log_info "ngspice build complete!"
|