Add KiCad PCBnew build script and CMake Find modules

- Add scripts/kicad/build-pcbnew.sh with clean-by-default and --no-clean flag
- Remove old scripts/build-pcbnew-wasm.sh (moved to scripts/kicad/)
- Add Boost build script with Emscripten toolset for Boost.Locale
- Add header download scripts for CURL and libgit2 (stub libraries)
- Add CMake Find modules for cross-compilation compatibility:
  - FindGLM.cmake: Reads version from setup.hpp
  - FindZSTD.cmake: Explicit sysroot paths
  - FindCURL.cmake: Header-only stub
  - FindSPNAV.cmake: Disabled (3D mouse not needed in browser)
  - FindCairo.cmake: Finds our built Cairo
  - FindPixman.cmake: Finds our built Pixman
  - Findlibgit2.cmake: Header-only stub
- Fix OpenCASCADE build: correct extracted dir name, add CMake policy
- Fix Protobuf build: correct GitHub release tag format (v21.12 not v3.21.12)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Viktor Vaczi 2025-12-08 11:37:14 +01:00
commit c408410c7d
14 changed files with 647 additions and 112 deletions

92
scripts/deps/build-boost.sh Executable file
View file

@ -0,0 +1,92 @@
#!/bin/bash
# Build Boost for WebAssembly
# KiCad requires Boost with the locale component
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"
BOOST_VERSION="${BOOST_VERSION:-1.84.0}"
BOOST_VERSION_UNDERSCORE="${BOOST_VERSION//./_}"
BOOST_DIR="${DEPS_ROOT}/boost_${BOOST_VERSION_UNDERSCORE}"
BOOST_BUILD="${BUILD_ROOT}/deps/boost"
BOOST_STAMP="${BUILD_ROOT}/stamps/boost.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 Boost build..."
rm -rf "${BOOST_BUILD}" "${BOOST_STAMP}"
fi
# Check if already built
if check_stamp "${BOOST_STAMP}"; then
log_info "Boost already built, skipping..."
exit 0
fi
# Download if needed
if [ ! -d "${BOOST_DIR}" ]; then
log_info "Downloading Boost ${BOOST_VERSION}..."
mkdir -p "${DEPS_ROOT}"
cd "${DEPS_ROOT}"
# Use SourceForge mirror (most reliable for Boost downloads)
BOOST_URL="https://sourceforge.net/projects/boost/files/boost/${BOOST_VERSION}/boost_${BOOST_VERSION_UNDERSCORE}.tar.gz/download"
BOOST_ARCHIVE="boost_${BOOST_VERSION_UNDERSCORE}.tar.gz"
# Download and extract
download_file "${BOOST_URL}" "${BOOST_ARCHIVE}"
tar -xzf "${BOOST_ARCHIVE}"
rm "${BOOST_ARCHIVE}"
fi
log_info "Building Boost ${BOOST_VERSION} for WASM..."
cd "${BOOST_DIR}"
# Bootstrap b2 if needed
if [ ! -f "b2" ]; then
log_info "Bootstrapping b2..."
./bootstrap.sh --with-toolset=clang
fi
# Create user-config.jam for Emscripten
cat > user-config.jam << 'EOF'
using clang : emscripten
: em++
: <cxxflags>"-pthread"
<linkflags>"-pthread"
;
EOF
# Build only the locale library (and its dependencies)
# Most of Boost is header-only, we just need locale built
log_info "Building Boost.Locale..."
JOBS=${JOBS:-$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)}
./b2 -j${JOBS} \
--user-config=user-config.jam \
--prefix="${SYSROOT}" \
--with-locale \
toolset=clang-emscripten \
variant=release \
link=static \
threading=multi \
runtime-link=static \
cxxflags="-pthread" \
install
create_stamp "${BOOST_STAMP}"
log_info "Boost build complete!"