xmake.lua 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package("libyuv")
  2. set_homepage("https://chromium.googlesource.com/libyuv/libyuv/")
  3. set_description("libyuv is an open source project that includes YUV scaling and conversion functionality.")
  4. set_license("BSD-3-Clause")
  5. add_urls("https://chromium.googlesource.com/libyuv/libyuv.git",
  6. "https://github.com/lemenkov/libyuv.git")
  7. add_urls("https://github.com/lemenkov/libyuv/archive/$(version).tar.gz", {
  8. version = function (version)
  9. -- Versions from LIBYUV_VERSION definition in include/libyuv/version.h
  10. -- Pay attention to package commits incrementing this definition
  11. local table = {
  12. ["1891"] = "611806a1559b92c97961f51c78805d8d9d528c08",
  13. }
  14. return table[tostring(version)]
  15. end})
  16. add_versions("1891", "a8dddc6f45d6987cd3c08e00824792f3c72651fde29f475f572ee2292c03761f")
  17. add_patches("1891", "patches/1891/cmake.patch", "87086566b2180f65ff3d5ef9db7c59a6e51e2592aeeb787e45305beb4cf9d30d")
  18. add_configs("jpeg", {description = "Build with JPEG.", default = false, type = "boolean"})
  19. add_configs("tools", {description = "Build tools", default = false, type = "boolean"})
  20. add_deps("cmake")
  21. if is_plat("linux", "bsd") then
  22. add_syslinks("m")
  23. end
  24. if on_check then
  25. on_check("android", function (package)
  26. local ndk = package:toolchain("ndk"):config("ndkver")
  27. assert(ndk and tonumber(ndk) > 22, "package(libyuv): need ndk version > 22")
  28. end)
  29. end
  30. on_load(function (package)
  31. if package:config("jpeg") then
  32. package:add("deps", "libjpeg")
  33. end
  34. if package:config("shared") then
  35. package:add("defines", "LIBYUV_USING_SHARED_LIBRARY")
  36. end
  37. end)
  38. on_install("!cross", function (package)
  39. if package:is_plat("iphoneos") then
  40. io.replace("CMakeLists.txt",
  41. [[STRING(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" arch_lowercase)]],
  42. [[set(arch_lowercase "]] .. package:arch() .. [[")]], {plain = true})
  43. end
  44. local configs = {"-DCMAKE_CXX_STANDARD=14"}
  45. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  46. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  47. table.insert(configs, "-DLIBYUV_WITH_JPEG=" .. (package:config("jpeg") and "ON" or "OFF"))
  48. table.insert(configs, "-DBUILD_TOOLS=" .. (package:config("tools") and "ON" or "OFF"))
  49. import("package.tools.cmake").install(package, configs)
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cfuncs("I420Rotate", {includes = "libyuv/rotate.h"}))
  53. end)