pcbjam/scripts/build-wxwidgets-native.sh
Viktor Vaczi 490f531521 feat(webgl): Add GAL native test harness for visual regression testing
Add a standalone test application that compiles KiCad's actual OPENGL_GAL
against system wxWidgets to generate baseline screenshots for comparing
native OpenGL rendering against WebGL rendering in the browser.

Architecture:
- Compiles 18 KiCad GAL source files from the kicad submodule
- Uses template-based private member accessor (safer than #define private public)
- Generates shader C++ files from GLSL (10 shader pairs for SMAA AA)
- Minimal stubs for KiCad dependencies (PGM_BASE, ADVANCED_CFG, etc.)

Test coverage:
- 11 scenarios testing ~19% of GAL API
- basic-lines, line-widths, circles, arcs, rectangles, polygons
- alpha-blending, transforms, grid-cursor, segments, complex-scene

Key insights documented:
- GAL uses world-to-screen transformation requiring 1:1 pixel mapping
- FBO reading required for clean screenshots on macOS
- Layer depth needed for proper z-ordering in complex scenes

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 09:42:31 +01:00

62 lines
1.7 KiB
Shell
Executable file

#!/bin/bash
#
# Build wxWidgets for native macOS (not WASM)
# This is used for the native GAL test harness
#
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
WX_SRC="$PROJECT_ROOT/wxwidgets"
BUILD_DIR="$PROJECT_ROOT/build-native/wxwidgets"
INSTALL_DIR="$PROJECT_ROOT/build-native/wxwidgets-install"
LOG_FILE="$PROJECT_ROOT/tests/logs/wxwidgets-native-build.log"
mkdir -p "$(dirname "$LOG_FILE")"
echo "Building wxWidgets for native macOS..."
echo " Source: $WX_SRC"
echo " Build: $BUILD_DIR"
echo " Install: $INSTALL_DIR"
echo " Log: $LOG_FILE"
# Create build directory
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Set up paths for homebrew libraries
export PKG_CONFIG_PATH="/opt/homebrew/lib/pkgconfig:/opt/homebrew/opt/libpng/lib/pkgconfig:$PKG_CONFIG_PATH"
export CPPFLAGS="-I/opt/homebrew/include $CPPFLAGS"
export LDFLAGS="-L/opt/homebrew/lib $LDFLAGS"
# Configure wxWidgets for native macOS with OpenGL support
echo "Configuring..."
"$WX_SRC/configure" \
--prefix="$INSTALL_DIR" \
--disable-shared \
--with-opengl \
--with-osx_cocoa \
--disable-webview \
--disable-mediactrl \
--with-libpng=sys \
--with-libjpeg=sys \
--with-libtiff=sys \
--with-zlib=sys \
>> "$LOG_FILE" 2>&1
# Build
echo "Building (this may take a while)..."
make -j$(sysctl -n hw.ncpu 2>/dev/null || echo 4) >> "$LOG_FILE" 2>&1
# Install
echo "Installing..."
make install >> "$LOG_FILE" 2>&1
echo ""
echo "wxWidgets native build complete!"
echo "wx-config: $INSTALL_DIR/bin/wx-config"
echo ""
echo "To use in CMake:"
echo " set(wxWidgets_CONFIG_EXECUTABLE $INSTALL_DIR/bin/wx-config)"
echo " find_package(wxWidgets REQUIRED COMPONENTS core base gl)"