Browse Source

add ogre-next (#587)

* improve libice and libsm

* add ogre

* rename and fix ogre-next

* fix macosx again

* disable opengl on macosx
Hoildkv 4 years ago
parent
commit
c1b4838c9b

+ 1 - 1
.github/workflows/fedora.yml

@@ -22,7 +22,7 @@ jobs:
           dnf -y install gfortran
           dnf -y install gfortran
           dnf -y install mesa-libGL-devel mesa-libGLU-devel
           dnf -y install mesa-libGL-devel mesa-libGLU-devel
           dnf -y install @development-tools @rpm-development-tools
           dnf -y install @development-tools @rpm-development-tools
-          dnf -y install copr-cli make gcc-c++
+          dnf -y install copr-cli make gcc-c++ libatomic
           dnf -y upgrade git
           dnf -y upgrade git
           dnf -y install perl
           dnf -y install perl
       - uses: actions/checkout@v1
       - uses: actions/checkout@v1

+ 4 - 0
packages/l/libice/xmake.lua

@@ -6,6 +6,10 @@ package("libice")
     add_urls("https://www.x.org/archive/individual/lib/libICE-$(version).tar.gz")
     add_urls("https://www.x.org/archive/individual/lib/libICE-$(version).tar.gz")
     add_versions("1.0.10", "1116bc64c772fd127a0d0c0ffa2833479905e3d3d8197740b3abd5f292f22d2d")
     add_versions("1.0.10", "1116bc64c772fd127a0d0c0ffa2833479905e3d3d8197740b3abd5f292f22d2d")
 
 
+    if is_plat("linux") then
+        add_extsources("apt::libice-dev")
+    end
+
     add_deps("xtrans")
     add_deps("xtrans")
 
 
     on_install("macosx", "linux", function (package)
     on_install("macosx", "linux", function (package)

+ 4 - 0
packages/l/libsm/xmake.lua

@@ -6,6 +6,10 @@ package("libsm")
     add_urls("https://www.x.org/archive/individual/lib/libSM-$(version).tar.gz")
     add_urls("https://www.x.org/archive/individual/lib/libSM-$(version).tar.gz")
     add_versions("1.2.3", "1e92408417cb6c6c477a8a6104291001a40b3bb56a4a60608fdd9cd2c5a0f320")
     add_versions("1.2.3", "1e92408417cb6c6c477a8a6104291001a40b3bb56a4a60608fdd9cd2c5a0f320")
 
 
+    if is_plat("linux") then
+        add_extsources("apt::libsm-dev")
+    end
+
     add_deps("libice")
     add_deps("libice")
 
 
     on_install("macosx", "linux", function (package)
     on_install("macosx", "linux", function (package)

+ 63 - 0
packages/o/ogre-next/patches/2.2.5/macosx.patch

@@ -0,0 +1,63 @@
+diff --git a/OgreMain/src/OgrePlatformInformation.cpp b/OgreMain/src/OgrePlatformInformation.cpp
+--- a/OgreMain/src/OgrePlatformInformation.cpp
++++ b/OgreMain/src/OgrePlatformInformation.cpp
+@@ -40,29 +40,18 @@ THE SOFTWARE.
+ #elif (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && OGRE_PLATFORM != OGRE_PLATFORM_NACL
+ #include <signal.h>
+ #include <setjmp.h>
+-#if OGRE_PLATFORM != OGRE_PLATFORM_WIN32
+-    #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
+-        #include <linux/sysctl.h>
+-    #endif
+ #endif
+ 
+-    #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
+-        #include <cpu-features.h>
+-    #elif OGRE_CPU == OGRE_CPU_ARM 
+-        #if __MACH__
+-            #include <mach/machine.h>
+-            #ifndef CPU_SUBTYPE_ARM64_V8
+-                #define CPU_SUBTYPE_ARM64_V8 ((cpu_subtype_t) 1)
+-            #endif
+-            #ifndef CPU_SUBTYPE_ARM_V8
+-                #define CPU_SUBTYPE_ARM_V8 ((cpu_subtype_t) 13)
+-            #endif
+-        #endif
+-    #endif
++#if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
++    #include <linux/sysctl.h>
++    #include <cpu-features.h>
++#endif
++#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE || OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
++    #include <sys/sysctl.h>
++    #include <mach/machine.h>
+ #endif
+-
+ #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 || OGRE_PLATFORM == OGRE_PLATFORM_WINRT
+-    #include "windows.h"
++    #include <windows.h>
+ #endif
+ 
+ // Yes, I know, this file looks very ugly, but there aren't other ways to do it better.
+diff --git a/OgreMain/CMakeLists.txt b/OgreMain/CMakeLists.txt
+--- a/OgreMain/CMakeLists.txt
++++ b/OgreMain/CMakeLists.txt
+@@ -419,11 +419,13 @@ else()
+   set_target_properties(OgreMain PROPERTIES VERSION ${OGRE_SOVERSION} SOVERSION ${OGRE_SOVERSION})
+ endif()
+ 
+-if(OGRE_GCC_VERSION VERSION_EQUAL 4.8 OR OGRE_GCC_VERSION VERSION_GREATER 4.8)
+-  if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+-    list(APPEND LIBRARIES "-latomic_ops")
+-  else()
+-    list(APPEND LIBRARIES "-latomic")
++if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
++  if(OGRE_GCC_VERSION VERSION_EQUAL 4.8 OR OGRE_GCC_VERSION VERSION_GREATER 4.8)
++    if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
++      list(APPEND LIBRARIES "-latomic_ops")
++    else()
++      list(APPEND LIBRARIES "-latomic")
++    endif()
+   endif()
+ endif()
+ 

+ 43 - 0
packages/o/ogre-next/xmake.lua

@@ -0,0 +1,43 @@
+package("ogre-next")
+
+    set_homepage("https://www.ogre3d.org/")
+    set_description("scene-oriented, flexible 3D engine written in C++")
+    set_license("MIT")
+
+    add_urls("https://github.com/OGRECave/ogre-next/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/OGRECave/ogre-next.git")
+    add_versions("v2.2.5", "b3b555386aa7ebf164a41451ad896bb3774521410944568ecec58f780d0725c4")
+
+    add_patches("v2.2.5", path.join(os.scriptdir(), "patches", "2.2.5", "macosx.patch"), "a20f32d8847dd4c93fe2b824d2b793862b8e3126ae7fda4450ad22e76bb00c32")
+
+    add_deps("cmake", "zziplib", "freetype", "zlib", "assimp")
+    add_deps("boost", {configs = {thread = true, date_time = true}})
+    if is_plat("linux") then
+        add_deps("libx11", "libxt", "libxaw", "libxrandr", "libsm", "libice", "xtrans")
+        add_syslinks("pthread")
+    end
+    add_includedirs("include/OGRE")
+    on_load("windows", function (package)
+        if not package:config("shared") then
+            package:add("defines", "OGRE_STATIC_LIB")
+        end
+    end)
+
+    on_install("windows", "macosx", "linux", function (package)
+        io.replace("Components/Hlms/Pbs/src/IrradianceField/OgreIrradianceField.cpp", "2ᵃ * 2ᵇ = 2ⁿ", "", {plain = true})
+        local configs = {"-DOGRE_BUILD_SAMPLES2=OFF", "-DOGRE_BUILD_TESTS=OFF", "-DCMAKE_CXX_STANDARD=17"}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DOGRE_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
+        if package:is_plat("macosx") then
+            table.insert(configs, "-DOGRE_BUILD_RENDERSYSTEM_GL3PLUS=OFF")
+        end
+        if package:is_plat("linux") then
+            import("package.tools.cmake").install(package, configs, {packagedeps = {"libx11", "libxt", "libxaw", "libxrandr", "libsm", "libice", "xtrans"}})
+        else
+            import("package.tools.cmake").install(package, configs)
+        end
+    end)
+
+    on_test(function (package)
+        assert(package:has_cxxtypes("Ogre::Root", {configs = {languages = "c++17"}, includes = "OgreRoot.h"}))
+    end)