Просмотр исходного кода

upgrade HP-Socket and fix zlib dependent (#557)

* upgrade HP-Socket and fix zlib dependent

* merging HP-Socket port scripts and fix llhttp dependent

* fix HP-Socket llhttp dependent on static
commrson 4 лет назад
Родитель
Сommit
91cd9aa7d6
2 измененных файлов с 44 добавлено и 18 удалено
  1. 40 7
      packages/h/hpsocket/port/xmake.lua
  2. 4 11
      packages/h/hpsocket/xmake.lua

+ 40 - 7
packages/h/hpsocket/port/xmake.lua

@@ -1,10 +1,12 @@
 local dep_packages = {}
 local options = {{name = "udp",    package = "kcp"},
                  {name = "http",   package = "http_parser"},
-                 {name = "zlib",   package = is_plat("android") and "" or "zlib"},
+                 {name = "zlib",   package = is_plat("android", "windows") and "" or "zlib"},
                  {name = "brotli", package = "brotli"},
                  {name = "ssl",    package = ""},
                  {name = "iconv",  package = ""}}
+local winCommonSrcPath = (get_config("hpversion") == "v5.7.3") and "Windows/Common/Src/" or "Windows/Src/Common/"
+local winBuiltinDependentLibPath = (get_config("hpversion") == "v5.7.3") and "Windows/Common/Lib/" or "Windows/Dependent/"
 
 for _, opt in ipairs(options) do
     local opt_name = "no_" .. opt.name
@@ -36,8 +38,27 @@ option("unicode")
     set_description("Build hpsocket with unicode character set")
 option_end()
 
+option("hpversion")
+    set_default("v5.8.4")
+    set_showmenu(true)
+    set_values("v5.7.3", "v5.8.4")
+    set_category("option")
+    set_description("The version of HP-Socket")
+option_end()
+
 add_rules("mode.debug", "mode.release")
 target("hpsocket")
+    before_build(function (target)
+        if is_plat("windows") then
+            io.writefile("stdafx.h", [[
+                #pragma once
+                #include "]] .. winCommonSrcPath .. [[GeneralHelper.h"
+            ]])
+            io.writefile("stdafx.cpp", [[
+                #include "stdafx.h"
+            ]])
+        end
+    end)
     set_kind("$(kind)")
 
     for _, opt in ipairs(options) do
@@ -68,14 +89,15 @@ target("hpsocket")
         end
     end
 
-    local linkdir
     if is_plat("windows") then
         if has_config("unicode") then
             add_defines("UNICODE", "_UNICODE")
         end
+        
         set_pcxxheader("stdafx.h")
         add_files("stdafx.cpp")
-        add_files("Windows/Common/Src/*.cpp")
+        add_files(path.join(winCommonSrcPath, "http/*.c"))
+        add_files(path.join(winCommonSrcPath, "*.cpp"))
         add_files("Windows/Src/*.cpp|" .. exclude_file)
         add_headerfiles("Windows/Include/HPSocket/*.h|" .. exclude_file)
         add_defines(is_kind("shared") and "HPSOCKET_EXPORTS" or "HPSOCKET_STATIC_LIB")
@@ -88,19 +110,30 @@ target("hpsocket")
         end
 
         add_includedirs(".")
-        add_includedirs(path.join("Windows/Common/Lib/openssl", vs_ver, "$(arch)", "include"))
-        linkdir = path.join("Windows/Common/Lib/openssl", vs_ver, "$(arch)", "lib")
-        add_linkdirs(linkdir)
+        add_includedirs(path.join(winBuiltinDependentLibPath, "openssl", vs_ver, "$(arch)", "include"))
+        ssllinkdir = path.join(winBuiltinDependentLibPath, "openssl", vs_ver, "$(arch)", "lib")
+        add_linkdirs(ssllinkdir)
+        add_includedirs(path.join(winBuiltinDependentLibPath, "zlib", vs_ver, "$(arch)", "include"))
+        zliblinkdir = path.join(winBuiltinDependentLibPath, "zlib", vs_ver, "$(arch)", "lib")
+        add_linkdirs(zliblinkdir)
 
         if not has_config("no_ssl") then
             add_links("libssl", "libcrypto")
             if is_kind("static") then
-                table.insert(install_files, path.join(linkdir, "*.lib"))
+                table.insert(install_files, path.join(ssllinkdir, "*.lib"))
+            end
+        end
+        
+        if not has_config("no_zlib") then
+            add_links("zlib")
+            if is_kind("static") then
+                table.insert(install_files, path.join(zliblinkdir, "*.lib"))
             end
         end
     elseif is_plat("linux", "android") then
         add_cxflags("-fpic", {force = true})
         add_files("Linux/src/common/crypto/*.cpp")
+        add_files("Linux/src/common/http/*.c")
         add_files("Linux/src/common/*.cpp")
         add_files("Linux/src/*.cpp|" .. exclude_file)
         add_headerfiles("Linux/include/hpsocket/*.h|" .. exclude_file)

+ 4 - 11
packages/h/hpsocket/xmake.lua

@@ -6,11 +6,12 @@ package("hpsocket")
     add_urls("https://github.com/ldcsaa/HP-Socket/archive/$(version).tar.gz",
              "https://github.com/ldcsaa/HP-Socket.git")
 
-    add_versions("v5.7.3", "b3f77120f94b0e85cabce3c184b8163c62aec42562c3b44beff61fd4d3aa4784")
+    add_versions("v5.7.3", "e653f3c15ded3a4b622ab9a4a52a477c7aa40f5b86398c6b75f5a732a55496a0")
+    add_versions("v5.8.4", "21c4fa70c5619074c41d3065261de1828ec521dcb6eeec9d0640e93e67ae05a4")
 
     local configs = {{name = "udp",    package = "kcp"},
                      {name = "http",   package = "http_parser"},
-                     {name = "zlib",   package = is_plat("android") and "" or "zlib"},
+                     {name = "zlib",   package = is_plat("android", "windows") and "" or "zlib"},
                      {name = "brotli", package = "brotli"},
                      {name = "ssl",    package = ""},
                      {name = "iconv",  package = ""}}
@@ -69,18 +70,10 @@ package("hpsocket")
     end)
 
     on_install("windows", "linux", "android", function (package)
-        if package:is_plat("windows") then
-            io.writefile("stdafx.h", [[
-                #pragma once
-                #include "Windows/Common/Src/GeneralHelper.h"
-            ]])
-            io.writefile("stdafx.cpp", [[
-                #include "stdafx.h"
-            ]])
-        end
         os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
 
         local config = {}
+        config.hpversion = package:version()
         config.no_4c = package:config("no_4c")
         config.unicode = package:config("unicode")
         for _, cfg in ipairs(configs) do