xmake.lua 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package("lsquic")
  2. set_homepage("https://github.com/litespeedtech/lsquic")
  3. set_description("LiteSpeed QUIC and HTTP/3 Library")
  4. set_license("MIT")
  5. add_urls("https://github.com/litespeedtech/lsquic/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/litespeedtech/lsquic.git")
  7. add_versions("v4.0.11", "b1c46951c1fc524a96923f4e380cb9fc6cc20bb8a8a41779351bcad6dcbe6e16")
  8. add_versions("v4.0.9", "bebb6e687138368d89ff3f67768692ac55b06925d63b011d000ce134b6ec98f1")
  9. add_versions("v4.0.8", "f18ff2fa0addc1c51833304b3d3ff0979ecf5f53f54f96bcd3442a40cfcd440b")
  10. add_patches(">=4.0.8", "patches/4.0.8/cmake.patch", "c9b8412fbd7df511dee4d57ea5dfa50bc527e015fc808270235b91abfd9baa89")
  11. add_configs("fiu", {description = "Use Fault Injection in Userspace (FIU)", default = false, type = "boolean"})
  12. add_deps("cmake")
  13. add_deps("zlib", "boringssl", "ls-qpack", "ls-hpack")
  14. add_includedirs("include/lsquic")
  15. on_load("windows", function (package)
  16. if not package:is_precompiled() then
  17. package:add("deps", "strawberry-perl")
  18. end
  19. end)
  20. on_install("windows|!arm64", "linux", "macosx", function (package)
  21. local opt = {}
  22. opt.packagedeps = {"ls-qpack", "ls-hpack"}
  23. if package:is_plat("windows") then
  24. opt.cxflags = "-DWIN32"
  25. -- https://github.com/litespeedtech/lsquic/issues/433
  26. package:add("defines", "WIN32", "WIN32_LEAN_AND_MEAN")
  27. end
  28. io.replace("CMakeLists.txt", "-WX", "", {plain = true})
  29. local boringssl = package:dep("boringssl")
  30. io.replace("CMakeLists.txt",
  31. "lib${LIB_NAME}${LIB_SUFFIX}",
  32. "lib${LIB_NAME}" .. (boringssl:config("shared") and ".so" or ".a"), {plain = true})
  33. local configs = {
  34. "-DLSQUIC_BIN=OFF",
  35. "-DLSQUIC_TESTS=OFF",
  36. "-DBORINGSSL_DIR=" .. boringssl:installdir(),
  37. "-DBORINGSSL_LIB=" .. boringssl:installdir("lib"),
  38. }
  39. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  40. table.insert(configs, "-DLSQUIC_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
  41. table.insert(configs, "-DLSQUIC_FIU=" .. (package:config("fiu") and "ON" or "OFF"))
  42. if package:is_plat("windows") then
  43. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  44. end
  45. import("package.tools.cmake").install(package, configs, opt)
  46. end)
  47. on_test(function (package)
  48. assert(package:has_cfuncs("lsquic_global_init", {includes = "lsquic.h"}))
  49. end)