improve libhv (#313)
* add pybind11 * add pybind11 * add pybind11 * add nng * update for add nng * update for add nng * update for add nng * update for add nng, remove MingW * update protobuf-cpp * update for protobuf-cpp * add libhv * improve libhv * improve libhv Co-authored-by: fasiondog <fasiondog@163.com>pull/314/head
parent
88c5dfa928
commit
205b709ffd
1 changed files with 75 additions and 0 deletions
@ -0,0 +1,75 @@ |
||||
package("libhv") |
||||
|
||||
set_homepage("https://github.com/ithewei/libhv") |
||||
set_description("Like libevent, libev, and libuv, libhv provides event-loop with non-blocking IO and timer, but simpler api and richer protocols.") |
||||
|
||||
add_urls("https://github.com/ithewei/libhv/archive/v$(version).zip") |
||||
add_versions("1.0.0", "39adb77cc7addaba82b69fa9a433041c8288f3d9c773fa360162e3391dcf6a7b") |
||||
|
||||
add_configs("protocol", {description = "compile protocol", default = false, type = "boolean"}) |
||||
add_configs("http", {description = "compile http", default = true, type = "boolean"}) |
||||
add_configs("http_server", {description = "compile http/server", default = true, type = "boolean"}) |
||||
add_configs("http_client", {description = "compile http/client", default = true, type = "boolean"}) |
||||
add_configs("consul", {description = "compile consul", default = false, type = "boolean"}) |
||||
add_configs("ipv6", {description = "enable ipv6", default = false, type = "boolean"}) |
||||
add_configs("uds", {description = "enable Unix Domain Socket", default = false, type = "boolean"}) |
||||
add_configs("windump", {description = "enable Windows MiniDumpWriteDump", default = false, type = "boolean"}) |
||||
add_configs("multimap", {description = "use MultiMap", default = false, type = "boolean"}) |
||||
add_configs("curl", {description = "with curl library", default = false, type = "boolean"}) |
||||
add_configs("nghttp2", {description = "with nghttp2 library", default = false, type = "boolean"}) |
||||
add_configs("openssl", {description = "with openssl library", default = false, type = "boolean"}) |
||||
add_configs("mbedtls", {description = "with mbedtls library", default = false, type = "boolean"}) |
||||
|
||||
if is_plat("linux") then |
||||
add_syslinks("pthread") |
||||
end |
||||
|
||||
add_deps("cmake") |
||||
|
||||
on_load(function (package) |
||||
if package:config("openssl") then |
||||
package:add("deps", "openssl") |
||||
elseif package:config("mbedtls") then |
||||
package:add("deps", "mbedtls") |
||||
elseif package:config("curl") then |
||||
package:add("deps", "libcurl") |
||||
elseif package:config("nghttp2") then |
||||
-- TODO |
||||
end |
||||
if package:is_plat("windows") and not package:config("shared") then |
||||
package:add("defines", "HV_STATICLIB") |
||||
end |
||||
end) |
||||
|
||||
on_install("windows", "linux", "macosx", "android", "iphoneos", function(package) |
||||
local configs = {"-DBUILD_EXAMPLES=OFF", "-DBUILD_UNITTEST=OFF"} |
||||
table.insert(configs, "-DBUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF")) |
||||
table.insert(configs, "-DBUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON")) |
||||
for _, name in ipairs({"with_protocol", |
||||
"with_http", |
||||
"with_http_server", |
||||
"with_http_client", |
||||
"with_consul", |
||||
"with_curl", |
||||
"with_nghttp2", |
||||
"with_openssl", |
||||
"with_mbedtls", |
||||
"enable_ipv6", |
||||
"enable_uds", |
||||
"enable_windump", |
||||
"use_multimap"}) do |
||||
local config_name = name:gsub("with_", ""):gsub("use_", ""):gsub("enable_", "") |
||||
table.insert(configs, "-D" .. name:upper() .. "=" .. (package:config(config_name) and "ON" or "OFF")) |
||||
end |
||||
local packagedeps = {} |
||||
if package:config("openssl") then |
||||
table.insert(packagedeps, "openssl") |
||||
elseif package:config("mbedtls") then |
||||
table.insert(packagedeps, "mbedtls") |
||||
end |
||||
import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps}) |
||||
end) |
||||
|
||||
on_test(function(package) |
||||
assert(package:has_cfuncs("hloop_new", {includes = "hv/hloop.h"})) |
||||
end) |
Loading…
Reference in new issue