Add spine-c bindings check automation

- Add generate-all-bindings.sh script with logging support
- Add GitHub Action to check if spine-c bindings are up-to-date
- Update spine-flutter/generate-bindings.sh to use logging.sh
- Action only runs on branches >= 4.3 (including beta versions)

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Mario Zechner 2025-07-25 23:31:07 +02:00
parent 03757139cd
commit 619c076da2
4 changed files with 154 additions and 15 deletions

View File

@ -0,0 +1,77 @@
name: spine-c bindings check
on:
push:
branches:
- '*'
jobs:
check-bindings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Check if branch qualifies for bindings check
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
echo "Branch: $BRANCH_NAME"
# Strip -beta suffix and extract version
VERSION=$(echo "$BRANCH_NAME" | sed 's/-beta$//')
# Check if it's a version branch (starts with number)
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+'; then
echo "Not a version branch, skipping bindings check"
exit 0
fi
# Extract major.minor version
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
# Check if version >= 4.3
if [ "$MAJOR" -gt 4 ] || ([ "$MAJOR" -eq 4 ] && [ "$MINOR" -ge 3 ]); then
echo "Branch qualifies for bindings check (version $MAJOR.$MINOR >= 4.3)"
echo "SHOULD_CHECK=true" >> $GITHUB_ENV
else
echo "Branch version $MAJOR.$MINOR < 4.3, skipping bindings check"
echo "SHOULD_CHECK=false" >> $GITHUB_ENV
fi
- name: Setup Node.js
if: env.SHOULD_CHECK == 'true'
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install build dependencies
if: env.SHOULD_CHECK == 'true'
run: |
sudo apt-get update
sudo apt-get install -y build-essential cmake ninja-build
- name: Generate and compile spine-c bindings
if: env.SHOULD_CHECK == 'true'
run: |
cd spine-c
./build.sh codegen
./build.sh clean
- name: Check for changes in generated bindings
if: env.SHOULD_CHECK == 'true'
run: |
if ! git diff --quiet; then
echo "❌ Generated bindings have changed!"
echo "This indicates that spine-cpp has been modified but spine-c bindings haven't been regenerated."
echo ""
echo "Changed files:"
git diff --name-only
echo ""
echo "Please run './generate-all-bindings.sh' locally and commit the changes."
exit 1
else
echo "✅ Generated bindings are up to date"
fi

View File

@ -128,3 +128,8 @@ log_summary() {
log_detail() { log_detail() {
echo -e "${SPINE_LOG_INDENT_SPACES} ${GRAY}$1${NC}" echo -e "${SPINE_LOG_INDENT_SPACES} ${GRAY}$1${NC}"
} }
# Log a simple info string at the current nesting level
log_info() {
echo -e "${SPINE_LOG_INDENT_SPACES}${CYAN}$1${NC}"
}

34
generate-all-bindings.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Script to generate all Spine runtime bindings
# This script regenerates bindings for C, Flutter, and cleans GLFW
# Get the directory containing this script
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
rm -rf "$SCRIPT_DIR/spine-c/codegen/node_modules" "$SCRIPT_DIR/spine-flutter/codegen/node_modules" "$SCRIPT_DIR/test/node_modules"
# Source logging utilities
source "$SCRIPT_DIR/formatters/logging/logging.sh"
log_title "Generating all Spine runtime bindings"
# Generate C bindings and test compilation
log_info "Generating C bindings"
cd "$SCRIPT_DIR/spine-c" && ./build.sh codegen
log_info "Testing C compilation"
cd "$SCRIPT_DIR/spine-c" && ./build.sh clean
# Clean GLFW
log_info "Test GLFW compilation"
cd "$SCRIPT_DIR/spine-glfw" && ./build.sh clean
# Generate Flutter bindings
log_info "Generating Dart bindings"
cd "$SCRIPT_DIR/spine-flutter" && ./generate-bindings.sh
log_info "Testing Dart"
cd "$SCRIPT_DIR/spine-flutter/test" && dart test headless_test.dart
log_summary "All bindings generated successfully"

View File

@ -3,26 +3,49 @@
set -e set -e
# Get to the script's directory # Get to the script's directory
pushd "$(dirname "$0")" > /dev/null cd "$(dirname "$0")"
#./setup.sh # Source logging utilities
source ../formatters/logging/logging.sh
log_title "spine-dart bindings generation"
# Install dependencies if needed # Install dependencies if needed
if [ ! -d "codegen/node_modules" ]; then if [ ! -d "codegen/node_modules" ]; then
pushd codegen > /dev/null log_action "Installing codegen dependencies"
npm install if (cd codegen && npm install > /dev/null 2>&1); then
popd > /dev/null log_ok
else
log_fail
exit 1
fi
fi fi
# Copy spine-c and spine-cpp sources # Copy spine-c and spine-cpp sources
./setup.sh log_action "Setting up source files"
if ./setup.sh > /dev/null 2>&1; then
log_ok
else
log_fail
exit 1
fi
# Run the codegen # Run the codegen
npx tsx codegen/src/index.ts log_action "Generating Dart bindings"
if npx tsx codegen/src/index.ts > /dev/null 2>&1; then
log_ok
else
log_fail
exit 1
fi
# Build test spine_flutter shared library # Build test spine_flutter shared library
pushd test > /dev/null log_action "Building test library"
./build.sh if (cd test && ./build.sh > /dev/null 2>&1); then
popd log_ok
else
log_fail
exit 1
fi
popd > /dev/null log_summary "✓ Dart bindings generated successfully"