Kaynağa Gözat

Add rlottie (#1846)

* add rlottie

* fix openssl patches sha256 error

* lock dependencies version of rlottie

* Revert "fix openssl patches sha256 error"

This reverts commit 14a281125969e20110ffb247f43b549b0ce4cbd8.

* fix error in tests of stb

* fix different sha256 for different sources of pixman

* temporarily disable pixman

* add patch for rlottie

* disable platform cross for rlottie

* fix error of rapidjson in windows-arm

* Use string.serialize() instead of string.dump()

* disable wasm shared library

* disable wasm shared lib for pixman and freetype

* fix install dir error of rlottie

* fix endian detect error of rapidjson in rlottie

* fix some error of rlottie

* fix endian error in win-arm of rapidjson

* add wasm patch for rlottie

* fix patch file error

* fix patch file error

* fix arm build error

* use pixman in xmake-repo

* set cxx standard for rlottie

* Update xmake.lua

* Update xmake.lua

* revert Android and iOS support for pixman

* remove  __declspec(dllimport) for static build

* fix a typo error

* update rlottie

* update rlottie

* Revert "use pixman in xmake-repo"

This reverts commit 442563f8e8dc33adef78a11b5fc6c848c3742e74.

* fix revert error

---------

Co-authored-by: ruki <[email protected]>
冰雪殇璃陌梦 2 yıl önce
ebeveyn
işleme
75a29c28af

+ 2 - 0
packages/f/freetype/xmake.lua

@@ -35,6 +35,8 @@ package("freetype")
     add_deps("cmake")
     if is_plat("windows", "mingw") and is_subhost("windows") then
         add_deps("pkgconf")
+    elseif is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
     end
 
     add_includedirs("include/freetype2")

+ 15 - 4
packages/p/pixman/xmake.lua

@@ -3,16 +3,27 @@ package("pixman")
     set_homepage("https://cairographics.org/")
     set_description("Low-level library for pixel manipulation.")
 
-    add_urls("https://cairographics.org/releases/pixman-$(version).tar.gz")
+    add_urls("https://cairographics.org/releases/pixman-$(version).tar.gz", {alias = "cairographics"})
+    add_urls("https://gitlab.freedesktop.org/pixman/pixman/-/archive/pixman-$(version)/pixman-pixman-$(version).tar.gz", {alias = "git_release"})
+    add_urls("https://github.com/freedesktop/pixman/archive/refs/tags/pixman-$(version).tar.gz", {alias = "git_release"})
     add_urls("https://gitlab.freedesktop.org/pixman/pixman.git")
-    add_versions("0.40.0", "6d200dec3740d9ec4ec8d1180e25779c00bc749f94278c8b9021f5534db223fc")
-    add_versions("0.42.2", "ea1480efada2fd948bc75366f7c349e1c96d3297d09a3fe62626e38e234a625e")
+    add_urls("https://github.com/freedesktop/pixman.git")
+    add_versions("git_release:0.40.0", "3a68a28318a78fffc61603c8385bb0010c3fb23d17cd1285d36a7148c87a3b91")
+    add_versions("cairographics:0.40.0", "6d200dec3740d9ec4ec8d1180e25779c00bc749f94278c8b9021f5534db223fc")
+    add_versions("git_release:0.42.0", "45c6462f6d6441923d4c17d06fa50ce066f0ceff0fc84af8d342df63c1079151")
+    add_versions("cairographics:0.42.0", "07f74c8d95e4a43eb2b08578b37f40b7937e6c5b48597b3a0bb2c13a53f46c13")
+    add_versions("git_release:0.42.2", "4191a5084bae000a61e3513b06027b6f8f559d17d61769ed9de27dfb0cec8699")
+    add_versions("cairographics:0.42.2", "ea1480efada2fd948bc75366f7c349e1c96d3297d09a3fe62626e38e234a625e")
+
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
 
     add_deps("meson", "ninja")
 
     add_includedirs("include", "include/pixman-1")
 
-    on_install("macosx", "linux", "windows|x64", "windows|x86", function (package)
+    on_install("macosx", "linux", "windows|x64", "windows|x86", "wasm", function (package)
         local configs = {
             "-Dopenmp=disabled",
             "-Dlibpng=disabled",

+ 4 - 0
packages/r/rapidjson/xmake.lua

@@ -12,6 +12,10 @@ package("rapidjson")
     add_versions("v1.1.0-arrow", "1a803826f1197b5e30703afe4b9c0e7dd48074f5")
 
     on_install(function (package)
+        if package:is_plat("windows") and package:is_arch("arm.*") then
+            package:add("defines", "RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN")
+        end
+
         os.cp(path.join("include", "*"), package:installdir("include"))
     end)
 

+ 12 - 0
packages/r/rlottie/patches/0.2/limit.diff

@@ -0,0 +1,12 @@
+diff --git a/src/vector/vrle.cpp b/src/vector/vrle.cpp
+index c7a520f5..379f8eda 100644
+--- a/src/vector/vrle.cpp
++++ b/src/vector/vrle.cpp
+@@ -27,6 +27,7 @@
+ #include <array>
+ #include <cstdlib>
+ #include <cstring>
++#include <limits>
+ #include <vector>
+ #include "vdebug.h"
+ #include "vglobal.h"

+ 52 - 0
packages/r/rlottie/xmake.lua

@@ -0,0 +1,52 @@
+package("rlottie")
+    set_homepage("https://github.com/Samsung/rlottie")
+    set_description("A platform independent standalone library that plays Lottie Animation. ")
+
+    add_urls("https://github.com/Samsung/rlottie/archive/refs/tags/v$(version).tar.gz",
+             "https://github.com/Samsung/rlottie.git")
+
+    add_versions("0.1", "319d640f094f747e09177df59ca498f0df80c779ba789eeb1fc35da5a1c93414")
+    add_versions("0.2", "030ccbc270f144b4f3519fb3b86e20dd79fb48d5d55e57f950f12bab9b65216a")
+    add_patches("0.2", path.join(os.scriptdir(), "patches", "0.2", "limit.diff"), "6dc1c00c6ccad770586ec9d84f24d6c35e35dd624df877a71bb5c7bcc32831e9")
+    add_configs("module", {description = "Enable LOTTIE MODULE SUPPORT", default = true, type = "boolean"})
+    add_configs("thread", {description = "Enable LOTTIE THREAD SUPPORT", default = true, type = "boolean"})
+    add_configs("cache",  {description = "Enable LOTTIE CACHE SUPPORT", default = true, type = "boolean"})
+    add_configs("ccache", {description = "Enable LOTTIE CCACHE SUPPORT", default = false, type = "boolean"})
+    add_configs("asan",   {description = "Compile with asan", default = false, type = "boolean"})
+
+    if is_plat("wasm") then
+        add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
+    end
+
+    add_deps("cmake")
+    add_deps("freetype", {configs = {zlib = false}})
+    add_deps("rapidjson ~1.1.0", "stb 2019.02.07")
+
+    add_links("rlottie")
+    on_install("windows", "linux", "macosx", "android|arm64*", "wasm", function (package)
+        local configs = {}
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
+        table.insert(configs, "-DLIB_INSTALL_DIR=" .. package:installdir("lib"))
+        for name, enabled in pairs(package:configs()) do
+            if not package:extraconf("configs", name, "builtin") then
+                table.insert(configs, "-DLOTTIE_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
+            end
+        end
+        if package:is_plat("wasm") then
+            io.replace("CMakeLists.txt", "-Wl,--no-undefined", "-Wl", {plain = true})
+        elseif package:is_plat("windows") and not package:config("shared") then
+            io.replace("inc/rlottie.h", "#define RLOTTIE_API __declspec(dllimport)", "#define RLOTTIE_API", {plain = true})
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:check_cxxsnippets({test = [[
+            #include "rlottie.h"
+            using namespace rlottie;
+            void test() {
+                rlottie::Surface surface(nullptr, 100, 100, 0);
+            }
+        ]]}, {configs = {languages = "c++11"}}))
+    end)

+ 4 - 1
packages/s/stb/xmake.lua

@@ -4,6 +4,7 @@ package("stb")
     set_description("single-file public domain (or MIT licensed) libraries for C/C++")
 
     add_urls("https://github.com/nothings/stb.git")
+    add_versions("2019.02.07", "756166e853a1d16a14fbc132384b98512cfce117")
     add_versions("2021.07.13", "3a1174060a7dd4eb652d4e6854bc4cd98c159200")
     add_versions("2021.09.10", "af1a5bc352164740c1cc1354942b1c6b72eacb8a")
     add_versions("2023.01.30", "5736b15f7ea0ffb08dd38af21067c314d6a3aae9")
@@ -23,5 +24,7 @@ package("stb")
 
     on_test(function (package)
         assert(package:has_cfuncs("stbi_load_from_memory", {includes = "stb/stb_image.h"}))
-        assert(package:has_cfuncs("stb_include_string", {includes = "stb/stb_include.h"}))
+        if package:version():gt("2019.02.07") then
+            assert(package:has_cfuncs("stb_include_string", {includes = "stb/stb_include.h"}))
+        end
     end)