Ver código fonte

Add the Spine 3.8 runtime library (#5034)

* Add the Spine 3.8 runtime library

* fix issues.But install package error: package(spine-cpp): links not found!

* Remove the CMAKE_INSTALL_PREFIX from the target repository and let xrepo set this variable itself to solve the problem of source and library files not being copied to the package directory.

* refractor

* fix patch

* fix indent

---------

Co-authored-by: star9029 <[email protected]>
张喜昌 1 ano atrás
pai
commit
d381bc07ec

+ 72 - 0
packages/s/spine-runtimes/patches/3.8/cmake.patch

@@ -0,0 +1,72 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 17d865734..9a5787b7f 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,37 +1,6 @@
+-cmake_minimum_required(VERSION 2.8.9)
++cmake_minimum_required(VERSION 3.5)
+ project(spine)
+ 
+-if(MSVC)
+-	message("MSCV detected")
+-	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+-	set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
+-else()
+-	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wunused-value -Wno-c++11-long-long -Wno-variadic-macros -Werror -Wextra -pedantic -Wnonportable-include-path -Wshadow -std=c89")
+-	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused-value -Wno-c++11-long-long -Wno-variadic-macros -Werror -Wextra -Wnon-virtual-dtor -pedantic -Wnonportable-include-path -Wshadow -std=c++03 -fno-exceptions -fno-rtti")
+-endif()
++include(GNUInstallDirs)
+ 
+-set(CMAKE_INSTALL_PREFIX "./")
+-set(CMAKE_VERBOSE_MAKEFILE ON)
+-set(SPINE_SFML FALSE CACHE BOOL FALSE)
+-set(SPINE_COCOS2D_OBJC FALSE CACHE BOOL FALSE)
+-set(SPINE_COCOS2D_X FALSE CACHE BOOL FALSE)
+-
+-if((${SPINE_SFML}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-sfml"))
+-	add_subdirectory(spine-c)
+-	add_subdirectory(spine-sfml/c)
+-	add_subdirectory(spine-cpp)
+-	add_subdirectory(spine-sfml/cpp)
+-endif()
+-
+-if((${SPINE_COCOS2D_OBJC}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-cocos2d-objc"))
+-	if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+-		add_subdirectory(spine-cocos2d-objc)
+-	endif()
+-endif()
+-
+-if((${SPINE_COCOS2D_X}) OR (${CMAKE_CURRENT_BINARY_DIR} MATCHES "spine-cocos2dx"))
+-	add_subdirectory(spine-cocos2dx)
+-endif()
+-
+-add_subdirectory(spine-c/spine-c-unit-tests)
+-add_subdirectory(spine-cpp/spine-cpp-unit-tests)
+\ No newline at end of file
++add_subdirectory(spine-cpp)
+diff --git a/spine-cpp/CMakeLists.txt b/spine-cpp/CMakeLists.txt
+index 706040cab..d5fac84aa 100644
+--- a/spine-cpp/CMakeLists.txt
++++ b/spine-cpp/CMakeLists.txt
+@@ -1,17 +1,9 @@
+-if(MSVC)
+-	message("MSCV detected")
+-	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+-	set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS}")
+-else()
+-	set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pedantic -std=c89")
+-	set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -pedantic -std=c++03 -fno-exceptions -fno-rtti")
+-endif()
+-
+ include_directories(include)
+ file(GLOB INCLUDES "spine-cpp/include/**/*.h")
+ file(GLOB SOURCES "spine-cpp/src/**/*.cpp")
+ 
+ add_library(spine-cpp STATIC ${SOURCES} ${INCLUDES})
+ target_include_directories(spine-cpp PUBLIC spine-cpp/include)
+-install(TARGETS spine-cpp DESTINATION dist/lib)
+-install(FILES ${INCLUDES} DESTINATION dist/include)
+\ No newline at end of file
++
++install(TARGETS spine-cpp DESTINATION ${CMAKE_INSTALL_LIBDIR})
++install(DIRECTORY "./spine-cpp/include/spine" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

+ 38 - 0
packages/s/spine-runtimes/xmake.lua

@@ -0,0 +1,38 @@
+package("spine-runtimes")
+    set_homepage("http://esotericsoftware.com")
+    set_description("2D skeletal animation runtimes for Spine.")
+    set_license("Spine Runtimes")
+
+    add_urls("https://github.com/EsotericSoftware/spine-runtimes.git")
+
+    add_versions("3.8", "d33c10f85634d01efbe4a3ab31dabaeaca41230c")
+
+    add_patches("3.8", "patches/3.8/cmake.patch", "bbfa70e3e36f8b3beefbc84d8047eb6735e1e75f4dce643d8916e231b13b992c")
+
+    add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+
+    if is_host("windows") then
+        set_policy("platform.longpaths", true)
+    end
+
+    add_deps("cmake")
+
+    on_install(function(package)
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            namespace spine {
+                SpineExtension *getDefaultExtension() {
+                    return new DefaultSpineExtension();
+                }
+            }
+            void test() {
+                assert(spine::SpineExtension::getInstance() != nullptr);
+            }
+        ]]}, {configs = {languages = "c++17"}, includes = "spine/spine.h"}))
+    end)