Kaynağa Gözat

add poppler and jasper (#370)

* update libraw

* add poppler

* add jasper

* add version detection for jasper

* fix package name inconsistency
Hoildkv 4 yıl önce
ebeveyn
işleme
e138bd65fd

+ 6 - 0
packages/b/brotli/xmake.lua

@@ -58,6 +58,9 @@ package("brotli")
                                 "BROTLIENC_SHARED_COMPILATION",
                                 "BROTLIDEC_SHARED_COMPILATION")
                 end
+                if is_plat("linux") then
+                    add_cxflags("-fvisibility=default")
+                end
                 add_headerfiles("c/include/(brotli/*.h)")
             target("brotlibin")
                 set_kind("binary")
@@ -68,6 +71,9 @@ package("brotli")
         if package:config("shared") then
             configs.kind = "shared"
         end
+        if package:is_plat("linux") and package:config("pic") ~= false then
+            configs.cxflags = "-fPIC"
+        end
         import("package.tools.xmake").install(package, configs)
     end)
 

+ 13 - 1
packages/f/freetype/xmake.lua

@@ -16,6 +16,8 @@ package("freetype")
 
     if not is_plat("windows") then
         add_configs("woff2", {description = "Enable woff2 support.", default = true, type = "boolean"})
+        add_configs("bzip2", {description = "Enable bzip2 support.", default = true, type = "boolean"})
+        add_configs("png", {description = "Enable png support.", default = true, type = "boolean"})
         add_includedirs("include/freetype2")
     end
 
@@ -28,10 +30,16 @@ package("freetype")
     end
 
     on_load("linux", "macosx", function (package)
-        package:add("deps", "libpng", "bzip2", "zlib")
+        package:add("deps", "zlib", "pkg-config")
         if package:config("woff2") then
             package:add("deps", "brotli")
         end
+        if package:config("bzip2") then
+            package:add("deps", "bzip2")
+        end
+        if package:config("png") then
+            package:add("deps", "libpng")
+        end
     end)
 
     on_install("windows", function (package)
@@ -41,10 +49,14 @@ package("freetype")
     end)
 
     on_install("linux", "macosx", function (package)
+        io.gsub("builds/unix/configure", "libbrotlidec", "brotli")
         local configs = { "--enable-freetype-config",
                           "--without-harfbuzz"}
         table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
         table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
+        table.insert(configs, "--with-bzip2=" .. (package:config("bzip2") and "yes" or "no"))
+        table.insert(configs, "--with-brotli=" .. (package:config("woff2") and "yes" or "no"))
+        table.insert(configs, "--with-png=" .. (package:config("png") and "yes" or "no"))
         if package:config("pic") ~= false then
             table.insert(configs, "--with-pic")
         end

+ 36 - 0
packages/j/jasper/xmake.lua

@@ -0,0 +1,36 @@
+package("jasper")
+
+    set_homepage("https://www.ece.uvic.ca/~frodo/jasper/")
+    set_description("Official Repository for the JasPer Image Coding Toolkit")
+    set_license("BSD-2-Clause")
+
+    add_urls("https://github.com/jasper-software/jasper/archive/refs/tags/version-$(version).tar.gz")
+    add_versions("2.0.28", "6b4e5f682be0ab1a5acb0eeb6bf41d6ce17a658bb8e2dbda95de40100939cc88")
+
+    add_deps("cmake", "libjpeg")
+    if not is_plat("macosx") then
+        add_deps("freeglut")
+    end
+    on_install("windows", "macosx", "linux", function (package)
+        io.replace("build/cmake/modules/JasOpenGL.cmake", "find_package(GLUT", "find_package(FreeGLUT", {plain = true})
+        local configs = {"-DJAS_ENABLE_PROGRAMS=OFF", "-DJAS_ENABLE_DOC=OFF"}
+        local vs_sdkver = get_config("vs_sdkver")
+        if vs_sdkver then
+            local build_ver = string.match(vs_sdkver, "%d+%.%d+%.(%d+)%.?%d*")
+            assert(tonumber(build_ver) >= 18362, "Jasper requires Windows SDK to be at least 10.0.18362.0")
+            table.insert(configs, "-DCMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION=" .. vs_sdkver)
+            table.insert(configs, "-DCMAKE_SYSTEM_VERSION=" .. vs_sdkver)
+        end
+        table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
+        table.insert(configs, "-DJAS_ENABLE_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+
+        -- warning: only works on windows sdk 10.0.18362.0 and later
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("jas_image_decode", {includes = "jasper/jasper.h"}))
+    end)

+ 10 - 3
packages/l/libraw/xmake.lua

@@ -1,10 +1,11 @@
 package("libraw")
     set_homepage("http://www.libraw.org")
     set_description("LibRaw is a library for reading RAW files from digital cameras.")
+    set_license("LGPL-2.1")
 
     add_urls("https://github.com/LibRaw/LibRaw/archive/$(version).tar.gz")
     add_urls("https://github.com/LibRaw/LibRaw.git")
-
+    add_versions("0.20.2", "dc1b486c2003435733043e4e05273477326e51c3ea554c6864a4eafaff1004a6")
     add_versions("0.19.5", "9a2a40418e4fb0ab908f6d384ff6f9075f4431f8e3d79a0e44e5a6ea9e75abdc")
 
     if is_plat("windows", "mingw") then
@@ -20,7 +21,7 @@ package("libraw")
         end
     end)
 
