xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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.git")
  6. add_versions("v1.4.1", "1cfb2bf79c51a08ae4e8b7ff5e9c1266b43cfff6f53ecd3e7bc5e3fcb2a22503")
  7. add_versions("v1.4.0", "eca3b5684dbf81a3a6173741a38aa20d2d0a4d95be05cf88c70e0e50062c407b")
  8. add_versions("v1.3.0", "f473789ae8a8415dd1f5473793775e68a919d27eba18b9ba7d0a14f254afddf9")
  9. add_versions("v1.2.0", "768a7cec2491e34c824204c4858351af2866618ceb13a024336dc1df8076bef3")
  10. if is_plat("windows") then
  11. add_syslinks("ws2_32")
  12. add_defines("_WINDOWS", "WIN32")
  13. else
  14. add_defines("POSIX", "LINUX")
  15. add_syslinks("pthread")
  16. end
  17. add_configs("webrtc", {description = "Enable p2p.", default = false, type = "boolean"})
  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. if package:config("webrtc") then
  23. package:add("deps", "abseil")
  24. end
  25. end
  26. end)
  27. on_install("windows|x86", "windows|x64", "linux", function (package)
  28. -- We need copy source codes to the working directory with short path on windows
  29. --
  30. -- Because the target name and source file path of this project are too long,
  31. -- it's absolute path exceeds the windows path length limit.
  32. --
  33. local oldir
  34. if is_host("windows") then
  35. local sourcedir = os.tmpdir() .. ".dir"
  36. os.tryrm(sourcedir)
  37. os.cp(os.curdir(), sourcedir)
  38. oldir = os.cd(sourcedir)
  39. end
  40. local configs = {}
  41. if package:config("shared") then
  42. configs.kind = "shared"
  43. end
  44. configs.webrtc = package:config("webrtc")
  45. os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
  46. import("package.tools.xmake").install(package, configs)
  47. if oldir then
  48. os.cd(oldir)
  49. end
  50. end)
  51. on_test(function (package)
  52. assert(package:has_cxxfuncs("GameNetworkingSockets_Kill()", {includes = "steam/steamnetworkingsockets.h"}))
  53. end)