xmake.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package("kcp")
  2. set_homepage("https://github.com/skywind3000/kcp")
  3. set_description("A Fast and Reliable ARQ Protocol.")
  4. set_license("MIT")
  5. add_urls("https://github.com/skywind3000/kcp/archive/$(version).tar.gz",
  6. "https://github.com/skywind3000/kcp.git")
  7. add_versions("1.7", "b4d26994d95599ab0c44e1f93002f9fda275094a879d66c192d79d596529199e")
  8. on_install(function (package)
  9. io.writefile("xmake.lua", [[
  10. add_rules("mode.debug", "mode.release")
  11. target("kcp")
  12. set_kind("$(kind)")
  13. if is_kind("shared") and is_plat("windows") then
  14. local funcs = {"ikcp_allocator",
  15. "ikcp_check",
  16. "ikcp_create",
  17. "ikcp_flush",
  18. "ikcp_getconv",
  19. "ikcp_input",
  20. "ikcp_interval",
  21. "ikcp_log",
  22. "ikcp_nodelay",
  23. "ikcp_parse_data",
  24. "ikcp_peeksize",
  25. "ikcp_qprint",
  26. "ikcp_recv",
  27. "ikcp_release",
  28. "ikcp_send",
  29. "ikcp_setmtu",
  30. "ikcp_setoutput",
  31. "ikcp_update",
  32. "ikcp_waitsnd",
  33. "ikcp_wndsize"}
  34. for _, func in ipairs(funcs) do
  35. add_shflags("/export:" .. func)
  36. end
  37. end
  38. add_files("ikcp.c")
  39. add_headerfiles("ikcp.h")
  40. ]])
  41. local configs = {}
  42. if package:config("shared") then
  43. configs.kind = "shared"
  44. end
  45. import("package.tools.xmake").install(package, configs)
  46. end)
  47. on_test(function (package)
  48. assert(package:has_cfuncs("ikcp_create", {includes = "ikcp.h"}))
  49. end)