فهرست منبع

add freeimage (#594)

* add apt extsources for openssl

* fix taskflow

* add freeimage

* disable vs2017+x86 build due to internal error
Hoildkv 4 سال پیش
والد
کامیت
70f22d9090

+ 31 - 0
packages/f/freeimage/patches/3.18.0/libjxr.patch

@@ -0,0 +1,31 @@
+diff --git a/Source/LibJXR/image/decode/segdec.c b/Source/LibJXR/image/decode/segdec.c
+--- a/Source/LibJXR/image/decode/segdec.c
++++ b/Source/LibJXR/image/decode/segdec.c
+@@ -62,8 +62,14 @@ static U32 _FORCEINLINE _load4(void* pv)
+     v = ((U16 *) pv)[0];
+     v |= ((U32)((U16 *) pv)[1]) << 16;
+     return _byteswap_ulong(v);
+-#else // _M_IA64
++#elif defined(_MSC_VER)
+     return _byteswap_ulong(*(U32*)pv);
++#else
++    U32 Byte0 = *(U32*)pv & 0x000000FF;
++    U32 Byte1 = *(U32*)pv & 0x0000FF00;
++    U32 Byte2 = *(U32*)pv & 0x00FF0000;
++    U32 Byte3 = *(U32*)pv & 0xFF000000;
++    return (Byte0 << 24) | (Byte1 << 8) | (Byte2 >> 8) | (Byte3 >> 24);
+ #endif // _M_IA64
+ #endif // _BIG__ENDIAN_
+ }
+diff --git a/Source/LibJXR/jxrgluelib/JXRGlueJxr.c b/Source/LibJXR/jxrgluelib/JXRGlueJxr.c
+--- a/Source/LibJXR/jxrgluelib/JXRGlueJxr.c
++++ b/Source/LibJXR/jxrgluelib/JXRGlueJxr.c
+@@ -29,6 +29,8 @@
+ #include <limits.h>
+ #include <JXRGlue.h>
+ 
++#include <stdio.h>
++#include <wchar.h>
+ 
+ static const char szHDPhotoFormat[] = "<dc:format>image/vnd.ms-photo</dc:format>";
+ const U32 IFDEntryTypeSizes[] = { 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8 };

+ 55 - 0
packages/f/freeimage/xmake.lua

@@ -0,0 +1,55 @@
+package("freeimage")
+
+    set_homepage("https://sourceforge.net/projects/freeimage/")
+    set_description("FreeImage is a library project for developers who would like to support popular graphics image formats (PNG, JPEG, TIFF, BMP and others).")
+
+    add_urls("https://sourceforge.net/projects/freeimage/files/Source%20Distribution/$(version).zip", {version = function (version)
+        return version .. "/FreeImage" .. version:gsub("%.", "")
+    end})
+    add_versions("3.18.0", "f41379682f9ada94ea7b34fe86bf9ee00935a3147be41b6569c9605a53e438fd")
+
+    add_patches("3.18.0", path.join(os.scriptdir(), "patches", "3.18.0", "libjxr.patch"), "fddbb9fa736da383f54352dc0ab848d083d9279b66cc6ac53910236144ad75ab")
+
+    on_load("windows", function (package)
+        if not package:config("shared") then
+            package:add("defines", "FREEIMAGE_LIB")
+        end
+    end)
+
+    on_install("windows", "macosx", "linux", function (package)
+        if package:is_plat("windows") and package:is_arch("x86") then
+            local vs = import("core.tool.toolchain").load("msvc"):config("vs")
+            if tonumber(vs) < 2019 then
+                raise("Your compiler is too old to use this library.")
+            end
+        end
+        local sources, includes
+        local content = io.readfile("Makefile.srcs")
+        sources = content:match("SRCS = (.-)\n"):split(" ")
+        includes = content:match("INCLUDE = (.-)\n"):gsub("%-I", ""):split(" ")
+        io.writefile("xmake.lua", format([[
+            add_rules("mode.debug", "mode.release")
+            includes("check_cincludes.lua")
+            target("freeimage")
+                set_kind("$(kind)")
+                set_languages("c++11")
+                add_files({"%s"})
+                add_headerfiles("Source/FreeImage.h", "Source/FreeImageIO.h")
+                set_symbols("hidden")
+                add_includedirs({"%s"})
+                check_cincludes("Z_HAVE_UNISTD_H", "unistd.h")
+                add_defines("OPJ_STATIC", "NO_LCMS", "LIBRAW_NODLL", "DISABLE_PERF_MEASUREMENT")
+                if is_plat("windows") then
+                    add_files("FreeImage.rc")
+                    add_defines("WIN32", "_CRT_SECURE_NO_DEPRECATE")
+                    add_defines(is_kind("static") and "FREEIMAGE_LIB" or "FREEIMAGE_EXPORTS")
+                else
+                    add_defines("__ANSI__")
+                end
+        ]], table.concat(sources, "\",\""), table.concat(includes, "\", \"")))
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("FreeImage_Initialise", {includes = "FreeImage.h"}))
+    end)

+ 0 - 3
packages/o/openssl/fetch.lua

@@ -32,9 +32,6 @@ function main(package, opt)
             result = _find_package_on_windows(package, opt)
         else
             result = package:find_package("openssl", opt)
-            if not result and package:is_plat("linux") then
-                result = package:find_package("apt::libssl-dev", opt)
-            end
         end
         return result or false
     end

+ 4 - 0
packages/o/openssl/xmake.lua

@@ -21,6 +21,10 @@ package("openssl")
         add_syslinks("dl")
     end
 
+    if is_plat("linux") then
+        add_extsources("apt::libssl-dev")
+    end
+
     on_fetch("fetch")
 
     on_load(function (package)

+ 4 - 0
packages/t/taskflow/xmake.lua

@@ -11,6 +11,10 @@ package("taskflow")
     add_versions("v3.1.0", "17b56e23312d20c4ad5cc497b9f42cd0ad4451dbd2df0160a0a692fd16d47143")
     add_versions("v3.0.0", "553c88a6e56e115d29ac1520b8a0fea4557a5fcda1af1427bd3ba454926d03a2")
 
+    if is_plat("linux") then
+        add_syslinks("pthread")
+    end
+
     on_install(function (package)
         os.cp("taskflow", package:installdir("include"))
     end)