* uSockets

* clean code

* limit plat

* add optional deps

* fix windows shared

* add readonly optional dep

* fix missing defines

* Update xmake.lua

---------

Co-authored-by: star9029 <hengxings783@gmail.com>
pull/3890/head
HapiFive 7 months ago committed by GitHub
parent a2b60e5096
commit 07715fbb15
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 49
      packages/u/usockets/port/xmake.lua
  2. 63
      packages/u/usockets/xmake.lua

@ -0,0 +1,49 @@
option("ssl", {default = nil, type = "string"})
option("uv", {showmenu = true, default = false})
option("uring", {showmenu = true, default = false})
option("quic", {showmenu = true, default = false})
add_rules("mode.debug", "mode.release")
local ssl = get_config("ssl")
if ssl then
add_requires(ssl)
add_packages(ssl)
if ssl == "openssl" or ssl == "boringssl" then
add_defines("LIBUS_USE_OPENSSL")
elseif ssl == "wolfssl" then
add_defines("LIBUS_USE_WOLFSSL")
end
else
add_defines("LIBUS_NO_SSL")
end
if is_plat("windows") or has_config("uv") then
add_requires("libuv")
add_packages("libuv")
add_defines("LIBUS_USE_LIBUV")
end
if is_plat("linux") and has_config("uring") then
add_requires("liburing")
add_packages("liburing")
add_defines("LIBUS_USE_IO_URING")
end
if has_config("quic") then
add_requires("lsquic")
add_packages("lsquic")
add_defines("LIBUS_USE_QUIC")
end
target("usockets")
set_kind("$(kind)")
set_languages("c++17")
add_files("src/**.cpp", "src/**.c")
add_includedirs("src")
add_headerfiles("src/libusockets.h")
if is_plat("windows") and is_kind("shared") then
add_rules("utils.symbols.export_all", {export_classes = true})
end

@ -0,0 +1,63 @@
package("usockets")
set_homepage("https://github.com/uNetworking")
set_description("µSockets is the non-blocking, thread-per-CPU foundation library used by µWebSockets. It provides optimized networking - using the same opaque API (programming interface) across all supported transports, event-loops and platforms.")
set_license("Apache-2.0")
add_urls("https://github.com/uNetworking/uSockets/archive/refs/tags/$(version).tar.gz",
"https://github.com/uNetworking/uSockets.git")
add_versions("v0.8.8", "d14d2efe1df767dbebfb8d6f5b52aa952faf66b30c822fbe464debaa0c5c0b17")
add_configs("ssl", {description = "Select ssl library", default = nil, type = "string", values = {"openssl", "wolfssl", "boringssl"}})
add_configs("uv", {description = "Enable libuv", default = false, type = "boolean"})
add_configs("uring", {description = "Enable liburing", default = false, type = "boolean"})
add_configs("quic", {description = "Enable lsquic", default = false, type = "boolean", readonly = true})
on_load(function (package)
local ssl = package:config("ssl")
if ssl then
package:add("deps", ssl)
if ssl == "openssl" or ssl == "boringssl" then
package:add("defines", "LIBUS_USE_OPENSSL")
elseif ssl == "wolfssl" then
package:add("defines", "LIBUS_USE_WOLFSSL")
end
else
package:add("defines", "LIBUS_NO_SSL")
end
if package:is_plat("windows") then
package:add("deps", "libuv")
package:config_set("uv", true)
else
if package:config("libuv") then
package:add("deps", "libuv")
package:add("defines", "LIBUS_USE_LIBUV")
end
end
if package:is_plat("linux") and package:config("uring") then
package:add("deps", "liburing")
package:add("defines", "LIBUS_USE_IO_URING")
end
if package:config("quic") then
package:add("deps", "lsquic")
package:add("defines", "LIBUS_USE_QUIC")
end
end)
on_install("windows", "macosx", "linux", function (package)
local configs = {}
configs.ssl = package:config("ssl")
configs.uv = package:config("uv")
configs.uring = package:config("uring")
configs.quic = package:config("quic")
os.cp(path.join(package:scriptdir(), "port", "xmake.lua"), "xmake.lua")
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)
assert(package:has_cfuncs("us_create_socket_context", {includes = {"libusockets.h"}}))
end)
Loading…
Cancel
Save