From b4ae1fb52109e5f1359583d49a0d274412f3bd50 Mon Sep 17 00:00:00 2001 From: wangli28 <47812810+wangli28@users.noreply.github.com> Date: Tue, 18 Jun 2019 02:32:15 +0800 Subject: [PATCH] [libwebsockets] Fix build error on Linux (#6855) --- ports/libwebsockets/0001-Fix-UWP.patch | 99 -------------------------- ports/libwebsockets/CONTROL | 2 +- ports/libwebsockets/portfile.cmake | 14 ++-- 3 files changed, 10 insertions(+), 105 deletions(-) delete mode 100644 ports/libwebsockets/0001-Fix-UWP.patch diff --git a/ports/libwebsockets/0001-Fix-UWP.patch b/ports/libwebsockets/0001-Fix-UWP.patch deleted file mode 100644 index c4cf221404e155..00000000000000 --- a/ports/libwebsockets/0001-Fix-UWP.patch +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/lib/plat/lws-plat-win.c b/lib/plat/lws-plat-win.c -index dd3e95a..eb1690a 100644 ---- a/lib/plat/lws-plat-win.c -+++ b/lib/plat/lws-plat-win.c -@@ -157,7 +157,7 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) - { - struct lws_context_per_thread *pt; - WSANETWORKEVENTS networkevents; -- struct lws_pollfd *pfd; -+ struct lws_pollfd *pfd = NULL; - struct lws *wsi; - unsigned int i; - DWORD ev; -@@ -591,6 +591,7 @@ lws_plat_inet_pton(int af, const char *src, void *dst) - return ok ? 1 : -1; - } - -+#if !defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP) - LWS_VISIBLE lws_fop_fd_t - _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, - const char *vpath, lws_fop_flags_t *flags) -@@ -631,6 +632,49 @@ _lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, - bail: - return NULL; - } -+#else -+LWS_VISIBLE lws_fop_fd_t -+_lws_plat_file_open(const struct lws_plat_file_ops *fops, const char *filename, -+ const char *vpath, lws_fop_flags_t *flags) -+{ -+ HANDLE ret; -+ WCHAR buf[MAX_PATH]; -+ lws_fop_fd_t fop_fd; -+ LARGE_INTEGER llFileSize = {0}; -+ -+ MultiByteToWideChar(CP_UTF8, 0, filename, -1, buf, ARRAY_SIZE(buf)); -+ if (((*flags) & 7) == _O_RDONLY) { -+ ret = CreateFile2(buf, GENERIC_READ, FILE_SHARE_READ, -+ OPEN_EXISTING, NULL); -+ } else { -+ lwsl_err("%s: open for write not implemented\n", __func__); -+ *filelen = 0; -+ ret = LWS_INVALID_FILE; -+ } -+ -+ if (ret == LWS_INVALID_FILE) -+ goto bail; -+ -+ fop_fd = malloc(sizeof(*fop_fd)); -+ if (!fop_fd) -+ goto bail; -+ -+ fop_fd->fops = fops; -+ fop_fd->fd = ret; -+ fop_fd->filesystem_priv = NULL; /* we don't use it */ -+ fop_fd->flags = *flags; -+ fop_fd->len = GetFileSize(ret, NULL); -+ if(GetFileSizeEx(ret, &llFileSize)) -+ fop_fd->len = llFileSize.QuadPart; -+ -+ fop_fd->pos = 0; -+ -+ return fop_fd; -+ -+bail: -+ return NULL; -+} -+#endif - - LWS_VISIBLE int - _lws_plat_file_close(lws_fop_fd_t *fop_fd) -diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h -index 23f8f4d..bc32aef 100644 ---- a/lib/private-libwebsockets.h -+++ b/lib/private-libwebsockets.h -@@ -111,12 +111,23 @@ - #define WIN32_LEAN_AND_MEAN - #endif - -+#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY != WINAPI_FAMILY_DESKTOP_APP) -+#ifndef WINVER -+#define WINVER 0x0602 -+#define _WIN32_WINNT WINVER -+#endif -+ -+#define getenv(x) NULL -+#define _WINSOCK_DEPRECATED_NO_WARNINGS -+#else -+ - #if (WINVER < 0x0501) - #undef WINVER - #undef _WIN32_WINNT - #define WINVER 0x0501 - #define _WIN32_WINNT WINVER - #endif -+#endif - #define LWS_NO_DAEMONIZE - #define LWS_ERRNO WSAGetLastError() - #define LWS_EAGAIN WSAEWOULDBLOCK diff --git a/ports/libwebsockets/CONTROL b/ports/libwebsockets/CONTROL index 97a755677d4244..ae9c3d6ee3551e 100644 --- a/ports/libwebsockets/CONTROL +++ b/ports/libwebsockets/CONTROL @@ -1,5 +1,5 @@ Source: libwebsockets -Version: 3.1.0 +Version: 3.1.0-1 Build-Depends: zlib, openssl Homepage: https://github.com/warmcat/libwebsockets Description: Libwebsockets is a lightweight pure C library built to use minimal CPU and memory resources, and provide fast throughput in both directions as client or server. diff --git a/ports/libwebsockets/portfile.cmake b/ports/libwebsockets/portfile.cmake index b869fcc2ab364d..c23f99042242c5 100644 --- a/ports/libwebsockets/portfile.cmake +++ b/ports/libwebsockets/portfile.cmake @@ -6,8 +6,6 @@ vcpkg_from_github( REF v3.1.0 SHA512 e2a4c1b25bc6f028654a63fc01a2732e6c63414868f8d3d01fa477752fdabe0f61e8d271fe7dd2734db0e15b1250f6b0101285b6d694f971ec4bf67ba7ee067c HEAD_REF master - PATCHES - 0001-Fix-UWP.patch ) string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" LWS_WITH_STATIC) @@ -28,7 +26,11 @@ vcpkg_configure_cmake( vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH "cmake") +if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "windows" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + vcpkg_fixup_cmake_targets(CONFIG_PATH "cmake") +else() + vcpkg_fixup_cmake_targets(CONFIG_PATH "lib/cmake/libwebsockets" TARGET_PATH "share/libwebsockets") +endif() file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) @@ -45,7 +47,9 @@ file(WRITE ${CURRENT_PACKAGES_DIR}/share/libwebsockets/LibwebsocketsTargets-rele file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/libwebsockets) file(RENAME ${CURRENT_PACKAGES_DIR}/share/libwebsockets/LICENSE ${CURRENT_PACKAGES_DIR}/share/libwebsockets/copyright) if (VCPKG_LIBRARY_LINKAGE STREQUAL static) - file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/websockets_static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/websockets.lib) - file(RENAME ${CURRENT_PACKAGES_DIR}/lib/websockets_static.lib ${CURRENT_PACKAGES_DIR}/lib/websockets.lib) + if (NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "windows" OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") + file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/websockets_static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/websockets.lib) + file(RENAME ${CURRENT_PACKAGES_DIR}/lib/websockets_static.lib ${CURRENT_PACKAGES_DIR}/lib/websockets.lib) + endif() endif () vcpkg_copy_pdbs()