diff --git a/packages/e/easywsclient/patches/2021.01.12/add_cstdint.patch b/packages/e/easywsclient/patches/2021.01.12/add_cstdint.patch new file mode 100644 index 000000000..5211abc91 --- /dev/null +++ b/packages/e/easywsclient/patches/2021.01.12/add_cstdint.patch @@ -0,0 +1,42 @@ +diff --git a/easywsclient.cpp b/easywsclient.cpp +index 0c98098..750d513 100644 +--- a/easywsclient.cpp ++++ b/easywsclient.cpp +@@ -26,17 +26,6 @@ + #ifndef snprintf + #define snprintf _snprintf_s + #endif +- #if _MSC_VER >=1600 +- // vs2010 or later +- #include +- #else +- typedef __int8 int8_t; +- typedef unsigned __int8 uint8_t; +- typedef __int32 int32_t; +- typedef unsigned __int32 uint32_t; +- typedef __int64 int64_t; +- typedef unsigned __int64 uint64_t; +- #endif + #define socketerrno WSAGetLastError() + #define SOCKET_EAGAIN_EINPROGRESS WSAEINPROGRESS + #define SOCKET_EWOULDBLOCK WSAEWOULDBLOCK +@@ -52,7 +41,6 @@ + #include + #include + #include +- #include + #ifndef _SOCKET_T_DEFINED + typedef int socket_t; + #define _SOCKET_T_DEFINED +diff --git a/easywsclient.hpp b/easywsclient.hpp +index 08c4a7b..df60500 100644 +--- a/easywsclient.hpp ++++ b/easywsclient.hpp +@@ -10,6 +10,7 @@ + + #include + #include ++#include + + namespace easywsclient { + diff --git a/packages/e/easywsclient/patches/2021.01.12/move_import.patch b/packages/e/easywsclient/patches/2021.01.12/move_import.patch new file mode 100644 index 000000000..5941ef7e5 --- /dev/null +++ b/packages/e/easywsclient/patches/2021.01.12/move_import.patch @@ -0,0 +1,18 @@ +diff --git a/easywsclient.cpp b/easywsclient.cpp +index 0c98098..aca7e77 100644 +--- a/easywsclient.cpp ++++ b/easywsclient.cpp +@@ -1,3 +1,4 @@ ++#include "easywsclient.hpp" + + #ifdef _WIN32 + #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) +@@ -73,8 +74,6 @@ + #include + #include + +-#include "easywsclient.hpp" +- + using easywsclient::Callback_Imp; + using easywsclient::BytesCallback_Imp; + diff --git a/packages/e/easywsclient/xmake.lua b/packages/e/easywsclient/xmake.lua new file mode 100644 index 000000000..73270643c --- /dev/null +++ b/packages/e/easywsclient/xmake.lua @@ -0,0 +1,43 @@ +package("easywsclient") + set_homepage("https://github.com/dhbaird/easywsclient") + set_description("A short and sweet WebSocket client for C++") + set_license("MIT") + + add_urls("https://github.com/dhbaird/easywsclient.git") + add_versions("2021.01.12", "afc1d8cfc584e0f1f4a77e8c0ce3e979d9fe7ce2") + add_patches("2021.01.12", path.join(os.scriptdir(), "patches", "2021.01.12", "add_cstdint.patch"), "babddf02e9eae42cc11e5458478f207837a402c425b31dafd2ef63a29b7d6744") + add_patches("2021.01.12", path.join(os.scriptdir(), "patches", "2021.01.12", "move_import.patch"), "9265412268390cbfcb799f40324c3e255ae6fc01c292e749c131f1c3c19e32bd") + + if is_plat("mingw") then + add_syslinks("ws2_32") + end + + on_install(function (package) + local configs = {} + io.writefile("xmake.lua", [[ + add_rules("mode.release", "mode.debug") + target("easywsclient") + set_kind("$(kind)") + set_languages("cxx11") + add_files("easywsclient.cpp") + add_headerfiles("(easywsclient.hpp)") + if is_plat("windows") then + add_defines("_WIN32") + end + if is_plat("mingw") then + add_syslinks("ws2_32") + end + ]]) + import("package.tools.xmake").install(package, configs) + end) + + on_test(function (package) + assert(package:check_cxxsnippets({test = [[ + #include + #include "easywsclient.hpp" + void test() { + std::unique_ptr ws(easywsclient::WebSocket::from_url("ws://echo.websocket.org")); + ws->send("Hello World!"); + } + ]]}), {configs = {languages = "cxx11"}}) + end)