Skip to content

Commit

Permalink
[+] Add Windows support (beta) (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanbo-zhang authored Apr 27, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent d1348ec commit 109918f
Showing 40 changed files with 686 additions and 280 deletions.
107 changes: 87 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -17,9 +17,40 @@ if(NOT SSL_TYPE)
set(SSL_TYPE "babassl")
endif()

# PATH of ssl
if(NOT SSL_PATH)
set(SSL_PATH "/usr/local/babassl")
if(${SSL_TYPE} MATCHES "babassl")
# PATH of ssl
if(NOT SSL_PATH)
set(SSL_PATH "/usr/local/babassl")
endif()

# ssl lib denpendency
if(NOT SSL_LIB_PATH)
set(SSL_LIB_PATH
${SSL_PATH}/lib/libssl.a
${SSL_PATH}/lib/libcrypto.a
)
endif()
elseif(${SSL_TYPE} MATCHES "boringssl")
# PATH of ssl
if(NOT SSL_PATH)
set(SSL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party/boringssl)
endif()

# ssl lib denpendency
if(NOT SSL_LIB_PATH)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions(-DNOCRYPT=1)
set(SSL_LIB_PATH
${SSL_PATH}/build/ssl/${CMAKE_BUILD_TYPE}/ssl.lib
${SSL_PATH}/build/crypto/${CMAKE_BUILD_TYPE}/crypto.lib
)
else()
set(SSL_LIB_PATH
${SSL_PATH}/build/ssl/libssl.a
${SSL_PATH}/build/crypto/libcrypto.a
)
endif()
endif()
endif()

# ssl include path
@@ -29,13 +60,10 @@ if(NOT SSL_INC_PATH)
)
endif()

# ssl lib denpendency
if(NOT SSL_LIB_PATH)
set(SSL_LIB_PATH
${SSL_PATH}/lib/libssl.a
${SSL_PATH}/lib/libcrypto.a
)
endif()
MESSAGE("SSL_TYPE= ${SSL_TYPE}")
MESSAGE("SSL_PATH= ${SSL_PATH}")
MESSAGE("SSL_LIB_PATH= ${SSL_LIB_PATH}")
MESSAGE("SSL_INC_PATH= ${SSL_INC_PATH}")

# print tls traffic secret in keylog
if(XQC_PRINT_SECRET)
@@ -65,8 +93,15 @@ endif()


# C_FLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -std=gnu11 -Werror -Wall -Wno-unused -Wno-pointer-sign -Wno-format-security -DNDEBUG_PRINT -DNPRINT_MALLOC ")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -std=gnu11 -Werror -Wall -Wno-unused -Wno-pointer-sign -Wno-format-security -DNDEBUG_PRINT -DNPRINT_MALLOC -DXQC_DEBUG ")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O2 -std=gnu11 -Wall -DNDEBUG_PRINT -DNPRINT_MALLOC ")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g -O0 -std=gnu11 -Wall -DNDEBUG_PRINT -DNPRINT_MALLOC -DXQC_DEBUG ")

if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-unused -Wno-pointer-sign -Wno-format-security ")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -Wno-unused -Wno-pointer-sign -Wno-format-security ")
else()
add_definitions(-DXQC_SYS_WINDOWS=1)
endif()

# additional C_FLAGS on mac
if(PLATFORM STREQUAL "mac32")
@@ -263,10 +298,9 @@ include_directories(${SSL_INC_PATH})
include_directories(${CMAKE_SOURCE_DIR}/)



##### build unittest, test client/server, demo client/server #####
if (XQC_ENABLE_TESTING)
# CUnit
# CUnit TODO: fix test unit on windows
find_package(CUnit 2.1)
enable_testing()
set(HAVE_CUNIT ${CUNIT_FOUND})
@@ -275,10 +309,24 @@ if (XQC_ENABLE_TESTING)
endif()

add_subdirectory(tests)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/test)

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
# used wingetopt on windows
if(NOT GETOPT_INC_PATH)
set(GETOPT_INC_PATH
${CMAKE_SOURCE_DIR}/third_party/wingetopt
)
endif()
MESSAGE("GETOPT_INC_PATH= ${GETOPT_INC_PATH}")

