xmake.lua 2.1 KB

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