Browse Source

libvips: add package (#3466)

* libvips: add package

* remove tools, test. fuzz

* add packagedeps

* add more configs, improve windows build

* add more configs

* fix macosx frameworks, disable unsupported deps

* add missing config, fix glib missing syslinks

* add v8.15.2

* use https://github.com/xmake-io/xmake/pull/4987

* use https://github.com/xmake-io/xmake/pull/4990
star9029 1 năm trước cách đây
mục cha
commit
ee1035b0aa
2 tập tin đã thay đổi với 144 bổ sung3 xóa
  1. 5 3
      packages/g/glib/xmake.lua
  2. 139 0
      packages/l/libvips/xmake.lua

+ 5 - 3
packages/g/glib/xmake.lua

@@ -20,15 +20,17 @@ package("glib")
         add_deps("libiconv", {system = true})
         add_deps("libintl")
     elseif is_plat("windows") then
-        add_deps("libintl")
+        add_deps("libintl", "pkgconf")
     end
 
     add_includedirs("include/glib-2.0", "lib/glib-2.0/include")
     add_links("gio-2.0", "gobject-2.0", "gthread-2.0", "gmodule-2.0", "glib-2.0")
+
     if is_plat("windows") then
-        add_syslinks("user32", "shell32", "ole32", "ws2_32", "shlwapi")
+        add_syslinks("user32", "shell32", "ole32", "ws2_32", "shlwapi", "iphlpapi", "dnsapi")
     elseif is_plat("macosx") then
-        add_frameworks("Foundation", "CoreFoundation")
+        add_syslinks("resolv")
+        add_frameworks("AppKit", "Foundation", "CoreServices", "CoreFoundation")
         add_extsources("brew::glib")
     elseif is_plat("linux") then
         add_syslinks("pthread", "dl", "resolv")

+ 139 - 0
packages/l/libvips/xmake.lua

@@ -0,0 +1,139 @@
+package("libvips")
+    set_homepage("https://libvips.github.io/libvips/")
+    set_description("A fast image processing library with low memory needs.")
+    set_license("LGPL-2.1")
+
+    add_urls("https://github.com/libvips/libvips/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/libvips/libvips.git")
+
+    add_versions("v8.15.2", "8c3ece7be367636fd676573a8ff22170c07e95e81fd94f2d1eb9966800522e1f")
+    add_versions("v8.15.1", "5701445a076465a3402a135d13c0660d909beb8efc4f00fbbe82392e243497f2")
+
+    add_configs("c++", { description = "Build C++ API", default = true, type = "boolean" })
+    add_configs("deprecated", { description = "Build deprecated components", default = false, type = "boolean" })
+    add_configs("dynamic_modules", { description = "Build dynamic modules", default = false, type = "boolean" })
+    add_configs("introspection", { description = "Build GObject introspection data", default = false, type = "boolean" })
+    add_configs("vapi", { description = "Build VAPI", default = false, type = "boolean" })
+
+    add_configs("nsgif", { description = "Build with nsgif", default = false, type = "boolean" })
+    add_configs("ppm", { description = "Build with ppm", default = false, type = "boolean" })
+    add_configs("analyze", { description = "Build with analyze", default = false, type = "boolean" })
+    add_configs("radiance", { description = "Build with radiance", default = false, type = "boolean" })
+
+    local deps = {
+        "cfitsio",
+        "fftw",
+        "fontconfig",
+        "libarchive",
+        "libheif",
+        "libimagequant",
+        "libjpeg",
+        "libjxl",
+        "lcms",
+        "imagemagick",
+        "matio",
+        "openexr",
+        "openjpeg",
+        "poppler",
+        "libpng",
+        "libspng",
+        "libtiff",
+        "libwebp",
+        "zlib",
+    }
+
+    local unsupported_deps = {
+        "cgif",
+        "exif",
+        "nifti",
+        "openslide",
+        "highway",
+        "orc",
+        "pangocairo",
+        "pdfium",
+        "quantizr",
+        "rsvg",
+    }
+
+    for _, dep in ipairs(deps) do
+        add_configs(dep, { description = "Build with " .. dep, default = false, type = "boolean"})
+    end
+
+    for _, dep in ipairs(unsupported_deps) do
+        add_configs(dep, { description = "Build with " .. dep, default = false, type = "boolean", readonly = true})
+    end
+
+    add_deps("meson", "ninja")
+    add_deps("glib", "expat")
+    if is_plat("windows") then
+        add_deps("pkgconf")
+    end
+
+    if is_plat("mingw") and is_subhost("msys") then
+        add_extsources("pacman::libvips")
+    elseif is_plat("linux") then
+        add_extsources("apt::libvips", "pacman::libvips")
+    elseif is_plat("macosx") then
+        add_extsources("brew::vips")
+    end
+
+    on_load(function (package)
+        for _, dep in ipairs(deps) do
+            if package:config(dep) then
+                package:add("deps", dep)
+            end
+        end
+    end)
+
+    on_install("windows", "macosx", "linux", "cross", function (package)
+        io.replace("meson.build", "subdir('tools')", "", {plain = true})
+        io.replace("meson.build", "subdir('test')", "", {plain = true})
+        io.replace("meson.build", "subdir('fuzz')", "", {plain = true})
+
+        local configs = {"-Dexamples=false"}
+        table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
+
+        local configs_map = {
+            ["c++"] = "cplusplus",
+            ["dynamic_modules"] = "modules",
+            ["libarchive"] = "archive",
+            ["libheif"] = "heif",
+            ["libimagequant"] = "imagequant",
+            ["libjpeg"] = "jpeg",
+            ["libjxl"] = "jpeg-xl",
+            ["imagemagick"] = "magick",
+            ["libpng"] = "png",
+            ["libspng"] = "spng",
+            ["libtiff"] = "tiff",
+            ["libwebp"] = "webp",
+        }
+
+        table.join2(deps, unsupported_deps)
+        -- workaround meson option type
+        table.insert(deps, "dynamic_modules")
+        table.insert(deps, "introspection")
+        for name, enabled in table.orderpairs(package:configs()) do
+            if not package:extraconf("configs", name, "builtin") then
+                local enabled_string
+                if table.contains(deps, name) then
+                    enabled_string = (enabled and "enabled" or "disabled")
+                else
+                    enabled_string = (enabled and "true" or "false")
+                end
+
+                if configs_map[name] then
+                    name = configs_map[name]
+                end
+                table.insert(configs, "-D" .. name .. "=" .. enabled_string)
+            end
+        end
+
+        import("package.tools.meson").install(package, configs, {
+            packagedeps = {"libintl", "libiconv"},
+            prefix = path.unix(package:installdir()) -- after xmake v2.9.1
+        })
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("vips_image_new_from_file", {includes = "vips/vips.h"}))
+    end)