From fef3b368091466bfce7dda3887226e31746f1fa2 Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 28 Apr 2024 20:05:30 +0800 Subject: [PATCH] lsquic: add package --- packages/l/lsquic/xmake.lua | 47 +++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 packages/l/lsquic/xmake.lua diff --git a/packages/l/lsquic/xmake.lua b/packages/l/lsquic/xmake.lua new file mode 100644 index 000000000..1190c7489 --- /dev/null +++ b/packages/l/lsquic/xmake.lua @@ -0,0 +1,47 @@ +package("lsquic") + set_homepage("https://github.com/litespeedtech/lsquic") + set_description("LiteSpeed QUIC and HTTP/3 Library") + set_license("MIT") + + add_urls("https://github.com/litespeedtech/lsquic/archive/refs/tags/$(version).tar.gz", + "https://github.com/litespeedtech/lsquic.git") + + add_versions("v4.0.8", "f18ff2fa0addc1c51833304b3d3ff0979ecf5f53f54f96bcd3442a40cfcd440b") + + add_deps("cmake") + add_deps("zlib", "boringssl", "ls-qpack", "ls-hpack") + + add_includedirs("include/lsquic") + + on_install("windows|!arm64", "linux", "macosx", function (package) + local opt = {} + opt.packagedeps = {"ls-qpack", "ls-hpack"} + if package:is_plat("windows") then + opt.cxflags = "-DWIN32" + -- https://github.com/litespeedtech/lsquic/issues/433 + package:add("defines", "WIN32", "WIN32_LEAN_AND_MEAN") + end + + io.replace("src/liblsquic/CMakeLists.txt", "ls-qpack/lsqpack.c", "", {plain = true}) + io.replace("src/liblsquic/CMakeLists.txt", "../lshpack/lshpack.c", "", {plain = true}) + io.replace("CMakeLists.txt", "-WX", "", {plain = true}) + + local boringssl_path = package:dep("boringssl"):installdir() + + local configs = { + "-DLSQUIC_BIN=OFF", + "-DLSQUIC_TESTS=OFF", + "-DBORINGSSL_DIR=" .. boringssl_path, + "-DBORINGSSL_LIB=" .. path.join(boringssl_path, "lib"), + } + + table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release")) + table.insert(configs, "-DLSQUIC_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF")) + import("package.tools.cmake").install(package, configs, opt) + + os.vcp("**.dll", package:installdir("bin")) + end) + + on_test(function (package) + assert(package:has_cfuncs("lsquic_global_init", {includes = "lsquic.h"})) + end)