xmake.lua 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. package("libwebp")
  2. set_homepage("https://chromium.googlesource.com/webm/libwebp/")
  3. set_description("Library to encode and decode images in WebP format.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://github.com/webmproject/libwebp/archive/$(version).tar.gz",
  6. "https://github.com/webmproject/libwebp.git")
  7. add_versions("v1.1.0", "424faab60a14cb92c2a062733b6977b4cc1e875a6398887c5911b3a1a6c56c51")
  8. add_versions("v1.2.0", "d37571723f531e5002667632c94fa18857ed7eb5b0561e3b49e913c3e0b1403e")
  9. add_versions("v1.2.1", "7926985218c9e546069c2013dd93774aac3f012fd275247f82b0c119ec9a3801")
  10. add_versions("v1.2.2", "51e9297aadb7d9eb99129fe0050f53a11fcce38a0848fb2b0389e385ad93695e")
  11. add_versions("v1.2.3", "5e8452bcfe64badadbed5480ea9e86f156fe649f15e765e6059645f0aff73546")
  12. add_versions("v1.2.4", "dfe7bff3390cd4958da11e760b65318f0a48c32913e4d5bc5e8d55abaaa2d32e")
  13. add_versions("v1.3.0", "dc9860d3fe06013266c237959e1416b71c63b36f343aae1d65ea9c94832630e1")
  14. add_patches(">=1.1.0 <1.3.0", path.join(os.scriptdir(), "patches", "0001-fix-dll-export.patch"), "81d92d800dd7b57704a0e4db3b7155184fe8bb6bc0a925a699a8a0868629f60c")
  15. add_configs("anim_utils", {description = "Build animation utilities.", default = false, type = "boolean"})
  16. add_configs("cwebp", {description = "Build the cwebp command line tool.", default = false, type = "boolean"})
  17. add_configs("dwebp", {description = "Build the dwebp command line tool.", default = false, type = "boolean"})
  18. add_configs("gif2webp", {description = "Build the gif2webp conversion tool.", default = false, type = "boolean"})
  19. add_configs("img2webp", {description = "Build the img2webp animation tool.", default = false, type = "boolean"})
  20. add_configs("vwebp", {description = "Build the vwebp viewer tool.", default = false, type = "boolean"})
  21. add_configs("webpinfo", {description = "Build the webpinfo command line tool.", default = false, type = "boolean"})
  22. add_configs("libwebpmux", {description = "Build the libwebpmux library.", default = false, type = "boolean"})
  23. add_configs("webpmux", {description = "Build the webpmux command line tool.", default = false, type = "boolean"})
  24. add_configs("sharpyuv", {description = "Build the sharpyuv library, remove since v1.2.3", default = false, type = "boolean"})
  25. add_configs("extras", {description = "Build extras.", default = false, type = "boolean"})
  26. add_configs("thread", {description = "Enable threading support.", default = true, type = "boolean"})
  27. add_deps("cmake")
  28. if is_plat("macosx") then
  29. add_extsources("brew::webp")
  30. elseif is_plat("linux") then
  31. add_extsources("apt::libwebp-dev", "pacman::libwebp")
  32. end
  33. on_load(function (package)
  34. local links = {"webpdecoder", "webpencoder", "webpdemux"}
  35. if package:config("libwebpmux") then
  36. table.insert(links, "webpmux")
  37. end
  38. table.insert(links, "webp")
  39. if package:config("sharpyuv") or package:version():ge("1.2.3") then
  40. table.insert(links, "sharpyuv")
  41. end
  42. for _, l in ipairs(links) do
  43. if package:version():ge("1.3") then
  44. package:add("links", (package:is_plat("windows") and "lib" or "") .. l)
  45. else
  46. package:add("links", l)
  47. end
  48. end
  49. end)
  50. on_install("linux", "macosx", "windows", "mingw", "bsd", "wasm", function (package)
  51. local configs = {}
  52. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  53. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  54. for name, enabled in pairs(package:configs()) do
  55. if name == "thread" then
  56. if enabled then
  57. package:add("defines", "WEBP_USE_THREAD")
  58. if package:is_plat("linux", "bsd") then
  59. package:add("syslinks", "pthread")
  60. end
  61. end
  62. elseif not package:extraconf("configs", name, "builtin") then
  63. table.insert(configs, "-DWEBP_BUILD_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
  64. end
  65. end
  66. import("package.tools.cmake").install(package, configs)
  67. end)
  68. on_test(function (package)
  69. assert(package:has_cfuncs("WebPGetEncoderVersion", {includes = "webp/encode.h"}))
  70. if package:config("libwebpmux") and package:version():ge("1.2.1") then
  71. assert(package:has_cfuncs("WebPGetMuxVersion", {includes = "webp/mux.h"}))
  72. end
  73. end)