xmake.lua 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_configs("anim_utils", {description = "Build animation utilities.", default = false, type = "boolean"})
  15. add_configs("cwebp", {description = "Build the cwebp command line tool.", default = false, type = "boolean"})
  16. add_configs("dwebp", {description = "Build the dwebp command line tool.", default = false, type = "boolean"})
  17. add_configs("gif2webp", {description = "Build the gif2webp conversion tool.", default = false, type = "boolean"})
  18. add_configs("img2webp", {description = "Build the img2webp animation tool.", default = false, type = "boolean"})
  19. add_configs("vwebp", {description = "Build the vwebp viewer tool.", default = false, type = "boolean"})
  20. add_configs("webpinfo", {description = "Build the webpinfo command line tool.", default = false, type = "boolean"})
  21. add_configs("libwebpmux", {description = "Build the libwebpmux library.", default = false, type = "boolean"})
  22. add_configs("webpmux", {description = "Build the webpmux command line tool.", default = false, type = "boolean"})
  23. add_configs("sharpyuv", {description = "Build the sharpyuv library, remove since v1.2.3", default = false, type = "boolean"})
  24. add_configs("extras", {description = "Build extras.", default = false, type = "boolean"})
  25. add_configs("thread", {description = "Enable threading support.", default = true, type = "boolean"})
  26. add_deps("cmake")
  27. add_links("webp", "webpdecoder", "webpencoder", "webpdemux")
  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_install("linux", "macosx", "windows", "mingw", "bsd", "wasm", function (package)
  34. local configs = {}
  35. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  36. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  37. if package:config("sharpyuv") or package:version():ge("1.2.3") then
  38. package:add("links", "sharpyuv")
  39. end
  40. for name, enabled in pairs(package:configs()) do
  41. if name == "thread" then
  42. if enabled then
  43. package:add("defines", "WEBP_USE_THREAD")
  44. if package:is_plat("linux", "bsd") then
  45. package:add("syslinks", "pthread")
  46. end
  47. end
  48. elseif not package:extraconf("configs", name, "builtin") then
  49. table.insert(configs, "-DWEBP_BUILD_" .. name:upper() .. "=" .. (enabled and "ON" or "OFF"))
  50. end
  51. end
  52. import("package.tools.cmake").install(package, configs)
  53. end)
  54. on_test(function (package)
  55. assert(package:has_cfuncs("WebPGetEncoderVersion", {includes = "webp/encode.h"}))
  56. end)