pcbjam/scripts/deps/build-pixman.sh
Viktor Vaczi d8d934ffca Enable exceptions and pthreads atomics for KiCad WASM build
Build fixes:
- Enable C++ exceptions in wxWidgets (--enable-exceptions, -fexceptions)
  Required for KiCad's OnExceptionInMainLoop override in debug builds
- Add -matomics -mbulk-memory to all dependency builds for shared memory
  Required for pthreads support with Emscripten
- Fix docker/build.sh output copy path (pcbnew/ not bin/)
- Make workspace mount read-only in docker-compose.yml

Updated dependency scripts:
- build-freetype.sh, build-harfbuzz.sh, build-protobuf.sh
- build-zstd.sh, build-opencascade.sh, build-boost.sh
- build-pixman.sh, build-cairo.sh (meson cross-file)
- build-wxuniversal-wasm.sh, build-pcbnew.sh

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-13 11:29:45 +01:00

98 lines
2.3 KiB
Shell
Executable file

#!/bin/bash
# Build Pixman for WebAssembly
# Pixman is required by Cairo for pixel manipulation
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"
PIXMAN_DIR="${DEPS_ROOT}/pixman-${PIXMAN_VERSION}"
PIXMAN_BUILD="${BUILD_ROOT}/deps/pixman"
PIXMAN_STAMP="${BUILD_ROOT}/stamps/pixman.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 Pixman build..."
rm -rf "${PIXMAN_BUILD}" "${PIXMAN_STAMP}"
fi
# Check if already built
if check_stamp "${PIXMAN_STAMP}"; then
log_info "Pixman already built, skipping..."
exit 0
fi
# Download if needed
if [ ! -d "${PIXMAN_DIR}" ]; then
log_info "Downloading Pixman ${PIXMAN_VERSION}..."
mkdir -p "${DEPS_ROOT}"
cd "${DEPS_ROOT}"
PIXMAN_URL="https://cairographics.org/releases/pixman-${PIXMAN_VERSION}.tar.gz"
download_file "${PIXMAN_URL}" "pixman-${PIXMAN_VERSION}.tar.gz"
tar -xzf "pixman-${PIXMAN_VERSION}.tar.gz"
rm "pixman-${PIXMAN_VERSION}.tar.gz"
fi
log_info "Building Pixman ${PIXMAN_VERSION} for WASM..."
mkdir -p "${PIXMAN_BUILD}"
cd "${PIXMAN_BUILD}"
# Determine meson build type based on DEBUG_BUILD
if [ "${DEBUG_BUILD:-1}" = "1" ]; then
MESON_BUILD_TYPE="debug"
MESON_DEBUG_FLAGS="'-g', '-O0'"
else
MESON_BUILD_TYPE="release"
MESON_DEBUG_FLAGS="'-O2'"
fi
# Pixman uses meson
cat > cross-file.txt << EOF
[binaries]
c = 'emcc'
cpp = 'em++'
ar = 'emar'
ranlib = 'emranlib'
strip = 'emstrip'
[host_machine]
system = 'emscripten'
cpu_family = 'wasm32'
cpu = 'wasm32'
endian = 'little'
[built-in options]
c_args = [${MESON_DEBUG_FLAGS}, '-pthread', '-matomics', '-mbulk-memory']
c_link_args = ['-pthread']
EOF
meson setup "${PIXMAN_DIR}" \
--cross-file cross-file.txt \
--prefix="${SYSROOT}" \
--default-library=static \
--buildtype=${MESON_BUILD_TYPE} \
-Dgtk=disabled \
-Dlibpng=disabled \
-Dtests=disabled
# JOBS is set in env.sh (default: 1 for sequential builds, use -j N to override)
ninja -j${JOBS}
ninja install
create_stamp "${PIXMAN_STAMP}"
log_info "Pixman build complete!"