Skip to content

Commit

Permalink
add mosquitto to repo (#2318)
Browse files Browse the repository at this point in the history
* add mosquitto to repo

* Optimize mosquitto pacakage

* format code and remove some configs

* reduce mosquitto xmake.lua

* add configs filter
  • Loading branch information
airhh group authored Jul 14, 2023
1 parent c30c39d commit befa6ee
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/m/mosquitto/patches/cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b8913c2d..97bb7d2d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,6 +14,11 @@ list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/")

add_definitions (-DCMAKE -DVERSION=\"${VERSION}\")

+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ add_definitions("-DWIN32")
+ add_definitions("-D_WIN32")
+endif()
+
if (WIN32)
add_definitions("-D_CRT_SECURE_NO_WARNINGS")
add_definitions("-D_CRT_NONSTDC_NO_DEPRECATE")
--
91 changes: 91 additions & 0 deletions packages/m/mosquitto/xmake.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package("mosquitto")
set_homepage("https://mosquitto.org")
set_description("Eclipse Mosquitto - An open source MQTT broker")
set_license("EPL-2.0")

add_urls("https://github.com/eclipse/mosquitto/archive/refs/tags/$(version).tar.gz",
"https://github.com/eclipse/mosquitto.git")

add_versions("v2.0.15", "547f98acd2e4668c8f3b86ef61e71c755366d180565b6e7537813876467d04d9")

if is_plat("windows") then
add_patches("v2.0.15", path.join(os.scriptdir(), "patches", "cmake.patch"),"b241fb965f3d00bad1fddf060fe9b99cba83df32c373a4eaee2289e05abd26b6")
end

add_configs("tls", {description = "Include SSL/TLS support", default = true, type = "boolean"})
add_configs("cjson", {description = "Build with cJSON support (required for dynamic security plugin and useful for mosquitto_sub)", default = true, type = "boolean"})
add_configs("bundled_deps", {description = "Build with bundled dependencies", default = true, type = "boolean"})
add_configs("websockets", {description = "Include websockets support", default = false, type = "boolean"})

add_configs("tls_psk", {description = "Include TLS-PSK support (requires WITH_TLS)", default = true, type = "boolean"})
add_configs("ec", {description = "Include Elliptic Curve support (requires WITH_TLS)", default = true, type = "boolean"})
add_configs("unix_sockets", {description = "Include Unix Domain Socket support", default = true, type = "boolean"})
add_configs("socks", {description = "Include SOCKS5 support", default = true, type = "boolean"})
add_configs("threading", {description = "Include client library threading support", default = true, type = "boolean"})
if is_plat("linux") then
add_configs("srv", {description = "Include SRV lookup support", default = true, type = "boolean"})
end
add_configs("dlt", {description = "Include DLT support", default = false, type = "boolean"})

add_configs("lib_cpp", {description = "Build C++ library", default = true, type = "boolean"})
add_configs("broker", {description = "Build broker", default = false, type = "boolean"})

add_deps("cmake")

if is_plat("macosx") then
add_extsources("brew::mosquitto")
end

local deps_map =
{
tls = "openssl",
cjson = "cjson",
bundled_deps = "uthash",
srv = "c-ares",
websockets = "libwebsockets",
}

if is_plat("linux") then
add_syslinks("pthread", "m")
add_links("mosquittopp", "mosquitto")
elseif is_plat("windows") then
add_syslinks("ws2_32")
deps_map["threading"] = "pthreads4w"
end

on_load("windows", "linux", "macosx", function (package)
for key, value in pairs(deps_map) do
if package:config(key) then
package:add("deps", value)
end
end
end)

on_install("windows", "linux", "macosx", function (package)
local configs ={"-DDOCUMENTATION=OFF", "-DWITH_CLIENTS=OFF", "-DWITH_APPS=OFF", "-DWITH_PLUGINS=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DWITH_STATIC_LIBRARIES=" .. (package:config("shared") and "OFF" or "ON"))

for name, value in pairs(package:configs()) do
if not package:extraconf("configs", name, "builtin") then
table.insert(configs, "-DWITH_" .. name:upper() .. "=" .. (value and "ON" or "OFF"))
end
end

local packagedeps = {}
for key, value in pairs(deps_map) do
if package:config(key) then
table.insert(packagedeps, value)
end
end
import("package.tools.cmake").install(package, configs, {packagedeps = packagedeps})
end)

on_test(function (package)
assert(package:check_csnippets({test = [[
#include <mosquitto.h>
void test() {
mosquitto_lib_init();
}
]]}))
end)

0 comments on commit befa6ee

Please sign in to comment.