2
0

xmake.lua 4.9 KB

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