Windows fixes

- Add libuv submodule (only needed and built on Windows)

- Temporarily switch uWebSockets to my github repo: I submitted some
mingw compilation fixes upstream; as soon as a new upstream release
comes out we will switch this back to the upstream repo.

- Switch BOOST_SCOPE_EXIT to LOKI_DEFER

- Don't compile `closefrom()` on Windows (it isn't used, and generates
an unused function warning).
This commit is contained in:
Jason Rhinelander 2020-07-16 22:25:17 -03:00
parent 42a7e83c33
commit 43f2dfba50
6 changed files with 19 additions and 6 deletions

5
.gitmodules vendored
View File

@ -18,4 +18,7 @@
url = https://github.com/google/googletest.git
[submodule "external/uWebSockets"]
path = external/uWebSockets
url = https://github.com/uNetworking/uWebSockets.git
url = https://github.com/jagerman/uWebSockets.git
[submodule "external/libuv"]
path = external/libuv
url = https://github.com/libuv/libuv.git

View File

@ -52,6 +52,7 @@ library archives (`.a`).
| sqlite3 | ? | YES | `libsqlite3-dev` | `sqlite` | `sqlite-devel` | NO | Loki Name System |
| libunbound | 1.4.16 | NO | `libunbound-dev` | `unbound` | `unbound-devel` | NO | DNS resolver |
| libsodium | 1.0.9 | YES | `libsodium-dev` | `libsodium` | `libsodium-devel` | NO | cryptography |
| libuv (Win) | any | NO | (Windows only) | -- | -- | NO | RPC event loop |
| libunwind | any | NO | `libunwind8-dev` | `libunwind` | `libunwind-devel` | YES | Stack traces |
| liblzma | any | NO | `liblzma-dev` | `xz` | `xz-devel` | YES | For libunwind |
| libreadline | 6.3.0 | NO | `libreadline-dev` | `readline` | `readline-devel` | YES | Input editing |

View File

@ -104,6 +104,12 @@ add_library(uSockets STATIC EXCLUDE_FROM_ALL ${usockets_src})
target_compile_definitions(uSockets PRIVATE LIBUS_NO_SSL=1)
target_include_directories(uSockets PRIVATE uWebSockets/uSockets/src)
# On Windows uSockets uses libuv for its event loop:
if (WIN32)
add_subdirectory(libuv EXCLUDE_FROM_ALL)
target_link_libraries(uSockets uv_a)
endif()
# The uWebSockets C++ layer is header-only but isn't actually prefixed in the repository itself, but
# rather only on install (which, as above, is just a very simple Makefile). This is unfortunate

1
external/libuv vendored Submodule

@ -0,0 +1 @@
Subproject commit 10a9c25a125185968809d65de901d23183df8150

@ -1 +1 @@
Subproject commit 8dfabd559d4a54f29bd04d397223da0140610c8e
Subproject commit f2752b3ff56c4ce1d57be9c0231209e50f5e231c

View File

@ -39,6 +39,8 @@
#include "misc_log_ex.h"
#include "util.h"
#include "spawn.h"
#include "loki.h"
#include "string_util.h"
#undef LOKI_DEFAULT_LOG_CATEGORY
#define LOKI_DEFAULT_LOG_CATEGORY "spawn"
@ -46,6 +48,7 @@
namespace tools
{
#ifndef _WIN32
static void closefrom(int fd)
{
#if defined __FreeBSD__ || defined __OpenBSD__ || defined __NetBSD__ || defined __DragonFly__
@ -64,6 +67,7 @@ static void closefrom(int fd)
}
#endif
}
#endif
int spawn(const char *filename, const std::vector<std::string>& args, bool wait)
@ -80,12 +84,10 @@ int spawn(const char *filename, const std::vector<std::string>& args, bool wait)
return -1;
}
BOOST_SCOPE_EXIT(&pi)
{
LOKI_DEFER {
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
}
BOOST_SCOPE_EXIT_END
};
if (!wait)
{