-    on_install("macosx", "linux", "windows", "mingw", "iphoneos", function(package)
+    on_install("macosx", "linux", "windows", "mingw@windows", "iphoneos", function(package)
         io.writefile("xmake.lua", [[
             target("libraw")
                 set_kind("$(kind)")
@@ -32,6 +33,9 @@ package("libraw")
                 if is_plat("windows") then
                     add_defines("WIN32")
                 end
+                if is_plat("windows") or is_plat("mingw") then
+                    add_syslinks("ws2_32")
+                end
                 add_headerfiles("(libraw/*.h)")
                 add_includedirs(".")
                 add_files("src/libraw_cxx.cpp", "src/libraw_datastream.cpp", "src/libraw_c_api.cpp")
@@ -39,7 +43,10 @@ package("libraw")
         ]])
         local configs = {}
         if package:config("shared") then
-            table.insert(configs, "--kind=shared")
+            configs.kind = "shared"
+        end
+        if package:is_plat("linux") and package:config("pic") then
+            configs.cxflags = "-fPIC"
         end
         import("package.tools.xmake").install(package, configs)
     end)

+ 43 - 0
packages/p/poppler/xmake.lua

@@ -0,0 +1,43 @@
+package("poppler")
+
+    set_homepage("https://poppler.freedesktop.org/")
+    set_description("Poppler, a PDF rendering library")
+    set_license("GPL-2.0")
+
+    add_urls("https://poppler.freedesktop.org/poppler-$(version).tar.xz")
+    add_versions("21.03.0", "fd51ead4aac1d2f4684fa6e7b0ec06f0233ed21667e720a4e817e4455dd63d27")
+
+    local libnames = {"splash", "glib", "qt5", "qt6"}
+    for _, libname in ipairs(libnames) do
+        add_configs(libname, {description = "Enable " .. libname .. " for use.", default = (libname == "splash"), type = "boolean"})
+    end
+
+    add_deps("cmake")
+    add_deps("libtiff", "openjpeg", "lcms", "libjpeg", "libpng", "bzip2", "zlib")
+    add_deps("freetype", {configs = {woff2 = false, png = false, bzip2 = false}})
+    if is_plat("linux") then
+        add_deps("fontconfig", "expat")
+    end
+
+    add_includedirs("include")
+    add_includedirs("include/poppler")
+
+    on_install("windows", "macosx", "linux", function (package)
+        io.replace("CMakeLists.txt", "if(MSVC)\n", "if(MSVC)\nadd_definitions(-D_BASETSD_H)\n", {plain = true})
+        io.replace("CMakeLists.txt", "add_subdirectory(test)", "", {plain = true})
+        io.replace("CMakeLists.txt", "set(ENABLE_LIBPNG ON)\n", "set(ENABLE_LIBPNG ON)\ninclude_directories(SYSTEM ${PNG_INCLUDE_DIRS})\n", {plain = true})
+        local configs = {"-DENABLE_UNSTABLE_API_ABI_HEADERS=ON", "-DBUILD_GTK_TESTS=OFF", "-DBUILD_QT5_TESTS=OFF", "-DBUILD_QT6_TESTS=OFF", "-DBUILD_CPP_TESTS=OFF", "-DENABLE_CPP=OFF", "-DENABLE_UTILS=OFF"}
+        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"))
+        for _, libname in ipairs(libnames) do
+            table.insert(configs, "-DENABLE_" .. libname:upper() .. "=" .. (package:config(libname) and "ON" or "OFF"))
+        end
+        if package:config("pic") ~= false then
+            table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
+        end
+        import("package.tools.cmake").install(package, configs)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cxxtypes("PDFDocBuilder", {configs = {languages = "c++11"}, includes = "PDFDocBuilder.h"}))
+    end)