xmake.lua 5.6 KB

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