xmake.lua 2.5 KB

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