Add stamp source hashing and maximize test infrastructure
- Add source hashing to stamp system (functions.sh) for detecting when dependencies need rebuild based on source file changes - Update build-pcbnew.sh to use source stamps for wxWidgets - Add global-setup.ts to clean logs before test runs - Add maximize_test standalone test to verify wxFrame::Maximize() works correctly in WASM (it does - window is 1280x720) - Update Makefile.wasm with maximize test build rules The maximize_test proves wxWidgets display detection works fine. KiCad's 20x20 window bug is KiCad-specific, not a wxWidgets issue. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
6771e7de74
commit
8453f9681e
8 changed files with 416 additions and 14 deletions
|
|
@ -193,6 +193,81 @@ remove_stamp() {
|
|||
rm -f "$stamp_file"
|
||||
}
|
||||
|
||||
# Compute hash of source files in a directory
|
||||
# Usage: compute_source_hash /path/to/source "*.cpp" "*.h"
|
||||
compute_source_hash() {
|
||||
local source_dir="$1"
|
||||
shift
|
||||
local patterns=("$@")
|
||||
|
||||
# Build find command for all patterns
|
||||
local find_args=()
|
||||
for pattern in "${patterns[@]}"; do
|
||||
if [ ${#find_args[@]} -gt 0 ]; then
|
||||
find_args+=("-o")
|
||||
fi
|
||||
find_args+=("-name" "$pattern")
|
||||
done
|
||||
|
||||
# Hash all matching files (sorted for consistency)
|
||||
# Use md5 on macOS, md5sum on Linux (Docker)
|
||||
if command -v md5 &>/dev/null; then
|
||||
find "$source_dir" -type f \( "${find_args[@]}" \) 2>/dev/null | \
|
||||
sort | \
|
||||
xargs cat 2>/dev/null | \
|
||||
md5
|
||||
else
|
||||
find "$source_dir" -type f \( "${find_args[@]}" \) 2>/dev/null | \
|
||||
sort | \
|
||||
xargs cat 2>/dev/null | \
|
||||
md5sum | \
|
||||
cut -d' ' -f1
|
||||
fi
|
||||
}
|
||||
|
||||
# Create stamp with source hash
|
||||
# Usage: create_source_stamp "wxwidgets" /path/to/source "*.cpp" "*.h"
|
||||
create_source_stamp() {
|
||||
local name="$1"
|
||||
local source_dir="$2"
|
||||
shift 2
|
||||
local patterns=("$@")
|
||||
|
||||
local stamp_dir="${BUILD_ROOT:-$PROJECT_ROOT/build-wasm}/stamps"
|
||||
mkdir -p "$stamp_dir"
|
||||
local stamp_file="$stamp_dir/$name.stamp"
|
||||
|
||||
local hash=$(compute_source_hash "$source_dir" "${patterns[@]}")
|
||||
echo "$hash" > "$stamp_file"
|
||||
log_info "Created stamp: $name (hash: ${hash:0:8}...)"
|
||||
}
|
||||
|
||||
# Check if source stamp is still valid
|
||||
# Usage: check_source_stamp "wxwidgets" /path/to/source "*.cpp" "*.h"
|
||||
# Returns: 0 if valid (no rebuild needed), 1 if invalid (rebuild needed)
|
||||
check_source_stamp() {
|
||||
local name="$1"
|
||||
local source_dir="$2"
|
||||
shift 2
|
||||
local patterns=("$@")
|
||||
|
||||
local stamp_file="${BUILD_ROOT:-$PROJECT_ROOT/build-wasm}/stamps/$name.stamp"
|
||||
|
||||
if [ ! -f "$stamp_file" ]; then
|
||||
return 1 # No stamp, need build
|
||||
fi
|
||||
|
||||
local stored_hash=$(cat "$stamp_file")
|
||||
local current_hash=$(compute_source_hash "$source_dir" "${patterns[@]}")
|
||||
|
||||
if [ "$stored_hash" = "$current_hash" ]; then
|
||||
return 0 # Up to date
|
||||
else
|
||||
log_info "Source changed for $name (${stored_hash:0:8}... -> ${current_hash:0:8}...)"
|
||||
return 1 # Changed, need rebuild
|
||||
fi
|
||||
}
|
||||
|
||||
# Build if stamp doesn't exist
|
||||
build_if_needed() {
|
||||
local name="$1"
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@
|
|||
# --debug Build with debug symbols (default)
|
||||
# --release Build optimized without debug symbols
|
||||
# -j N Parallel compilation jobs (default: 1)
|
||||
#
|
||||
# Stamp System:
|
||||
# Dependencies use source-hash stamps to detect when rebuilds are needed.
|
||||
# wxWidgets rebuilds automatically when source files (*.cpp, *.h, *.c) change.
|
||||
# To force a rebuild, delete the stamp: rm -f build-wasm/stamps/wxwidgets.stamp
|
||||
|
||||
set -e
|
||||
|
||||
|
|
@ -101,16 +106,13 @@ if [ $NO_CLEAN -eq 1 ] && check_stamp "${KICAD_STAMP}"; then
|
|||
exit 0
|
||||
fi
|
||||
|
||||
# Step 4: Build wxWidgets if not present
|
||||
WXWIDGETS_STAMP="${BUILD_ROOT}/stamps/wxwidgets.stamp"
|
||||
if [ ! -f "${WX_BUILD}/lib/libwx_baseu-3.2.a" ]; then
|
||||
# Step 4: Build wxWidgets if source changed or not present
|
||||
WX_SOURCE="${PROJECT_ROOT}/wxwidgets/src"
|
||||
if [ ! -f "${WX_BUILD}/lib/libwx_baseu-3.2.a" ] || \
|
||||
! check_source_stamp "wxwidgets" "$WX_SOURCE" "*.cpp" "*.h" "*.c"; then
|
||||
log_info "Building wxWidgets..."
|
||||
"${SCRIPT_DIR}/../build-wxuniversal-wasm.sh" --no-clean
|
||||
# Create stamp after successful build
|
||||
touch "${WXWIDGETS_STAMP}"
|
||||
elif [ ! -f "${WXWIDGETS_STAMP}" ]; then
|
||||
# Library exists but no stamp - create one
|
||||
touch "${WXWIDGETS_STAMP}"
|
||||
create_source_stamp "wxwidgets" "$WX_SOURCE" "*.cpp" "*.h" "*.c"
|
||||
fi
|
||||
|
||||
log_info "Building KiCad PCBnew ${KICAD_VERSION} for WASM..."
|
||||
|
|
|
|||
Loading…
Reference in a new issue