xmake.lua 2.7 KB

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