Sfoglia il codice sorgente

Update nghttp3 to 1.3.0 (#4037)

* Update nghttp3 to 1.3.0

* Update xmake.lua

* vendor sfparse

* Update xmake.lua

* improve sfparse includedirs

* fix shared

* Revert "fix shared"

This reverts commit be07f5ec329b601ab78474da734ec0a4d2640a7e.

* Revert "improve sfparse includedirs"

This reverts commit 6248342ec5e029659817f9793d6464e6a9313d32.

* fix link on linux

---------

Co-authored-by: star9029 <[email protected]>
c8ef 1 anno fa
parent
commit
f2ccd0ecd9

+ 26 - 0
packages/n/nghttp3/patches/vendor.patch

@@ -0,0 +1,26 @@
+diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
+index 2f7e31c..3e3d7fb 100644
+--- a/lib/CMakeLists.txt
++++ b/lib/CMakeLists.txt
+@@ -60,12 +60,12 @@ set(nghttp3_SOURCES
+   nghttp3_opl.c
+   nghttp3_objalloc.c
+   nghttp3_unreachable.c
+-  sfparse/sfparse.c
+ )
+ 
+ # Public shared library
+ if(ENABLE_SHARED_LIB)
+   add_library(nghttp3 SHARED ${nghttp3_SOURCES})
++  target_link_libraries(nghttp3 sfparse)
+   set_target_properties(nghttp3 PROPERTIES
+     COMPILE_FLAGS "${WARNCFLAGS}"
+     VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}
+@@ -81,6 +81,7 @@ endif()
+ if(ENABLE_STATIC_LIB)
+   # Public static library
+   add_library(nghttp3_static STATIC ${nghttp3_SOURCES})
++  target_link_libraries(nghttp3_static sfparse)
+   set_target_properties(nghttp3_static PROPERTIES
+     COMPILE_FLAGS "${WARNCFLAGS}"
+     VERSION ${LT_VERSION} SOVERSION ${LT_SOVERSION}

+ 9 - 5
packages/n/nghttp3/xmake.lua

@@ -3,10 +3,14 @@ package("nghttp3")
     set_description("HTTP/3 library written in C")
     set_license("MIT")
 
-    add_urls("https://github.com/ngtcp2/nghttp3.git")
-    add_versions("2022.02.08", "98402fb68fffc0ab1b211a5f07c1425dfd42d217")
+    add_urls("https://github.com/ngtcp2/nghttp3/archive/refs/tags/$(version).tar.gz",
+             "https://github.com/ngtcp2/nghttp3.git")
 
-    add_deps("cmake")
+    add_versions("v1.3.0", "a83c6a4f589ae777a5f967652969d99b3399a85971340b8de9bed79119a11f88")
+
+    add_patches("v1.3.0", "patches/vendor.patch", "51ab785328270b8df854283a8c20403c09813b0586eb84702a9c20241ff14980")
+
+    add_deps("cmake", "sfparse")
 
     on_load("windows", function (package)
         if not package:config("shared") then
@@ -15,14 +19,14 @@ package("nghttp3")
     end)
 
     on_install("windows", "macosx", "linux", function (package)
-        local configs = {"-DENABLE_LIB_ONLY=ON"}
+        local configs = {"-DENABLE_LIB_ONLY=ON", "-DBUILD_TESTING=OFF"}
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
         table.insert(configs, "-DENABLE_SHARED_LIB=" .. (package:config("shared") and "ON" or "OFF"))
         table.insert(configs, "-DENABLE_STATIC_LIB=" .. (package:config("shared") and "OFF" or "ON"))
         if package:is_plat("windows") then
             table.insert(configs, "-DENABLE_STATIC_CRT=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
         end
-        import("package.tools.cmake").install(package, configs)
+        import("package.tools.cmake").install(package, configs, {packagedeps = "sfparse"})
     end)
 
     on_test(function (package)

+ 27 - 0
packages/s/sfparse/xmake.lua

@@ -0,0 +1,27 @@
+package("sfparse")
+    set_homepage("https://github.com/ngtcp2/sfparse")
+    set_description("Structured Field Values parser")
+    set_license("MIT")
+
+    set_urls("https://github.com/ngtcp2/sfparse.git", {submodules = false})
+    add_versions("2024.05.12", "c669673012f9d535ec3bcf679fe911c8c75a479f")
+
+    add_includedirs("include", "include/sfparse")
+
+    on_install(function (package)
+        io.writefile("xmake.lua", [[
+            add_rules("mode.debug", "mode.release")
+            target("sfparse")
+                set_kind("$(kind)")
+                add_files("sfparse.c")
+                add_headerfiles("sfparse.h", {prefixdir = "sfparse"})
+                if is_plat("windows") and is_kind("shared") then
+                    add_rules("utils.symbols.export_all")
+                end
+        ]])
+        import("package.tools.xmake").install(package)
+    end)
+
+    on_test(function (package)
+        assert(package:has_cfuncs("sf_parser_param", {includes = "sfparse.h"}))
+    end)