diff --git a/CMakeLists.txt b/CMakeLists.txt index d2140afde..79d60e122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -188,7 +188,6 @@ set(CMAKE_THREAD_PREFER_PTHREAD TRUE) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) -# win32 is in tree if(NOT IOS AND NOT ANDROID AND NOT WIN32) find_package(CURL REQUIRED) endif() diff --git a/cmake/win32.cmake b/cmake/win32.cmake index af4167eb0..291aed58a 100644 --- a/cmake/win32.cmake +++ b/cmake/win32.cmake @@ -20,7 +20,7 @@ if(NOT MSVC_VERSION) # GNU ld sees fit to merge *all* the .ident sections in object files # to .r[o]data section one after the other! add_compile_options(-fno-ident -Wa,-mbig-obj) - link_libraries( -lshlwapi -ldbghelp -luser32 -liphlpapi -lpsapi -luserenv ) + link_libraries( -lws2_32 -lshlwapi -ldbghelp -luser32 -liphlpapi -lpsapi -luserenv ) add_definitions(-DWINVER=0x0500 -D_WIN32_WINNT=0x0500) endif() @@ -31,7 +31,7 @@ endif() list(APPEND LIBTUNTAP_SRC ${TT_ROOT}/tuntap-windows.c) get_filename_component(EV_SRC "llarp/ev/ev_libuv.cpp" ABSOLUTE) add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x0500) -set(EXE_LIBS ${STATIC_LIB} ${FS_LIB}) +set(EXE_LIBS ${STATIC_LIB} ${FS_LIB} uv) if(RELEASE_MOTTO) add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}") diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index 2025a7411..34bd26294 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -52,16 +52,5 @@ else() target_link_libraries(${CTL} PRIVATE ${CURL_LIBRARIES}) target_compile_definitions(${CTL} PRIVATE -DWITH_CURL=1) endif(CURL_FOUND) - if(WIN32) - target_include_directories(${CTL} PRIVATE ../win32-setup/include) - target_compile_definitions(${CTL} PRIVATE -DWITH_CURL=1 -DCURL_STATICLIB) - if (CMAKE_SIZEOF_VOID_P EQUAL 8) - target_link_directories(${CTL} PRIVATE ../win32-setup/lib64) - target_link_directories(${EXE} PRIVATE ../win32-setup/lib64) - else() - target_link_directories(${CTL} PRIVATE ../win32-setup/lib) - target_link_directories(${EXE} PRIVATE ../win32-setup/lib) - endif() - endif(WIN32) endif(SHADOW) diff --git a/llarp/CMakeLists.txt b/llarp/CMakeLists.txt index 199d5c788..bb9f2632d 100644 --- a/llarp/CMakeLists.txt +++ b/llarp/CMakeLists.txt @@ -64,15 +64,6 @@ add_library(${UTIL_LIB} STATIC ${LIB_UTIL_SRC}) add_dependencies(${UTIL_LIB} genversion) target_include_directories(${UTIL_LIB} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${PROJECT_SOURCE_DIR}/include) -if (WIN32) - target_include_directories(${UTIL_LIB} PUBLIC ../win32-setup/include) - target_compile_definitions(${UTIL_LIB} PUBLIC -DCURL_STATICLIB) - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - target_link_libraries(${UTIL_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${FS_LIB} ${LOG_LIB} curl crypt32 ws2_32 iphlpapi) - else() - target_link_libraries(${UTIL_LIB} PUBLIC ${CRYPTOGRAPHY_LIB} ${FS_LIB} ${LOG_LIB} curl mbedtls mbedx509 mbedcrypto ws2_32 iphlpapi) - endif() -endif() if(ANDROID) set(LOG_LIB log) endif() @@ -114,8 +105,7 @@ if (WIN32) ev/ev_win32.cpp ${LIB_PLATFORM_SRC} win32/win32_inet.c - win32/win32_intrnl.c - win32/win32_upoll.c) + win32/win32_intrnl.c) endif(WIN32) add_library(${PLATFORM_LIB} STATIC ${LIB_PLATFORM_SRC}) diff --git a/llarp/config/key_manager.cpp b/llarp/config/key_manager.cpp index 3cb711a2e..71a97f304 100644 --- a/llarp/config/key_manager.cpp +++ b/llarp/config/key_manager.cpp @@ -6,7 +6,9 @@ #include "crypto/crypto.hpp" #include "crypto/types.hpp" +#ifndef _WIN32 #include +#endif /// curl callback static size_t diff --git a/llarp/ev/ev.hpp b/llarp/ev/ev.hpp index 38f45f3e5..7e040104e 100644 --- a/llarp/ev/ev.hpp +++ b/llarp/ev/ev.hpp @@ -20,8 +20,6 @@ #include #ifdef _WIN32 -#include -#include // From the preview SDK, should take a look at that // periodically in case its definition changes #define UNIX_PATH_MAX 108 @@ -184,7 +182,7 @@ namespace llarp virtual ssize_t do_write(void* data, size_t sz) { - return uwrite(fd, (char*)data, sz); + return send(fd, (char*)data, sz, 0); } bool @@ -272,7 +270,7 @@ namespace llarp virtual ~win32_ev_io() { - uclose(fd); + closesocket(fd); }; }; #else diff --git a/llarp/ev/ev_win32.cpp b/llarp/ev/ev_win32.cpp index 9869b1bcc..766cbd5e8 100644 --- a/llarp/ev/ev_win32.cpp +++ b/llarp/ev/ev_win32.cpp @@ -234,7 +234,7 @@ exit_tun_loop() DeleteCriticalSection(&HandlerMtx); } } - +/* // now zero-copy ssize_t TCPWrite(llarp_tcp_conn* conn, const byte_t* ptr, size_t sz) @@ -730,5 +730,5 @@ llarp_win32_loop::tick_listeners() for(auto& func : m_Tickers) LogicCall(m_Logic, func); } - +*/ #endif diff --git a/llarp/ev/ev_win32.hpp b/llarp/ev/ev_win32.hpp index 495faeb95..4a6a7002d 100644 --- a/llarp/ev/ev_win32.hpp +++ b/llarp/ev/ev_win32.hpp @@ -112,7 +112,7 @@ struct win32_tun_io // // Not only that, the win32 IOCP facility handles timing on its own, you can // specify an interval to tick directly into the call to GetQueuedCompletionStatus(2) -struct llarp_win32_loop : public llarp_ev_loop +/*struct llarp_win32_loop : public llarp_ev_loop { upoll_t* upollfd; std::shared_ptr< llarp::Logic > m_Logic; @@ -183,6 +183,6 @@ struct llarp_win32_loop : public llarp_ev_loop void tick_listeners() override; }; - +*/ #endif #endif diff --git a/win32-setup/Makefile b/win32-setup/Makefile index 84b6acc59..a6ab718a4 100644 --- a/win32-setup/Makefile +++ b/win32-setup/Makefile @@ -19,7 +19,7 @@ mbedtls: wget https://tls.mbed.org/download/mbedtls-2.16.3-apache.tgz tar xvf mbedtls-2.16.3-apache.tgz patch -p0 -d mbedtls-2.16.3 < mbedtls-win32.patch - $(MAKE) -j48 -C mbedtls-2.16.3/library CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" LDFLAGS=$(LIBS) + $(MAKE) -j4 -C mbedtls-2.16.3/library CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" LDFLAGS=$(LIBS) mkdir -p lib; mkdir -p include cp mbedtls-2.16.3/library/*.a lib cp -r mbedtls-2.16.3/include/mbedtls include @@ -29,11 +29,7 @@ curl: tar xvf curl-7.66.0.tar.xz patch -p1 < curl-win32.patch cd curl-7.66.0; ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" LIBS=$(LIBS) --disable-shared --without-zlib --without-ssl --with-mbedtls=$(PWD) --enable-optimize --enable-http --disable-ftp --prefix=$(PWD) --disable-file --disable-ldap --disable-ldaps --disable-rtsp --enable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --enable-manual - $(MAKE) -j48 -C curl-7.66.0 install - $(MAKE) -C curl-7.66.0 clean - cd curl-7.66.0; ./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 CC=$(CC64) CXX=$(CXX64) CFLAGS="$(CFLAGS)" LIBS=$(LIBS) --disable-shared --without-zlib --without-ssl --with-winssl --enable-optimize --enable-http --disable-ftp --prefix=$(PWD) --disable-file --disable-ldap --disable-ldaps --disable-rtsp --enable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smb --disable-smtp --disable-gopher --enable-manual - $(MAKE) -j48 -C curl-7.66.0 - cp curl-7.66.0/lib/.libs/libcurl.a $(PWD)/lib64 + $(MAKE) -j4 -C curl-7.66.0 install lokinet-bootstrap.exe: mbedtls curl dbghelp cp bin/curl.exe $@ @@ -75,10 +71,10 @@ tap-win32: libuv: git clone https://github.com/libuv/libuv.git cd libuv; ./autogen.sh; ./configure --host=i686-w64-mingw32 --target=i686-w64-mingw32 CC=$(CC) CXX=$(CXX) CFLAGS="$(CFLAGS)" --disable-shared --prefix=$(PWD) - make -C libuv -j48 install - make -C libuv -j48 distclean + make -C libuv -j4 install + make -C libuv -j4 distclean cd libuv; ./configure --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 CC=$(CC64) CXX=$(CXX64) CFLAGS="$(CFLAGS)" --disable-shared - make -C libuv -j48 + make -C libuv -j4 cp libuv/.libs/libuv.a $(PWD)/lib64 clean: