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:
parent
3034d9d76f
commit
c408410c7d
14 changed files with 647 additions and 112 deletions
92
scripts/deps/build-boost.sh
Executable file
92
scripts/deps/build-boost.sh
Executable 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!"
|
||||
59
scripts/deps/build-curl-headers.sh
Executable file
59
scripts/deps/build-curl-headers.sh
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/bash
|
||||
# Download CURL headers for WebAssembly builds
|
||||
# We only need the headers - CURL functions will be stubbed for WASM
|
||||
# since networking uses browser fetch API, not native sockets
|
||||
|
||||
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"
|
||||
|
||||
CURL_VERSION="${CURL_VERSION:-8.5.0}"
|
||||
CURL_DIR="${DEPS_ROOT}/curl-${CURL_VERSION}"
|
||||
CURL_STAMP="${BUILD_ROOT}/stamps/curl-headers.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 CURL headers..."
|
||||
rm -rf "${CURL_DIR}" "${CURL_STAMP}"
|
||||
rm -rf "${SYSROOT}/include/curl"
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if check_stamp "${CURL_STAMP}"; then
|
||||
log_info "CURL headers already installed, skipping..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Download if needed
|
||||
if [ ! -d "${CURL_DIR}" ]; then
|
||||
log_info "Downloading CURL ${CURL_VERSION} headers..."
|
||||
mkdir -p "${DEPS_ROOT}"
|
||||
cd "${DEPS_ROOT}"
|
||||
|
||||
# Download from curl official releases
|
||||
CURL_URL="https://curl.se/download/curl-${CURL_VERSION}.tar.gz"
|
||||
download_file "${CURL_URL}" "curl-${CURL_VERSION}.tar.gz"
|
||||
tar -xzf "curl-${CURL_VERSION}.tar.gz"
|
||||
rm "curl-${CURL_VERSION}.tar.gz"
|
||||
fi
|
||||
|
||||
# Install headers only (no build needed - header-only for WASM stub)
|
||||
log_info "Installing CURL headers to sysroot..."
|
||||
mkdir -p "${SYSROOT}/include/curl"
|
||||
cp "${CURL_DIR}/include/curl/"*.h "${SYSROOT}/include/curl/"
|
||||
|
||||
create_stamp "${CURL_STAMP}"
|
||||
log_info "CURL headers installed!"
|
||||
58
scripts/deps/build-libgit2-headers.sh
Executable file
58
scripts/deps/build-libgit2-headers.sh
Executable file
|
|
@ -0,0 +1,58 @@
|
|||
#!/bin/bash
|
||||
# Download libgit2 headers for WebAssembly builds
|
||||
# We only need the headers - git functionality won't work in browser
|
||||
|
||||
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"
|
||||
|
||||
LIBGIT2_VERSION="${LIBGIT2_VERSION:-1.7.1}"
|
||||
LIBGIT2_DIR="${DEPS_ROOT}/libgit2-${LIBGIT2_VERSION}"
|
||||
LIBGIT2_STAMP="${BUILD_ROOT}/stamps/libgit2-headers.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 libgit2 headers..."
|
||||
rm -rf "${LIBGIT2_DIR}" "${LIBGIT2_STAMP}"
|
||||
rm -rf "${SYSROOT}/include/git2.h" "${SYSROOT}/include/git2"
|
||||
fi
|
||||
|
||||
# Check if already installed
|
||||
if check_stamp "${LIBGIT2_STAMP}"; then
|
||||
log_info "libgit2 headers already installed, skipping..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Download if needed
|
||||
if [ ! -d "${LIBGIT2_DIR}" ]; then
|
||||
log_info "Downloading libgit2 ${LIBGIT2_VERSION} headers..."
|
||||
mkdir -p "${DEPS_ROOT}"
|
||||
cd "${DEPS_ROOT}"
|
||||
|
||||
LIBGIT2_URL="https://github.com/libgit2/libgit2/archive/refs/tags/v${LIBGIT2_VERSION}.tar.gz"
|
||||
download_file "${LIBGIT2_URL}" "libgit2-${LIBGIT2_VERSION}.tar.gz"
|
||||
tar -xzf "libgit2-${LIBGIT2_VERSION}.tar.gz"
|
||||
rm "libgit2-${LIBGIT2_VERSION}.tar.gz"
|
||||
fi
|
||||
|
||||
# Install headers only
|
||||
log_info "Installing libgit2 headers to sysroot..."
|
||||
mkdir -p "${SYSROOT}/include/git2/sys"
|
||||
cp "${LIBGIT2_DIR}/include/git2.h" "${SYSROOT}/include/"
|
||||
cp -r "${LIBGIT2_DIR}/include/git2/"* "${SYSROOT}/include/git2/"
|
||||
|
||||
create_stamp "${LIBGIT2_STAMP}"
|
||||
log_info "libgit2 headers installed!"
|
||||
|
|
@ -45,7 +45,8 @@ if [ ! -d "${OCC_DIR}" ]; then
|
|||
OCC_URL="https://github.com/Open-Cascade-SAS/OCCT/archive/refs/tags/V${OCC_VERSION//./_}.tar.gz"
|
||||
download_file "${OCC_URL}" "opencascade-${OCC_VERSION}.tar.gz"
|
||||
tar -xzf "opencascade-${OCC_VERSION}.tar.gz"
|
||||
mv "OCCT-V${OCC_VERSION//./_}" "opencascade-${OCC_VERSION}"
|
||||
# Directory name in tarball is OCCT-7_8_0 (without V prefix)
|
||||
mv "OCCT-${OCC_VERSION//./_}" "opencascade-${OCC_VERSION}"
|
||||
rm "opencascade-${OCC_VERSION}.tar.gz"
|
||||
fi
|
||||
|
||||
|
|
@ -59,6 +60,7 @@ cd "${OCC_BUILD}"
|
|||
# Disable GUI, visualization that needs X11/OpenGL native
|
||||
# Enable core geometry and data exchange modules only
|
||||
emcmake cmake "${OCC_DIR}" \
|
||||
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_INSTALL_PREFIX="${SYSROOT}" \
|
||||
-DCMAKE_CXX_FLAGS="-pthread -O2" \
|
||||
|
|
|
|||
|
|
@ -41,7 +41,9 @@ if [ ! -d "${PROTOBUF_DIR}" ]; then
|
|||
mkdir -p "${DEPS_ROOT}"
|
||||
cd "${DEPS_ROOT}"
|
||||
|
||||
PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz"
|
||||
# Protobuf 3.21.x uses tag format v21.12 (major version 3 is implicit)
|
||||
PROTOBUF_TAG_VERSION="${PROTOBUF_VERSION#3.}" # Strip leading "3." -> "21.12"
|
||||
PROTOBUF_URL="https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOBUF_TAG_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz"
|
||||
download_file "${PROTOBUF_URL}" "protobuf-${PROTOBUF_VERSION}.tar.gz"
|
||||
tar -xzf "protobuf-${PROTOBUF_VERSION}.tar.gz"
|
||||
rm "protobuf-${PROTOBUF_VERSION}.tar.gz"
|
||||
|
|
|
|||
Loading…
Reference in a new issue