[cpp] Docker build for GCC testing, minor GCC fixes

This commit is contained in:
Mario Zechner 2025-07-30 12:10:02 +02:00
parent e162835c31
commit f9fefee0c8
5 changed files with 70 additions and 7 deletions

15
spine-c/Dockerfile Normal file
View File

@ -0,0 +1,15 @@
FROM ubuntu:24.04
# Install build dependencies for spine-c
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
ninja-build \
git \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /workspace
# Default command
CMD ["bash"]

28
spine-c/build-docker.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
set -e
# Get to the script's directory
cd "$(dirname "$0")"
# Build Docker image if it doesn't exist or if Dockerfile changed
IMAGE_NAME="spine-c-build"
if ! docker images | grep -q "$IMAGE_NAME" || [ Dockerfile -nt .docker-built ]; then
echo "Building Docker image for spine-c..."
docker build -t "$IMAGE_NAME" .
touch .docker-built
fi
# Clean build directory to avoid platform conflicts
if [ -d "build" ]; then
echo "Cleaning build directory to avoid platform conflicts..."
rm -rf build
fi
# Run the build in Docker
echo "Building spine-c in Docker container..."
docker run --rm \
-v "$(cd .. && pwd)":/workspace \
-w /workspace/spine-c \
"$IMAGE_NAME" \
./build.sh "$@"

View File

@ -56,11 +56,32 @@
#endif
#endif
#define SPINE_OPAQUE_TYPE(name) \
typedef struct name##_wrapper { \
char _dummy; \
} name##_wrapper; \
#if defined(__clang__)
/* Clang needs to suppress both pedantic and C/C++ compatibility warnings */
#define SPINE_OPAQUE_TYPE(name) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wpedantic\"") \
_Pragma("clang diagnostic ignored \"-Wextern-c-compat\"") \
typedef struct name##_wrapper { \
} name##_wrapper; \
_Pragma("clang diagnostic pop") \
typedef name##_wrapper *name;
#elif defined(__GNUC__)
/* GCC only needs to suppress pedantic warning */
#define SPINE_OPAQUE_TYPE(name) \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
typedef struct name##_wrapper { \
} name##_wrapper; \
_Pragma("GCC diagnostic pop") \
typedef name##_wrapper *name;
#else
/* Other compilers - generic version */
#define SPINE_OPAQUE_TYPE(name) \
typedef struct name##_wrapper { \
} name##_wrapper; \
typedef name##_wrapper *name;
#endif
typedef long long spine_property_id;

View File

@ -80,7 +80,6 @@ namespace spine {
}
inline Array<T> &setSize(size_t newSize, const T &defaultValue) {
assert(newSize >= 0);
size_t oldSize = _size;
_size = newSize;
if (_capacity < newSize) {

View File

@ -133,7 +133,7 @@ void BonePose::updateWorldTransform(Skeleton &skeleton) {
za *= s;
zc *= s;
s = MathUtil::sqrt(za * za + zc * zc);
if (_inherit == Inherit_NoScale && (pa * pd - pb * pc < 0) != (skeleton.getScaleX() < 0 != skeleton.getScaleY() < 0)) s = -s;
if (_inherit == Inherit_NoScale && (pa * pd - pb * pc < 0) != ((skeleton.getScaleX() < 0) != (skeleton.getScaleY() < 0))) s = -s;
r = MathUtil::Pi / 2 + MathUtil::atan2(zc, za);
float zb = MathUtil::cos(r) * s;
float zd = MathUtil::sin(r) * s;
@ -207,7 +207,7 @@ void BonePose::updateLocalTransform(Skeleton &skeleton) {
pa *= s;
pc *= s;
s = MathUtil::sqrt(pa * pa + pc * pc);
if (_inherit == Inherit_NoScale && pid < 0 != (skeleton.getScaleX() < 0 != skeleton.getScaleY() < 0)) s = -s;
if (_inherit == Inherit_NoScale && (pid < 0) != ((skeleton.getScaleX() < 0) != (skeleton.getScaleY() < 0))) s = -s;
r = MathUtil::Pi / 2 + MathUtil::atan2(pc, pa);
pb = MathUtil::cos(r) * s;
pd = MathUtil::sin(r) * s;