ixwebsocket: add package (#2879)

* ixwebsocket: add package

* ixwebsocket: add config to use mbedtls

* ixwebsocket: set default ssl

* ixwebsocket: removed shared config for wasm

* Update xmake.lua

* Update xmake.lua

* Remove on_install limits

* ixwebsocket: disable shared for wasm

* ixwebsocket: revert non shared for wasm

* ixwebsocket: set zlib version to `v1.2.13`

* ixwebsocket: add zlib include dir

* ixwebsocket: add PLATFORM_NAME for wasm

* ixwebsocket: fix quotations

* ixwebsocket: replace use of PLATFORM_NAME if wasm

* ixwebsocket: remove extra quotation mark

* ixwebsocket: remove another extra quotation mark

---------

Co-authored-by: ruki <waruqi@gmail.com>
pull/2881/head
Chi Huu Huynh 1 year ago committed by GitHub
parent 7df93f9fee
commit d505630708
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 86
      packages/i/ixwebsocket/xmake.lua

@ -0,0 +1,86 @@
package("ixwebsocket")
set_homepage("https://github.com/machinezone/IXWebSocket")
set_description("websocket and http client and server library, with TLS support and very few dependencies")
set_license("BSD-3-Clause")
add_urls("https://github.com/machinezone/IXWebSocket/archive/refs/tags/$(version).tar.gz",
"https://github.com/machinezone/IXWebSocket.git")
add_versions("v11.4.4", "9ef7fba86a91ce18693451466ddc54b1e0c4a7dc4466c3028d888d6d55dde539")
local default_ssl = nil
if not is_plat("windows") then
if is_plat("iphoneos") or is_plat("wasm") then
default_ssl = "mbedtls"
else
default_ssl = "openssl"
end
end
add_configs("ssl", {description = "Enable SSL", default = default_ssl, type = "string", values = {"openssl", "mbedtls"}})
add_configs("use_tls", {description = "Use TLS", default = false, type = "boolean"})
if is_plat("wasm") then
add_configs("shared", {description = "Build shared library.", default = false, type = "boolean", readonly = true})
end
add_deps("zlib")
if is_plat("windows") then
add_syslinks("ws2_32")
elseif is_plat("macosx") then
add_frameworks("Foundation", "Security")
elseif is_plat("linux", "bsd") then
add_syslinks("pthread")
end
add_deps("cmake")
on_load(function (package)
if package:config("ssl") == "openssl" then
package:add("deps", "openssl")
elseif package:config("ssl") == "mbedtls" then
package:add("deps", "mbedtls")
end
end)
on_install(function (package)
local configs = {"-DCMAKE_CXX_STANDARD=11"}
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, "-DUSE_TLS=" .. (package:config("use_tls") and "ON" or "OFF"))
local zlib = package:dep("zlib")
if zlib and not zlib:is_system() then
local fetchinfo = zlib:fetch({external = false})
if fetchinfo then
local includedirs = fetchinfo.includedirs or fetchinfo.sysincludedirs
if includedirs and #includedirs > 0 then
table.insert(configs, "-DZLIB_INCLUDE_DIR=" .. table.concat(includedirs, " "))
end
local libfiles = fetchinfo.libfiles
if libfiles then
table.insert(configs, "-DZLIB_LIBRARY=" .. table.concat(libfiles, " "))
end
end
end
if is_plat("wasm") then
io.replace("ixwebsocket/IXUserAgent.cpp", [[ss << " " << PLATFORM_NAME]], [[ss << " " << "unknown platform"]], {plain = true})
end
import("package.tools.cmake").install(package, configs)
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocket.h>
void test () {
ix::initNetSystem();
ix::WebSocket webSocket;
std::string url("wss://echo.websocket.org");
webSocket.setUrl(url);
webSocket.start();
webSocket.send("Hello world");
}
]]}, {configs = {languages = "cxx11"}}))
end)
Loading…
Cancel
Save