Skip to content

Commit

Permalink
libwebsockets: add v4.3.3 version (#5112)
Browse files Browse the repository at this point in the history
* libwebsockets: add v4.3.3 version

* disable example & test

* fix mingw syslinks

* fix libcap

* add configs
  • Loading branch information
star-hengxing authored Sep 2, 2024
1 parent b4edbd6 commit 2da37b2
Showing 1 changed file with 54 additions and 12 deletions.
66 changes: 54 additions & 12 deletions packages/l/libwebsockets/xmake.lua
Original file line number Diff line number Diff line change
@@ -1,37 +1,79 @@
package("libwebsockets")

set_homepage("https://github.com/warmcat/libwebsockets")
set_description("canonical libwebsockets.org websocket library")
set_license("MIT")

set_urls("https://github.com/warmcat/libwebsockets/archive/$(version).tar.gz",
set_urls("https://github.com/warmcat/libwebsockets/archive/refs/tags/$(version).tar.gz",
"https://github.com/warmcat/libwebsockets.git")

add_versions("v4.1.6", "402e9a8df553c9cd2aff5d7a9758e9e5285bf3070c82539082864633db3deb83")
add_versions("v4.3.3", "6fd33527b410a37ebc91bb64ca51bdabab12b076bc99d153d7c5dd405e4bdf90")

add_deps("cmake")

add_configs("ssl", { description = "Enable ssl (default: openssl).", default = false, type = "boolean"})
add_configs("ssl", {description = "Enable ssl (default: openssl).", default = false, type = "boolean"})
add_configs("libev", {description = "Build with libev", default = false, type = "boolean"})
add_configs("libuv", {description = "Build with libuv", default = false, type = "boolean"})
add_configs("libevent", {description = "Build with libevent", default = false, type = "boolean"})
add_configs("glib", {description = "Build with glib", default = false, type = "boolean"})

add_configs("libcap", {description = "Build with libcap", default = false, type = "boolean"})

if is_plat("windows") then
if is_plat("windows", "mingw") then
add_syslinks("ws2_32")
end

if on_check then
on_check("windows", function (package)
import("core.base.semver")

local msvc = package:toolchain("msvc")
if msvc then
local vs_sdkver = msvc:config("vs_sdkver")
assert(vs_sdkver and semver.match(vs_sdkver):gt("10.0.19041"), "package(libwebsockets): need vs_sdkver > 10.0.19041.0")
end
end)
end

on_load(function (package)
if package:config("ssl") then
package:add("deps", "openssl")
local deps_map = {
["ssl"] = "openssl"
}
for name, enabled in table.orderpairs(package:configs()) do
if not package:extraconf("configs", name, "builtin") then
if package:config(name) then
local dep_name = deps_map[name]
if not dep_name then
dep_name = name
end
package:add("deps", dep_name)
end
end
end
end)

on_install("windows", "linux", "macosx", function (package)
local configs = {}
table.insert(configs, "-DLWS_WITH_SSL=" .. (package:config("ssl") and "ON" or "OFF"))
on_install("!wasm", function (package)
io.replace("CMakeLists.txt", "/WX", "", {plain = true})
if not package:is_plat("linux") or not package:config("libcap") then
io.replace("CMakeLists.txt", [[CHECK_LIBRARY_EXISTS(cap cap_set_flag "" LWS_HAVE_LIBCAP)]], "", {plain = true})
end

local configs = {"-DDISABLE_WERROR=ON", "-DLWS_WITH_MINIMAL_EXAMPLES=OFF", "-DLWS_WITHOUT_TESTAPPS=ON"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_STATIC=" .. (package:config("shared") and "OFF" or "ON"))
table.insert(configs, "-DLWS_LINK_TESTAPPS_DYNAMIC=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_SHARED=" .. (package:config("shared") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_ASAN=" .. (package:config("asan") and "ON" or "OFF"))

table.insert(configs, "-DLWS_WITH_SSL=" .. (package:config("ssl") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_LIBEV=" .. (package:config("libev") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_LIBUV=" .. (package:config("libuv") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_LIBEVENT=" .. (package:config("libevent") and "ON" or "OFF"))
table.insert(configs, "-DLWS_WITH_GLIB=" .. (package:config("glib") and "ON" or "OFF"))

os.mkdir(path.join(package:buildir(), "lib", "pdb"))
import("package.tools.cmake").install(package, configs)
end)

on_test(function (package)
assert(package:has_cfuncs("lws_create_context", {includes = "libwebsockets.h"}))
end)

0 comments on commit 2da37b2

Please sign in to comment.