Преглед на файлове

lsquic: add package (#3898)

* lsquic: add package

* fix cmake find library

* fix hidden symbol refer in dso

* improve cp dll

* Update xmake.lua

* try pic

* Revert "try pic"

This reverts commit f796cb5bb395cd2ed0cc6383ad599b4914decf38.
star9029 преди 1 година
родител
ревизия
3b0d9258f4
променени са 2 файла, в които са добавени 61 реда и са изтрити 0 реда
  1. 2 0
      packages/l/ls-hpack/xmake.lua
  2. 59 0
      packages/l/lsquic/xmake.lua

+ 2 - 0
packages/l/ls-hpack/xmake.lua

@@ -14,6 +14,8 @@ package("ls-hpack")
         io.writefile("xmake.lua", [[
             add_rules("mode.debug", "mode.release")
 
+            set_symbols("none")
+
             add_requires("xxhash")
             add_packages("xxhash")
 

+ 59 - 0
packages/l/lsquic/xmake.lua

@@ -0,0 +1,59 @@
+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_configs("fiu", {description = "Use Fault Injection in Userspace (FIU)", default = false, type = "boolean"})
+
+    add_deps("cmake")
+    add_deps("zlib", "boringssl", "ls-qpack", "ls-hpack")
+
+    add_includedirs("include/lsquic")
+
+    on_load("windows", function (package)
+        if not package:is_precompiled() then
+            package:add("deps", "strawberry-perl")
+        end
+    end)
+
+    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 = package:dep("boringssl")
+        io.replace("CMakeLists.txt",
+            "lib${LIB_NAME}${LIB_SUFFIX}",
+            "lib${LIB_NAME}" .. (boringssl:config("shared") and ".so" or ".a"), {plain = true})
+
+        local configs = {
+            "-DLSQUIC_BIN=OFF",
+            "-DLSQUIC_TESTS=OFF",
+            "-DBORINGSSL_DIR=" .. boringssl:installdir(),
+            "-DBORINGSSL_LIB=" .. boringssl:installdir("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"))
+        table.insert(configs, "-DLSQUIC_FIU=" .. (package:config("fiu") and "ON" or "OFF"))
+        import("package.tools.cmake").install(package, configs, opt)
+
+        os.vcp(path.join(package:buildir(), "**.dll"), package:installdir("bin"))
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("lsquic_global_init", {includes = "lsquic.h"}))
+    end)