include_directories(${GETOPT_INC_PATH}/src)
set(GETOPT_SOURCES "${GETOPT_INC_PATH}/src/getopt.c")
endif()

### test client/server ###
add_executable(test_server tests/test_server.c)
add_executable(test_client tests/test_client.c)
add_executable(test_server tests/test_server.c ${GETOPT_SOURCES})
add_executable(test_client tests/test_client.c ${GETOPT_SOURCES})

### hq demo client/server ###
set(
@@ -300,10 +348,24 @@ if (XQC_ENABLE_TESTING)
"demo/demo_server.c"
)

add_executable(demo_server ${DEMO_SERVER_SOURCES})
add_executable(demo_client ${DEMO_CLIENT_SOURCES})

link_directories(/usr/local/lib)
add_executable(demo_server ${DEMO_SERVER_SOURCES} ${GETOPT_SOURCES})
add_executable(demo_client ${DEMO_CLIENT_SOURCES} ${GETOPT_SOURCES})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
if (NOT EVENT_LIB_DIR)
message("YOU NEED SET -DEVENT_LIB_DIR=your_event_path, eg:-DEVENT_LIB_DIR=D:/project/vcpkg/packages/libevent_x64-windows-static")
endif()

include_directories( ${EVENT_LIB_DIR}/include )
link_directories( ${EVENT_LIB_DIR}/lib )

SET(EVENT_LIB_PATH
${EVENT_LIB_DIR}/lib/event.lib
${EVENT_LIB_DIR}/lib/event_core.lib
${EVENT_LIB_DIR}/lib/event_extra.lib
)
else()
link_directories( /usr/local/lib )
endif()

if(PLATFORM STREQUAL "mac32")
target_link_libraries(test_server xquic -lm ${CMAKE_CURRENT_SOURCE_DIR}/../libevent32/lib/libevent.dylib)
@@ -315,6 +377,11 @@ if (XQC_ENABLE_TESTING)
target_link_libraries(test_client xquic -lm -L/usr/local/lib -levent)
target_link_libraries(demo_server xquic -lm -L/usr/local/lib -levent)
target_link_libraries(demo_client xquic -lm -L/usr/local/lib -levent)
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows")
target_link_libraries(test_server xquic ${EVENT_LIB_PATH} -lm)
target_link_libraries(test_client xquic ${EVENT_LIB_PATH} -lm)
target_link_libraries(demo_server xquic ${EVENT_LIB_PATH} -lm)
target_link_libraries(demo_client xquic ${EVENT_LIB_PATH} -lm)
else()
target_link_libraries(test_server xquic -levent -lm)
target_link_libraries(test_client xquic -levent -lm)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ XQUIC Library released by Alibaba is …

**a client and server implementation of QUIC and HTTP/3 as specified by the IETF.** Currently supported QUIC versions are v1 and draft-29.

**OS and platform agnostic.** It currently supports Android, iOS, Linux and macOS. Most of the code is used in our own products, and has been tested at scale on android, iOS apps, as well as servers.
**OS and platform agnostic.** It currently supports Android, iOS, Linux, macOS and Windows. Most of the code is used in our own products, and has been tested at scale on android, iOS apps, as well as servers.

**still in active development.** [Interoperability](https://interop.seemann.io/) is regularly tested with other QUIC implementations.

12 changes: 0 additions & 12 deletions demo/common.h
Original file line number Diff line number Diff line change
@@ -94,16 +94,4 @@ xqc_demo_read_file_data(char * data, size_t data_len, char *filename)
return ret;
}


static inline uint64_t
xqc_demo_now()
{
/* get microsecond unit time */
struct timeval tv;
gettimeofday(&tv, NULL);
uint64_t ul = tv.tv_sec * (uint64_t)1000000 + tv.tv_usec;
return ul;
}


#endif
Loading

0 comments on commit 109918f

Please sign in to comment.