- 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>
111 lines
2.7 KiB
Shell
Executable file
111 lines
2.7 KiB
Shell
Executable file
#!/bin/bash
|
|
# Build Cairo for WebAssembly
|
|
# Cairo provides 2D graphics rendering
|
|
|
|
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"
|
|
|
|
# Cairo requires Pixman and FreeType
|
|
"${SCRIPT_DIR}/build-pixman.sh"
|
|
"${SCRIPT_DIR}/build-freetype.sh"
|
|
|
|
CAIRO_DIR="${DEPS_ROOT}/cairo-${CAIRO_VERSION}"
|
|
CAIRO_BUILD="${BUILD_ROOT}/deps/cairo"
|
|
CAIRO_STAMP="${BUILD_ROOT}/stamps/cairo.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 Cairo build..."
|
|
rm -rf "${CAIRO_BUILD}" "${CAIRO_STAMP}"
|
|
fi
|
|
|
|
# Check if already built
|
|
if check_stamp "${CAIRO_STAMP}"; then
|
|
log_info "Cairo already built, skipping..."
|
|
exit 0
|
|
fi
|
|
|
|
# Download if needed
|
|
if [ ! -d "${CAIRO_DIR}" ]; then
|
|
log_info "Downloading Cairo ${CAIRO_VERSION}..."
|
|
mkdir -p "${DEPS_ROOT}"
|
|
cd "${DEPS_ROOT}"
|
|
|
|
CAIRO_URL="https://cairographics.org/releases/cairo-${CAIRO_VERSION}.tar.xz"
|
|
download_file "${CAIRO_URL}" "cairo-${CAIRO_VERSION}.tar.xz"
|
|
tar -xJf "cairo-${CAIRO_VERSION}.tar.xz"
|
|
rm "cairo-${CAIRO_VERSION}.tar.xz"
|
|
fi
|
|
|
|
log_info "Building Cairo ${CAIRO_VERSION} for WASM..."
|
|
|
|
mkdir -p "${CAIRO_BUILD}"
|
|
cd "${CAIRO_BUILD}"
|
|
|
|
# Cairo uses meson
|
|
cat > cross-file.txt << EOF
|
|
[binaries]
|
|
c = 'emcc'
|
|
cpp = 'em++'
|
|
ar = 'emar'
|
|
ranlib = 'emranlib'
|
|
strip = 'emstrip'
|
|
pkgconfig = 'pkg-config'
|
|
|
|
[host_machine]
|
|
system = 'emscripten'
|
|
cpu_family = 'wasm32'
|
|
cpu = 'wasm32'
|
|
endian = 'little'
|
|
|
|
[properties]
|
|
# Prevent finding system libraries when cross-compiling
|
|
sys_root = '${SYSROOT}'
|
|
pkg_config_libdir = '${SYSROOT}/lib/pkgconfig'
|
|
|
|
[built-in options]
|
|
c_args = ['-pthread', '-I${SYSROOT}/include', '-I${SYSROOT}/include/freetype2', '-I${SYSROOT}/include/pixman-1']
|
|
c_link_args = ['-pthread', '-L${SYSROOT}/lib']
|
|
pkg_config_path = '${SYSROOT}/lib/pkgconfig'
|
|
EOF
|
|
|
|
# Set PKG_CONFIG_PATH for dependency discovery
|
|
# Use LIBDIR to ONLY search our sysroot, preventing system lzo2 from being found
|
|
export PKG_CONFIG_LIBDIR="${SYSROOT}/lib/pkgconfig"
|
|
unset PKG_CONFIG_PATH
|
|
|
|
meson setup "${CAIRO_DIR}" \
|
|
--cross-file cross-file.txt \
|
|
--prefix="${SYSROOT}" \
|
|
--default-library=static \
|
|
-Dfontconfig=disabled \
|
|
-Dfreetype=enabled \
|
|
-Dglib=disabled \
|
|
-Dpng=disabled \
|
|
-Dxlib=disabled \
|
|
-Dxcb=disabled \
|
|
-Dzlib=enabled \
|
|
-Dtests=disabled \
|
|
-Dspectre=disabled \
|
|
-Dsymbol-lookup=disabled
|
|
|
|
JOBS=${JOBS:-$(sysctl -n hw.ncpu 2>/dev/null || nproc 2>/dev/null || echo 4)}
|
|
ninja -j${JOBS}
|
|
ninja install
|
|
|
|
create_stamp "${CAIRO_STAMP}"
|
|
log_info "Cairo build complete!"
|