be slightly less annoying

check build rules
This commit is contained in:
despair 2018-10-27 08:51:02 -05:00
parent c5d1b32286
commit 38f2a6b2c9
8 changed files with 69 additions and 58 deletions

View File

@ -500,22 +500,17 @@ set(ALL_SRC ${CLIENT_SRC} ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${
if(USE_LIBABYSS)
set(ABYSS libabyss)
set(ABYSS_LIB abyss)
set(ABYSS_EXE ${ABYSS_LIB}-main)
include_directories(${ABYSS}/include)
set(ABYSS_SRC
${ABYSS}/src/http.cpp
${ABYSS}/src/client.cpp
${ABYSS}/src/server.cpp
${ABYSS}/src/json.cpp)
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
set(ALL_SRC ${CLIENT_SRC} ${RC_SRC} ${EXE_SRC} ${DNS_SRC} ${LIB_PLATFORM_SRC} ${LIB_SRC} ${TEST_SRC} ${ABYSS_SRC} ${ABYSS}/main.cpp)
add_library(${ABYSS_LIB} STATIC ${ABYSS_SRC})
set(ALL_SRC ${ALL_SRC} ${ABYSS_SRC} ${ABYSS}/main.cpp)
endif()
foreach(F ${ALL_SRC})
set_source_files_properties(${F} PROPERTIES COMPILE_FLAGS -DLOG_TAG=\\\"${F}\\\")
@ -553,14 +548,12 @@ if(WITH_STATIC)
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB})
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB})
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB})
target_link_libraries(${ABYSS_EXE} ${STATIC_LIB})
if (WIN32)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${RC_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${TEST_EXE} ${STATIC_LINK_LIBS} gtest_main ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
target_link_libraries(${DNS_EXE} ${STATIC_LIB} ${PLATFORM_LIB} ${THREAD_LIB} ws2_32 iphlpapi)
target_link_libraries(${ABYSS_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} ${PLATFORM_LIB} ws2_32 iphlpapi)
endif(WIN32)
endif(NOT WITH_SHARED)
endif(WITH_STATIC)

View File

@ -35,9 +35,6 @@ startWinsock()
{
WSADATA wsockd;
int err;
// We used to defer starting winsock until
// we got to the iocp event loop
// but getaddrinfo(3) requires that winsock be in core already
err = ::WSAStartup(MAKEWORD(2, 2), &wsockd);
if(err)
{
@ -83,7 +80,9 @@ main(int argc, char *argv[])
break;
case 'r':
#ifdef _WIN32
llarp::LogError("we will not run as relay because you're running windows, install a real operating system please");
llarp::LogError(
"please don't try this at home, the relay feature is untested on "
"windows server --R.");
return 1;
#endif
asRouter = true;

View File

@ -26,7 +26,17 @@ namespace abyss
#endif
namespace abyss
{
#if __cplusplus >= 201703L
// the code assumes C++11, if you _actually have_ C++17
// and have the ability to switch it on, then some of the code
// using string_view fails since it was made with the assumption
// that string_view is an alias for string!
//
// Specifically, one cannot use std::transform() on _real_ string_views
// since _those_ are read-only at all times - iterator and const_iterator
// are _exactly_ alike -rick
/* #if __cplusplus >= 201703L */
#if 0
typedef std::string_view string_view;
#else
typedef std::string string_view;

View File

@ -13,10 +13,10 @@
#include <pthread_np.h>
#endif
/*#if _WIN32 || __sun
#if _WIN32 || __sun
#define wmin(x, y) (((x) < (y)) ? (x) : (y))
#define MIN wmin
#endif*/
#endif
namespace llarp
{

View File

@ -1,3 +1,8 @@
// saves us some calculation in the sodium bits
#if defined(_WIN32) || defined(_M_IX86) || defined(_M_X64) \
|| defined(__i386__) || defined(__amd64__)
#define NATIVE_LITTLE_ENDIAN 1
#endif
#include <assert.h>
#include <llarp/crypto.h>
#include <sodium/crypto_generichash.h>

View File

@ -245,6 +245,9 @@ namespace llarp
} // namespace llarp
// they're effectively alike, save for the fact that we must not
// get file descriptors below zero
#ifndef _WIN32
llarp::ev_io *
llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
{
@ -274,3 +277,42 @@ llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
tcp->impl = serv;
return serv;
}
#else
llarp::ev_io *
llarp_ev_loop::bind_tcp(llarp_tcp_acceptor *tcp, const sockaddr *bindaddr)
{
DWORD on = 1;
SOCKET fd = ::socket(bindaddr->sa_family, SOCK_STREAM, 0);
if(fd == INVALID_SOCKET)
return nullptr;
socklen_t sz = sizeof(sockaddr_in);
if(bindaddr->sa_family == AF_INET6)
{
sz = sizeof(sockaddr_in6);
}
// keep. inexplicably, windows now has unix domain sockets
// for now, use the ID numbers directly until this comes out of
// beta
else if(bindaddr->sa_family == AF_UNIX)
{
sz = 110; // current size in 10.0.17763, verify each time the beta PSDK
// is updated
}
if(::bind(fd, bindaddr, sz) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
if(::listen(fd, 5) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
llarp::ev_io *serv = new llarp::tcp_serv(this, fd, tcp);
tcp->impl = serv;
// We're non-blocking now, but can't really make use of it
// until we cut over to WSA* functions
ioctlsocket(fd, FIONBIO, &on);
return serv;
}
#endif

View File

@ -289,44 +289,6 @@ struct llarp_win32_loop : public llarp_ev_loop
return result;
}
llarp::ev_io*
bind_tcp(llarp_tcp_acceptor* tcp, const sockaddr* bindaddr)
{
DWORD on = 1;
SOCKET fd = ::socket(bindaddr->sa_family, SOCK_STREAM, 0);
if(fd == INVALID_SOCKET)
return nullptr;
socklen_t sz = sizeof(sockaddr_in);
if(bindaddr->sa_family == AF_INET6)
{
sz = sizeof(sockaddr_in6);
}
// keep. inexplicably, windows now has unix domain sockets
// for now, use the ID numbers directly until this comes out of
// beta
else if(bindaddr->sa_family == AF_UNIX)
{
sz = 110; // current size in 10.0.17763, verify each time the beta PSDK
// is updated
}
if(::bind(fd, bindaddr, sz) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
if(::listen(fd, 5) == SOCKET_ERROR)
{
::closesocket(fd);
return nullptr;
}
llarp::ev_io* serv = new llarp::tcp_serv(this, fd, tcp);
tcp->impl = serv;
// We're non-blocking now, but can't really make use of it
// until we cut over to WSA* functions
ioctlsocket(fd, FIONBIO, &on);
return serv;
}
SOCKET
udp_bind(const sockaddr* addr)
{

View File

@ -108,15 +108,15 @@ namespace llarp
#else
struct ServerImpl
{
ServerImpl(llarp_router * r) {};
bool Start(const std::string & addr)
ServerImpl(llarp_router* r){};
bool
Start(const std::string& addr)
{
return true;
}
};
#endif
Server::Server(llarp_router* r) : m_Impl(new ServerImpl(r))
{
}