xmake.lua 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("gamenetworkingsockets")
  2. set_homepage("https://github.com/ValveSoftware/GameNetworkingSockets")
  3. set_description("Reliable & unreliable messages over UDP. Robust message fragmentation & reassembly. P2P networking / NAT traversal. Encryption. ")
  4. set_license("BSD-3-Clause")
  5. set_urls("https://github.com/ValveSoftware/GameNetworkingSockets/archive/$(version).tar.gz",
  6. "https://github.com/ValveSoftware/GameNetworkingSockets.git")
  7. add_versions("v1.4.1", "1cfb2bf79c51a08ae4e8b7ff5e9c1266b43cfff6f53ecd3e7bc5e3fcb2a22503")
  8. add_versions("v1.4.0", "eca3b5684dbf81a3a6173741a38aa20d2d0a4d95be05cf88c70e0e50062c407b")
  9. add_versions("v1.3.0", "f473789ae8a8415dd1f5473793775e68a919d27eba18b9ba7d0a14f254afddf9")
  10. add_versions("v1.2.0", "768a7cec2491e34c824204c4858351af2866618ceb13a024336dc1df8076bef3")
  11. if is_plat("windows") then
  12. add_syslinks("ws2_32")
  13. add_defines("_WINDOWS", "WIN32")
  14. else
  15. add_defines("POSIX", "LINUX")
  16. add_syslinks("pthread")
  17. end
  18. on_load("windows", "linux", function(package)
  19. if not package:config("shared") then
  20. package:add("defines", "STEAMNETWORKINGSOCKETS_STATIC_LINK")
  21. package:add("deps", "openssl", "protobuf-cpp")
  22. end
  23. end)
  24. on_install("windows", "linux", function (package)
  25. -- We need copy source codes to the working directory with short path on windows
  26. --
  27. -- Because the target name and source file path of this project are too long,
  28. -- it's absolute path exceeds the windows path length limit.
  29. --
  30. local oldir
  31. if is_host("windows") then
  32. local sourcedir = os.tmpdir() .. ".dir"
  33. os.tryrm(sourcedir)
  34. os.cp(os.curdir(), sourcedir)
  35. oldir = os.cd(sourcedir)
  36. end
  37. local configs = {}
  38. if package:config("shared") then
  39. configs.kind = "shared"
  40. end
  41. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  42. import("package.tools.xmake").install(package, configs)
  43. if oldir then
  44. os.cd(oldir)
  45. end
  46. end)
  47. on_test(function (package)
  48. assert(package:has_cxxfuncs("GameNetworkingSockets_Kill()", {includes = "steam/steamnetworkingsockets.h"}))
  49. end)