mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
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:
parent
03757139cd
commit
619c076da2
77
.github/workflows/spine-c-bindings-check.yml
vendored
Normal file
77
.github/workflows/spine-c-bindings-check.yml
vendored
Normal 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
|
||||
@ -51,13 +51,13 @@ NC='\033[0m' # No Color
|
||||
# This runs once when logging.sh is sourced
|
||||
detect_nesting_level() {
|
||||
local nesting=0
|
||||
|
||||
|
||||
# Check parent process for script execution
|
||||
if [ -n "$PPID" ]; then
|
||||
local parent_info=$(ps -p $PPID -o comm,args 2>/dev/null | tail -1)
|
||||
local parent_comm=$(echo "$parent_info" | awk '{print $1}')
|
||||
local parent_args=$(echo "$parent_info" | awk '{for(i=2;i<=NF;i++) printf "%s ", $i}')
|
||||
|
||||
|
||||
case "$parent_comm" in
|
||||
*bash|*sh|bash|sh)
|
||||
if echo "$parent_args" | grep -q '\.sh\|\.bash' && ! echo "$parent_args" | grep -q 'claude\|snapshot\|/tmp/\|eval'; then
|
||||
@ -66,7 +66,7 @@ detect_nesting_level() {
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
# Fallback to SHLVL-based detection if no parent script found
|
||||
if [ $nesting -eq 0 ] && [ $((SHLVL - 1)) -gt 0 ]; then
|
||||
# Check if non-interactive (likely scripted)
|
||||
@ -74,7 +74,7 @@ detect_nesting_level() {
|
||||
nesting=$((SHLVL - 1))
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo $nesting
|
||||
}
|
||||
|
||||
@ -127,4 +127,9 @@ log_summary() {
|
||||
# Detailed output (errors, etc.)
|
||||
log_detail() {
|
||||
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
34
generate-all-bindings.sh
Executable 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"
|
||||
@ -3,26 +3,49 @@
|
||||
set -e
|
||||
|
||||
# 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
|
||||
if [ ! -d "codegen/node_modules" ]; then
|
||||
pushd codegen > /dev/null
|
||||
npm install
|
||||
popd > /dev/null
|
||||
log_action "Installing codegen dependencies"
|
||||
if (cd codegen && npm install > /dev/null 2>&1); then
|
||||
log_ok
|
||||
else
|
||||
log_fail
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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
|
||||
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
|
||||
pushd test > /dev/null
|
||||
./build.sh
|
||||
popd
|
||||
log_action "Building test library"
|
||||
if (cd test && ./build.sh > /dev/null 2>&1); then
|
||||
log_ok
|
||||
else
|
||||
log_fail
|
||||
exit 1
|
||||
fi
|
||||
|
||||
popd > /dev/null
|
||||
log_summary "✓ Dart bindings generated successfully"
|
||||
Loading…
x
Reference in New Issue
Block a user