xmake.lua 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. package("libvips")
  2. set_homepage("https://libvips.github.io/libvips/")
  3. set_description("A fast image processing library with low memory needs.")
  4. set_license("LGPL-2.1")
  5. add_urls("https://github.com/libvips/libvips/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/libvips/libvips.git")
  7. add_versions("v8.15.3", "c23a820443241c35e62f1f1f0a1f6c199b37e07d98e3268a7fa9db43309fd67d")
  8. add_versions("v8.15.2", "8c3ece7be367636fd676573a8ff22170c07e95e81fd94f2d1eb9966800522e1f")
  9. add_versions("v8.15.1", "5701445a076465a3402a135d13c0660d909beb8efc4f00fbbe82392e243497f2")
  10. add_patches("8.15.3", "patches/8.15.3/msvc-ssize_t.patch", "1995af657dfd2f4e4f8edec685f67bd473537ff33c42d8329a0df0e0477408b9")
  11. add_configs("c++", { description = "Build C++ API", default = true, type = "boolean" })
  12. add_configs("deprecated", { description = "Build deprecated components", default = false, type = "boolean" })
  13. add_configs("dynamic_modules", { description = "Build dynamic modules", default = false, type = "boolean" })
  14. add_configs("introspection", { description = "Build GObject introspection data", default = false, type = "boolean" })
  15. add_configs("vapi", { description = "Build VAPI", default = false, type = "boolean" })
  16. add_configs("nsgif", { description = "Build with nsgif", default = false, type = "boolean" })
  17. add_configs("ppm", { description = "Build with ppm", default = false, type = "boolean" })
  18. add_configs("analyze", { description = "Build with analyze", default = false, type = "boolean" })
  19. add_configs("radiance", { description = "Build with radiance", default = false, type = "boolean" })
  20. local deps = {
  21. "cfitsio",
  22. "fftw",
  23. "fontconfig",
  24. "libarchive",
  25. "libheif",
  26. "libimagequant",
  27. "libjpeg",
  28. "libjxl",
  29. "lcms",
  30. "imagemagick",
  31. "matio",
  32. "openexr",
  33. "openjpeg",
  34. "poppler",
  35. "libpng",
  36. "libspng",
  37. "libtiff",
  38. "libwebp",
  39. "zlib",
  40. "cgif",
  41. "nifti",
  42. "highway",
  43. }
  44. local unsupported_deps = {
  45. "exif",
  46. "openslide",
  47. "orc",
  48. "pangocairo",
  49. "pdfium",
  50. "quantizr",
  51. "rsvg",
  52. }
  53. for _, dep in ipairs(deps) do
  54. add_configs(dep, { description = "Build with " .. dep, default = false, type = "boolean"})
  55. end
  56. for _, dep in ipairs(unsupported_deps) do
  57. add_configs(dep, { description = "Build with " .. dep, default = false, type = "boolean", readonly = true})
  58. end
  59. add_deps("meson", "ninja")
  60. add_deps("glib", "expat")
  61. if is_plat("windows") then
  62. add_deps("pkgconf")
  63. end
  64. if is_plat("mingw") and is_subhost("msys") then
  65. add_extsources("pacman::libvips")
  66. elseif is_plat("linux") then
  67. add_extsources("apt::libvips", "pacman::libvips")
  68. elseif is_plat("macosx") then
  69. add_extsources("brew::vips")
  70. end
  71. on_load(function (package)
  72. for _, dep in ipairs(deps) do
  73. if package:config(dep) then
  74. package:add("deps", dep)
  75. end
  76. end
  77. end)
  78. on_install("windows", "macosx", "linux", "cross", function (package)
  79. io.replace("meson.build", "subdir('tools')", "", {plain = true})
  80. io.replace("meson.build", "subdir('test')", "", {plain = true})
  81. io.replace("meson.build", "subdir('fuzz')", "", {plain = true})
  82. local configs = {"-Dexamples=false"}
  83. table.insert(configs, "-Ddefault_library=" .. (package:config("shared") and "shared" or "static"))
  84. local configs_map = {
  85. ["c++"] = "cplusplus",
  86. ["dynamic_modules"] = "modules",
  87. ["libarchive"] = "archive",
  88. ["libheif"] = "heif",
  89. ["libimagequant"] = "imagequant",
  90. ["libjpeg"] = "jpeg",
  91. ["libjxl"] = "jpeg-xl",
  92. ["imagemagick"] = "magick",
  93. ["libpng"] = "png",
  94. ["libspng"] = "spng",
  95. ["libtiff"] = "tiff",
  96. ["libwebp"] = "webp",
  97. }
  98. table.join2(deps, unsupported_deps)
  99. -- workaround meson option type
  100. table.insert(deps, "dynamic_modules")
  101. table.insert(deps, "introspection")
  102. for name, enabled in table.orderpairs(package:configs()) do
  103. if not package:extraconf("configs", name, "builtin") then
  104. local enabled_string
  105. if table.contains(deps, name) then
  106. enabled_string = (enabled and "enabled" or "disabled")
  107. else
  108. enabled_string = (enabled and "true" or "false")
  109. end
  110. if configs_map[name] then
  111. name = configs_map[name]
  112. end
  113. table.insert(configs, "-D" .. name .. "=" .. enabled_string)
  114. end
  115. end
  116. import("package.tools.meson").install(package, configs, {
  117. packagedeps = {"libintl", "libiconv"},
  118. prefix = path.unix(package:installdir()) -- after xmake v2.9.1
  119. })
  120. end)
  121. on_test(function (package)
  122. assert(package:has_cfuncs("vips_image_new_from_file", {includes = "vips/vips.h"}))
  123. end)