2
0

xmake.lua 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package("zlmediakit")
  2. set_homepage("https://github.com/ZLMediaKit/ZLMediaKit")
  3. set_description("WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11")
  4. set_license("MIT")
  5. add_urls("https://github.com/ZLMediaKit/ZLMediaKit.git",
  6. "https://gitee.com/xia-chu/ZLMediaKit.git", {submodules = false})
  7. add_versions("2023.8.26", "895e93cb6aae82f9fd6f19b0980c28062b6b9d2f")
  8. add_configs("c_api", {description = "Enable C API SDK.", default = false, type = "boolean"})
  9. add_configs("c_static_api", {description = "Enable mk_api static lib.", default = false, type = "boolean"})
  10. add_configs("cxx_api", {description = "Enable C++ API SDK.", default = true, type = "boolean"})
  11. add_configs("server_lib", {description = "Enable server as android static library.", default = false, type = "boolean"})
  12. add_configs("asan", {description = "Enable Address Sanitize.", default = false, type = "boolean"})
  13. add_configs("mem_debug", {description = "Enable Memory Debug.", default = false, type = "boolean"})
  14. add_configs("jemalloc", {description = "Enable static linking to the jemalloc library.", default = false, type = "boolean"})
  15. add_configs("ffmpeg", {description = "Enable FFMPEG.", default = false, type = "boolean"})
  16. add_configs("mysql", {description = "Enable MySQL.", default = false, type = "boolean"})
  17. add_configs("x264", {description = "Enable libx264.", default = false, type = "boolean"})
  18. add_configs("faac", {description = "Enable FAAC.", default = false, type = "boolean"})
  19. add_deps("cmake")
  20. add_deps("zltoolkit")
  21. on_install("macosx", "linux", "windows", function (package)
  22. local configdeps = {
  23. c_api = "ENABLE_API",
  24. c_static_api = "ENABLE_API_STATIC_LIB",
  25. cxx_api = "ENABLE_CXX_API",
  26. server_lib = "ENABLE_SERVER_LIB",
  27. asan = "ENABLE_ASAN",
  28. mem_debug = "ENABLE_MEM_DEBUG",
  29. jemalloc = "ENABLE_JEMALLOC_STATIC",
  30. ffmpeg = "ENABLE_FFMPEG",
  31. mysql = "ENABLE_MYSQL",
  32. x264 = "ENABLE_X264",
  33. faac = "ENABLE_FAAC"
  34. }
  35. local configs = {"-DENABLE_TESTS=OFF", "-DUSE_SOLUTION_FOLDERS=OFF", "-DENABLE_SERVER=OFF"}
  36. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  37. for name, item in pairs(configdeps) do
  38. table.insert(configs, "-D" .. item .. "=" .. (package:config(name) and "ON" or "OFF"))
  39. end
  40. io.replace("CMakeLists.txt", "add_subdirectory(3rdpart)", "", {plain = true})
  41. io.replace("srt/CMakeLists.txt", "ZLMediaKit::ToolKit", "", {plain = true})
  42. import("package.tools.cmake").install(package, configs, {packagedeps = {"zltoolkit"}})
  43. if package:config("shared") then
  44. if package:is_plat("windows") then
  45. os.trycp("**.dll", package:installdir("lib"))
  46. os.trycp("**.pdb", package:installdir("lib"))
  47. else
  48. os.trycp("**.so", package:installdir("lib"))
  49. end
  50. else
  51. if package:is_plat("windows") then
  52. os.trycp("**.lib", package:installdir("lib"))
  53. else
  54. os.trycp("**.a", package:installdir("lib"))
  55. end
  56. end
  57. os.cp("src/**.h", package:installdir("include"), {rootdir = "src"})
  58. end)
  59. on_test(function (package)
  60. assert(package:check_cxxsnippets({test = [[
  61. void test() {
  62. using namespace toolkit;
  63. mINI ini;
  64. ini[".dot"] = "dot-value";
  65. }
  66. ]]}, {configs = {languages = "c++11"}, includes = {"Common/config.h"}}))
  67. end)