mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-21 01:36:02 +08:00
[cpp] Smoke tests
This commit is contained in:
parent
6a621f0cc1
commit
1a10d185a3
@ -9,8 +9,8 @@ include_directories(include)
|
||||
file(GLOB INCLUDES "include/**/*.h")
|
||||
file(GLOB ALL_SOURCES "src/**/*.cpp")
|
||||
|
||||
# Exclude nostdcpp.cpp from regular build
|
||||
list(FILTER ALL_SOURCES EXCLUDE REGEX "src/nostdcpp\\.cpp$")
|
||||
# Exclude no-cpprt.cpp from regular build
|
||||
list(FILTER ALL_SOURCES EXCLUDE REGEX "src/no-cpprt\\.cpp$")
|
||||
set(SOURCES ${ALL_SOURCES})
|
||||
|
||||
add_library(spine-cpp STATIC ${SOURCES} ${INCLUDES})
|
||||
@ -20,10 +20,10 @@ if(SPINE_NO_FILE_IO)
|
||||
target_compile_definitions(spine-cpp PRIVATE SPINE_NO_FILE_IO)
|
||||
endif()
|
||||
|
||||
# nostdcpp variant (no C++ standard library)
|
||||
set(NOSTDCPP_SOURCES ${SOURCES} "src/nostdcpp.cpp")
|
||||
add_library(spine-cpp-nostdcpp STATIC ${NOSTDCPP_SOURCES} ${INCLUDES})
|
||||
target_include_directories(spine-cpp-nostdcpp PUBLIC include)
|
||||
# no-cpprt variant (no C++ runtime)
|
||||
set(NO_CPPRT_SOURCES ${SOURCES} "src/no-cpprt.cpp")
|
||||
add_library(spine-cpp-no-cpprt STATIC ${NO_CPPRT_SOURCES} ${INCLUDES})
|
||||
target_include_directories(spine-cpp-no-cpprt PUBLIC include)
|
||||
|
||||
# Install target
|
||||
install(TARGETS spine-cpp EXPORT spine-cpp_TARGETS DESTINATION dist/lib)
|
||||
@ -44,18 +44,18 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
target_compile_definitions(headless-test PRIVATE SPINE_NO_FILE_IO)
|
||||
endif()
|
||||
|
||||
# Configure nostdcpp linking for different platforms
|
||||
add_executable(headless-test-nostdcpp ${CMAKE_CURRENT_SOURCE_DIR}/tests/HeadlessTest.cpp)
|
||||
target_link_libraries(headless-test-nostdcpp spine-cpp-nostdcpp)
|
||||
# Configure no-cpprt linking for different platforms
|
||||
add_executable(headless-test-no-cpprt ${CMAKE_CURRENT_SOURCE_DIR}/tests/HeadlessTest.cpp)
|
||||
target_link_libraries(headless-test-no-cpprt spine-cpp-no-cpprt)
|
||||
|
||||
if(MSVC)
|
||||
target_link_options(headless-test-nostdcpp PRIVATE /NODEFAULTLIB)
|
||||
target_link_libraries(headless-test-nostdcpp msvcrt kernel32)
|
||||
target_link_options(headless-test-no-cpprt PRIVATE /NODEFAULTLIB)
|
||||
target_link_libraries(headless-test-no-cpprt msvcrt kernel32)
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
target_link_options(headless-test-nostdcpp PRIVATE -nostdlib++ -lc)
|
||||
target_link_options(headless-test-no-cpprt PRIVATE -nostdlib++ -lc)
|
||||
else()
|
||||
target_link_options(headless-test-nostdcpp PRIVATE -nodefaultlibs)
|
||||
target_link_libraries(headless-test-nostdcpp -lm -lc -lgcc)
|
||||
target_link_options(headless-test-no-cpprt PRIVATE -nodefaultlibs)
|
||||
target_link_libraries(headless-test-no-cpprt -lm -lc -lgcc)
|
||||
endif()
|
||||
|
||||
# Static variants (Linux only)
|
||||
@ -64,14 +64,14 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
||||
target_link_libraries(headless-test-static spine-cpp)
|
||||
target_link_options(headless-test-static PRIVATE -static)
|
||||
|
||||
add_executable(headless-test-nostdcpp-static ${CMAKE_CURRENT_SOURCE_DIR}/tests/HeadlessTest.cpp)
|
||||
target_link_libraries(headless-test-nostdcpp-static spine-cpp-nostdcpp)
|
||||
target_link_options(headless-test-nostdcpp-static PRIVATE -static -static-libgcc -Wl,--exclude-libs,libstdc++.a)
|
||||
target_link_libraries(headless-test-nostdcpp-static -lm -lc)
|
||||
add_executable(headless-test-no-cpprt-static ${CMAKE_CURRENT_SOURCE_DIR}/tests/HeadlessTest.cpp)
|
||||
target_link_libraries(headless-test-no-cpprt-static spine-cpp-no-cpprt)
|
||||
target_link_options(headless-test-no-cpprt-static PRIVATE -static -static-libgcc -Wl,--exclude-libs,libstdc++.a)
|
||||
target_link_libraries(headless-test-no-cpprt-static -lm -lc)
|
||||
|
||||
if(SPINE_NO_FILE_IO)
|
||||
target_compile_definitions(headless-test-static PRIVATE SPINE_NO_FILE_IO)
|
||||
target_compile_definitions(headless-test-nostdcpp-static PRIVATE SPINE_NO_FILE_IO)
|
||||
target_compile_definitions(headless-test-no-cpprt-static PRIVATE SPINE_NO_FILE_IO)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@ -18,6 +18,10 @@ spine-cpp works with data exported from spine 4.3.xx.
|
||||
|
||||
spine-cpp supports all spine features.
|
||||
|
||||
## Usage
|
||||
|
||||
### [Please see the spine-cpp guide for full documentation](http://esotericsoftware.com/spine-cpp)
|
||||
|
||||
## Setup
|
||||
|
||||
### Manual Copy
|
||||
@ -42,10 +46,6 @@ add_subdirectory(${spine-runtimes_SOURCE_DIR}/spine-cpp ${spine-runtimes_BINARY_
|
||||
target_link_libraries(your_target PRIVATE spine-cpp)
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### [Please see the spine-cpp guide for full documentation](http://esotericsoftware.com/spine-cpp)
|
||||
|
||||
## Runtimes extending spine-cpp
|
||||
- [spine-glfw](../spine-glfw)
|
||||
- [spine-sdl](../spine-sdl)
|
||||
|
||||
84
spine-cpp/tests/test-linux-docker.sh
Executable file
84
spine-cpp/tests/test-linux-docker.sh
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
# Spine-C++ Docker Test Runner
|
||||
#
|
||||
# Runs the full spine-cpp test suite inside a Linux Docker container.
|
||||
# This ensures consistent testing across different host environments.
|
||||
|
||||
set -e
|
||||
|
||||
# Change to spine-runtimes root directory (parent of spine-cpp)
|
||||
cd "$(dirname "$0")/../.."
|
||||
|
||||
# Source logging utilities
|
||||
source formatters/logging/logging.sh
|
||||
|
||||
log_title "Spine-C++ Docker Test"
|
||||
log_detail "Running tests in Linux container"
|
||||
|
||||
# Detect existing build type
|
||||
BUILD_TYPE=""
|
||||
cd spine-cpp
|
||||
if [ -f "build/CMakeCache.txt" ]; then
|
||||
if grep -q "CMAKE_BUILD_TYPE:STRING=Release" build/CMakeCache.txt 2>/dev/null; then
|
||||
BUILD_TYPE="release"
|
||||
elif grep -q "CMAKE_BUILD_TYPE:STRING=Debug" build/CMakeCache.txt 2>/dev/null; then
|
||||
BUILD_TYPE="debug"
|
||||
fi
|
||||
log_detail "Detected existing build type: ${BUILD_TYPE:-unknown}"
|
||||
fi
|
||||
cd ..
|
||||
|
||||
# Use a lightweight Linux image with build tools
|
||||
DOCKER_IMAGE="gcc:12"
|
||||
|
||||
log_action "Pulling Docker image"
|
||||
if docker pull "$DOCKER_IMAGE" > /dev/null 2>&1; then
|
||||
log_ok
|
||||
else
|
||||
log_fail "Failed to pull Docker image"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_action "Running tests in container"
|
||||
if DOCKER_OUTPUT=$(docker run --rm \
|
||||
-v "$(pwd)":/workspace \
|
||||
-w /workspace/spine-cpp \
|
||||
"$DOCKER_IMAGE" \
|
||||
bash -c "apt-get update -qq && apt-get install -y -qq cmake ninja-build && ./tests/test.sh" 2>&1); then
|
||||
log_ok
|
||||
|
||||
log_action "Analyzing executables"
|
||||
if ANALYSIS_OUTPUT=$(docker run --rm \
|
||||
-v "$(pwd)":/workspace \
|
||||
-w /workspace/spine-cpp \
|
||||
"$DOCKER_IMAGE" \
|
||||
bash -c "echo '=== EXECUTABLE ANALYSIS ==='; for exe in build/headless-test*; do if [ -f \"\$exe\" ] && [ -x \"\$exe\" ]; then echo; echo \"--- \$(basename \"\$exe\") ---\"; echo \"Size: \$(du -h \"\$exe\" | cut -f1)\"; echo \"Dependencies:\"; ldd \"\$exe\" 2>/dev/null || echo 'No dynamic dependencies'; fi; done" 2>&1); then
|
||||
log_ok
|
||||
log_detail "$ANALYSIS_OUTPUT"
|
||||
else
|
||||
log_fail
|
||||
log_error_output "$ANALYSIS_OUTPUT"
|
||||
fi
|
||||
|
||||
log_action "Restoring local build directory"
|
||||
cd spine-cpp
|
||||
if rm -rf build; then
|
||||
if [ -n "$BUILD_TYPE" ]; then
|
||||
log_detail "Rebuilding $BUILD_TYPE configuration"
|
||||
if ./build.sh clean "$BUILD_TYPE" > /dev/null 2>&1; then
|
||||
log_ok "Local build directory restored ($BUILD_TYPE)"
|
||||
else
|
||||
log_detail "Warning: Could not restore $BUILD_TYPE build"
|
||||
fi
|
||||
else
|
||||
log_detail "No previous build detected, leaving clean"
|
||||
log_ok "Build directory cleaned"
|
||||
fi
|
||||
else
|
||||
log_detail "Warning: Could not remove build directory"
|
||||
fi
|
||||
else
|
||||
log_fail
|
||||
log_error_output "$DOCKER_OUTPUT"
|
||||
exit 1
|
||||
fi
|
||||
@ -3,9 +3,9 @@
|
||||
#
|
||||
# Tests all spine-cpp build variants with spineboy example data:
|
||||
# - headless-test (regular dynamic)
|
||||
# - headless-test-nostdcpp (nostdcpp dynamic)
|
||||
# - headless-test-no-cpprt (no-cpprt dynamic)
|
||||
# - headless-test-static (regular static, Linux only)
|
||||
# - headless-test-nostdcpp-static (nostdcpp static, Linux only)
|
||||
# - headless-test-no-cpprt-static (no-cpprt static, Linux only)
|
||||
|
||||
set -e
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user