mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
chore: Simplify msvc build using vcpkg.
This commit is contained in:
parent
5cac6d7eb1
commit
b148a2afff
67
.github/workflows/ci.yml
vendored
67
.github/workflows/ci.yml
vendored
|
@ -44,6 +44,53 @@ jobs:
|
|||
- name: Run cimplefmt
|
||||
run: other/docker/cimplefmt/run -u $(find tox* -name "*.[ch]")
|
||||
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- run: .github/scripts/cmake-android armeabi-v7a
|
||||
- run: .github/scripts/cmake-android arm64-v8a
|
||||
- run: .github/scripts/cmake-android x86
|
||||
- run: .github/scripts/cmake-android x86_64
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build and test
|
||||
run: .github/scripts/cmake-osx
|
||||
|
||||
build-msvc:
|
||||
strategy:
|
||||
matrix:
|
||||
version: [2019, 2022]
|
||||
runs-on: windows-${{ matrix.version }}
|
||||
env:
|
||||
VCPKG_ROOT: "C:/vcpkg"
|
||||
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Export GitHub Actions cache environment variables
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
||||
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
||||
- name: Configure CMake
|
||||
run: cmake --preset windows-default
|
||||
- name: Build
|
||||
run: cmake --build _build
|
||||
- name: Test
|
||||
run: |
|
||||
cd _build
|
||||
ctest -j50 --output-on-failure --rerun-failed --repeat until-pass:6 --build-config Debug
|
||||
|
||||
build-windows:
|
||||
strategy:
|
||||
matrix:
|
||||
|
@ -56,26 +103,6 @@ jobs:
|
|||
- name: Cross compilation
|
||||
run: .github/scripts/cmake-win${{ matrix.bits }} script
|
||||
|
||||
build-macos:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Build and test
|
||||
run: .github/scripts/cmake-osx
|
||||
|
||||
build-android:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- run: .github/scripts/cmake-android armeabi-v7a
|
||||
- run: .github/scripts/cmake-android arm64-v8a
|
||||
- run: .github/scripts/cmake-android x86
|
||||
- run: .github/scripts/cmake-android x86_64
|
||||
|
||||
mypy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -14,6 +14,8 @@ Thumbs.db
|
|||
/_build
|
||||
/_install
|
||||
/tox-0.0.0*
|
||||
/.vs
|
||||
/CppProperties.json
|
||||
CMakeCache.txt
|
||||
CMakeFiles
|
||||
Makefile
|
||||
|
|
|
@ -81,7 +81,7 @@ find_package(GTest)
|
|||
set(CMAKE_MACOSX_RPATH ON)
|
||||
|
||||
# Set standard version for compiler.
|
||||
if(MSVC)
|
||||
if(MSVC AND MSVC_TOOLSET_VERSION LESS 143)
|
||||
# https://developercommunity.visualstudio.com/t/older-winsdk-headers-are-incompatible-with-zcprepr/1593479
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
else()
|
||||
|
@ -94,6 +94,35 @@ set(CMAKE_CXX_EXTENSIONS OFF)
|
|||
message(STATUS "Supported C compiler features = ${CMAKE_C_COMPILE_FEATURES}")
|
||||
message(STATUS "Supported C++ compiler features = ${CMAKE_CXX_COMPILE_FEATURES}")
|
||||
|
||||
# Enable some warnings if we know the compiler.
|
||||
if(MSVC)
|
||||
add_compile_options(/W4 /analyze)
|
||||
add_compile_options(/wd4100) # unreferenced formal parameter
|
||||
add_compile_options(/wd4267) # narrowing conversion
|
||||
add_compile_options(/wd4244) # narrowing conversion
|
||||
add_compile_options(/wd4127) # conditional expression is constant
|
||||
add_compile_options(/wd4995) # #pragma deprecated
|
||||
add_compile_options(/wd4018) # signed/unsigned compare
|
||||
add_compile_options(/wd4310) # cast truncates constant value
|
||||
add_compile_options(/wd4389) # signed/unsigned compare
|
||||
add_compile_options(/wd4245) # signed/unsigned assign/return/function call
|
||||
add_compile_options(/wd4200) # nonstandard extension used: zero-sized array in struct/union
|
||||
add_compile_options(/wd4702) # unreachable code
|
||||
add_compile_options(/wd6340) # unsigned int passed to signed parameter
|
||||
add_compile_options(/wd6326) # potential comparison of a constant with another constant
|
||||
|
||||
# TODO(iphydf): Look into these
|
||||
add_compile_options(/wd4996) # use WSAAddressToStringW() instead of WSAAddressToStringA()
|
||||
add_compile_options(/wd6255) # don't use alloca
|
||||
add_compile_options(/wd6385) # reading invalid data
|
||||
add_compile_options(/wd6001) # using uninitialized memory
|
||||
add_compile_options(/wd6101) # returning uninitialized memory
|
||||
add_compile_options(/wd6386) # buffer overrun
|
||||
add_compile_options(/wd6011) # NULL dereference
|
||||
add_compile_options(/wd6031) # sscanf return value ignored
|
||||
add_compile_options(/wd6387) # passing NULL to fwrite
|
||||
endif()
|
||||
|
||||
set(MIN_LOGGER_LEVEL "" CACHE STRING "Logging level to use (TRACE, DEBUG, INFO, WARNING, ERROR)")
|
||||
if(MIN_LOGGER_LEVEL)
|
||||
if(("${MIN_LOGGER_LEVEL}" STREQUAL "TRACE") OR
|
||||
|
@ -307,10 +336,14 @@ set(toxcore_SOURCES
|
|||
toxcore/tox_unpack.h
|
||||
toxcore/util.c
|
||||
toxcore/util.h)
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} unofficial-sodium::sodium)
|
||||
else()
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${LIBSODIUM_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${LIBSODIUM_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${LIBSODIUM_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${LIBSODIUM_CFLAGS_OTHER})
|
||||
endif()
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} libsodium)
|
||||
set(toxcore_API_HEADERS
|
||||
${toxcore_SOURCE_DIR}/toxcore/tox.h^tox
|
||||
|
@ -346,10 +379,14 @@ if(BUILD_TOXAV)
|
|||
set(toxcore_API_HEADERS ${toxcore_API_HEADERS}
|
||||
${toxcore_SOURCE_DIR}/toxav/toxav.h^toxav)
|
||||
|
||||
if(MSVC)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PkgConfig::OPUS PkgConfig::VPX)
|
||||
else()
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
set(toxcore_LINK_DIRECTORIES ${toxcore_LINK_DIRECTORIES} ${OPUS_LIBRARY_DIRS} ${VPX_LIBRARY_DIRS})
|
||||
set(toxcore_INCLUDE_DIRECTORIES ${toxcore_INCLUDE_DIRECTORIES} ${OPUS_INCLUDE_DIRS} ${VPX_INCLUDE_DIRS})
|
||||
set(toxcore_COMPILE_OPTIONS ${toxcore_COMPILE_OPTIONS} ${OPUS_CFLAGS_OTHER} ${VPX_CFLAGS_OTHER})
|
||||
endif()
|
||||
set(toxcore_PKGCONFIG_REQUIRES ${toxcore_PKGCONFIG_REQUIRES} opus vpx)
|
||||
endif()
|
||||
|
||||
|
@ -380,7 +417,6 @@ if(CMAKE_THREAD_LIBS_INIT)
|
|||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
|
||||
if(NSL_LIBRARIES)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ${NSL_LIBRARIES})
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lnsl)
|
||||
|
@ -396,9 +432,13 @@ if(SOCKET_LIBRARIES)
|
|||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lsocket)
|
||||
endif()
|
||||
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} Threads::Threads)
|
||||
endif()
|
||||
if(WIN32)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} ws2_32 iphlpapi)
|
||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} -lws2_32 -liphlpapi)
|
||||
set(toxcore_LINK_LIBRARIES ${toxcore_LINK_LIBRARIES} iphlpapi wsock32 ws2_32)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
|
@ -496,6 +536,14 @@ if(DHT_BOOTSTRAP)
|
|||
target_link_libraries(DHT_bootstrap PRIVATE toxcore_shared)
|
||||
endif()
|
||||
target_link_libraries(DHT_bootstrap PRIVATE misc_tools)
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE unofficial-sodium::sodium)
|
||||
endif()
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(DHT_bootstrap PRIVATE Threads::Threads)
|
||||
endif()
|
||||
install(TARGETS DHT_bootstrap RUNTIME DESTINATION bin)
|
||||
endif()
|
||||
|
||||
|
|
21
CMakePresets.json
Normal file
21
CMakePresets.json
Normal file
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"version": 3,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "windows-default",
|
||||
"binaryDir": "${sourceDir}/_build",
|
||||
"cacheVariables": {
|
||||
"ENABLE_SHARED": true,
|
||||
"ENABLE_STATIC": true,
|
||||
"AUTOTEST": true,
|
||||
"BUILD_MISC_TESTS": true,
|
||||
"BOOTSTRAP_DAEMON": false,
|
||||
"MUST_BUILD_TOXAV": true,
|
||||
"TEST_TIMEOUT_SECONDS": "60",
|
||||
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS": true,
|
||||
"CMAKE_COMPILE_WARNING_AS_ERROR": true,
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -9,6 +9,11 @@ if(TARGET toxcore_static)
|
|||
else()
|
||||
target_link_libraries(auto_test_support PRIVATE toxcore_shared)
|
||||
endif()
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(auto_test_support PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(auto_test_support PRIVATE Threads::Threads)
|
||||
endif()
|
||||
|
||||
function(auto_test target)
|
||||
add_executable(auto_${target}_test ${target}_test.c)
|
||||
|
@ -18,12 +23,15 @@ function(auto_test target)
|
|||
else()
|
||||
target_link_libraries(auto_${target}_test PRIVATE toxcore_shared)
|
||||
endif()
|
||||
if(NOT ARGV1 STREQUAL "DONT_RUN")
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(auto_${target}_test PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(auto_${target}_test PRIVATE Threads::Threads)
|
||||
endif()
|
||||
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
|
||||
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
|
||||
# add the source dir as environment variable, so the testdata can be found
|
||||
set_tests_properties(${target} PROPERTIES ENVIRONMENT "LLVM_PROFILE_FILE=${target}.profraw;srcdir=${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
auto_test(TCP)
|
||||
|
@ -89,6 +97,10 @@ if(BUILD_TOXAV)
|
|||
auto_test(toxav_basic)
|
||||
auto_test(toxav_many)
|
||||
|
||||
if(MSVC)
|
||||
target_link_libraries(auto_toxav_basic_test PRIVATE PkgConfig::VPX)
|
||||
target_link_libraries(auto_toxav_many_test PRIVATE PkgConfig::VPX)
|
||||
else()
|
||||
target_link_libraries(auto_toxav_basic_test PRIVATE ${VPX_LIBRARIES})
|
||||
target_link_directories(auto_toxav_basic_test PRIVATE ${VPX_LIBRARY_DIRS})
|
||||
target_include_directories(auto_toxav_basic_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
|
||||
|
@ -99,6 +111,7 @@ if(BUILD_TOXAV)
|
|||
target_include_directories(auto_toxav_many_test SYSTEM PRIVATE ${VPX_INCLUDE_DIRS})
|
||||
target_compile_options(auto_toxav_many_test PRIVATE ${VPX_CFLAGS_OTHER})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(PROXY_TEST)
|
||||
auto_test(proxy)
|
||||
|
|
|
@ -1,19 +1,26 @@
|
|||
###############################################################################
|
||||
#
|
||||
# :: For UNIX-like systems that have pkg-config.
|
||||
# :: For systems that have pkg-config.
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
include(ModulePackage)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
find_library(NSL_LIBRARIES nsl )
|
||||
find_library(RT_LIBRARIES rt )
|
||||
find_library(SOCKET_LIBRARIES socket)
|
||||
|
||||
find_package(pthreads QUIET)
|
||||
if(NOT TARGET PThreads4W::PThreads4W)
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
endif()
|
||||
|
||||
# For toxcore.
|
||||
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET)
|
||||
pkg_search_module(LIBSODIUM libsodium IMPORTED_TARGET REQUIRED)
|
||||
if(MSVC)
|
||||
find_package(unofficial-sodium REQUIRED)
|
||||
endif()
|
||||
|
||||
# For toxav.
|
||||
pkg_search_module(OPUS opus IMPORTED_TARGET)
|
||||
|
@ -27,56 +34,3 @@ endif()
|
|||
|
||||
# For tox-bootstrapd.
|
||||
pkg_search_module(LIBCONFIG libconfig IMPORTED_TARGET)
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# :: For MSVC Windows builds.
|
||||
#
|
||||
# These require specific installation paths of dependencies:
|
||||
# - libsodium in third-party/libsodium/Win32/Release/v140/dynamic
|
||||
# - pthreads in third-party/pthreads-win32/Pre-built.2
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
if(MSVC)
|
||||
# libsodium
|
||||
# ---------
|
||||
if(NOT LIBSODIUM_FOUND)
|
||||
find_library(LIBSODIUM_LIBRARIES
|
||||
NAMES sodium libsodium
|
||||
PATHS
|
||||
"third_party/libsodium/Win32/Release/v140/dynamic"
|
||||
"third_party/libsodium/x64/Release/v140/dynamic"
|
||||
)
|
||||
if(LIBSODIUM_LIBRARIES)
|
||||
include_directories("third_party/libsodium/include")
|
||||
set(LIBSODIUM_FOUND TRUE)
|
||||
message("libsodium: ${LIBSODIUM_LIBRARIES}")
|
||||
else()
|
||||
message(FATAL_ERROR "libsodium libraries not found")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# pthreads
|
||||
# --------
|
||||
if(CMAKE_USE_WIN32_THREADS_INIT)
|
||||
find_library(CMAKE_THREAD_LIBS_INIT
|
||||
NAMES pthreadVC2
|
||||
PATHS
|
||||
"third_party/pthreads-win32/Pre-built.2/lib/x86"
|
||||
"third_party/pthreads-win32/Pre-built.2/lib/x64"
|
||||
)
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
include_directories("third_party/pthreads-win32/Pre-built.2/include")
|
||||
add_definitions(-DHAVE_STRUCT_TIMESPEC)
|
||||
message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
|
||||
else()
|
||||
find_package(pthreads4w)
|
||||
if(NOT pthreads4w_FOUND)
|
||||
message(FATAL_ERROR "libpthreads libraries not found")
|
||||
endif()
|
||||
include_directories(${pthreads4w_INCLUDE_DIR})
|
||||
link_libraries(${pthreads4w_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -19,19 +19,17 @@ if(FULLY_STATIC)
|
|||
set(ENABLE_STATIC ON)
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
function(add_module lib)
|
||||
set(${lib}_SOURCES ${ARGN} PARENT_SCOPE)
|
||||
|
||||
if(ENABLE_SHARED)
|
||||
add_library(${lib}_shared SHARED ${ARGN})
|
||||
set_target_properties(${lib}_shared PROPERTIES OUTPUT_NAME ${lib})
|
||||
endif()
|
||||
if(ENABLE_STATIC)
|
||||
add_library(${lib}_static STATIC ${ARGN})
|
||||
if(NOT MSVC)
|
||||
set_target_properties(${lib}_static PROPERTIES OUTPUT_NAME ${lib})
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(install_module lib)
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
--align-reference=name
|
||||
|
||||
# Formatting Options
|
||||
--add-brackets
|
||||
--convert-tabs
|
||||
--max-code-length=120
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
0ac3f502265ed3c2a4fb2971d1f7b92ad20f900b8daa64b828fd5994c3d4af9d /usr/local/bin/tox-bootstrapd
|
||||
6d2321d58fa948279b28ae28a888672164eadaa985c43ce99ed0b71a69033c5c /usr/local/bin/tox-bootstrapd
|
||||
|
|
|
@ -8,10 +8,19 @@ if(TARGET toxcore_static)
|
|||
else()
|
||||
target_link_libraries(misc_tools PRIVATE toxcore_shared)
|
||||
endif()
|
||||
if(TARGET unofficial-sodium::sodium)
|
||||
target_link_libraries(misc_tools PRIVATE unofficial-sodium::sodium)
|
||||
else()
|
||||
target_link_libraries(misc_tools PRIVATE ${LIBSODIUM_LIBRARIES})
|
||||
target_link_directories(misc_tools PUBLIC ${LIBSODIUM_LIBRARY_DIRS})
|
||||
target_include_directories(misc_tools SYSTEM PRIVATE ${LIBSODIUM_INCLUDE_DIRS})
|
||||
target_compile_options(misc_tools PRIVATE ${LIBSODIUM_CFLAGS_OTHER})
|
||||
endif()
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(misc_tools PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(misc_tools PRIVATE Threads::Threads)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
#
|
||||
|
@ -27,4 +36,9 @@ if(BUILD_MISC_TESTS)
|
|||
else()
|
||||
target_link_libraries(Messenger_test PRIVATE toxcore_shared)
|
||||
endif()
|
||||
if(TARGET PThreads4W::PThreads4W)
|
||||
target_link_libraries(Messenger_test PRIVATE PThreads4W::PThreads4W)
|
||||
elseif(TARGET Threads::Threads)
|
||||
target_link_libraries(Messenger_test PRIVATE Threads::Threads)
|
||||
endif()
|
||||
endif()
|
||||
|
|
|
@ -511,7 +511,7 @@ int unpack_ip_port(IP_Port *ip_port, const uint8_t *data, uint16_t length, bool
|
|||
return -1;
|
||||
}
|
||||
|
||||
*ip_port = empty_ip_port;
|
||||
ipport_reset(ip_port);
|
||||
|
||||
if (is_ipv4) {
|
||||
const uint32_t size = 1 + SIZE_IP4 + sizeof(uint16_t);
|
||||
|
|
|
@ -243,11 +243,11 @@ static IP broadcast_ip(Family family_socket, Family family_broadcast)
|
|||
ip.ip.v6.uint8[15] = 0x01;
|
||||
} else if (net_family_is_ipv4(family_broadcast)) {
|
||||
ip.family = net_family_ipv6();
|
||||
ip.ip.v6 = ip6_broadcast;
|
||||
ip.ip.v6 = get_ip6_broadcast();
|
||||
}
|
||||
} else if (net_family_is_ipv4(family_socket) && net_family_is_ipv4(family_broadcast)) {
|
||||
ip.family = net_family_ipv4();
|
||||
ip.ip.v4 = ip4_broadcast;
|
||||
ip.ip.v4 = get_ip4_broadcast();
|
||||
}
|
||||
|
||||
return ip;
|
||||
|
|
|
@ -141,7 +141,7 @@ protected:
|
|||
ann2.ip_port_is_set = 1;
|
||||
ann2.tcp_relays_count = 1;
|
||||
ann2.tcp_relays[0].ip_port.ip.family = net_family_ipv4();
|
||||
ann2.tcp_relays[0].ip_port.ip.ip.v4 = ip4_broadcast;
|
||||
ann2.tcp_relays[0].ip_port.ip.ip.v4 = get_ip4_broadcast();
|
||||
ann2.tcp_relays[0].public_key[0] = 0xea;
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ TEST(ModList, UnpackingFromEmptyBufferFails)
|
|||
std::vector<uint8_t> packed(1);
|
||||
|
||||
Moderation mods{system_memory()};
|
||||
EXPECT_EQ(mod_list_unpack(&mods, packed.end().base(), 0, 1), -1);
|
||||
EXPECT_EQ(mod_list_unpack(&mods, packed.data(), 0, 1), -1);
|
||||
}
|
||||
|
||||
TEST(ModList, HashOfEmptyModListZeroesOutBuffer)
|
||||
|
|
|
@ -340,12 +340,20 @@ static void fill_addr6(const IP6 *ip, struct in6_addr *addr)
|
|||
#endif
|
||||
|
||||
static const IP empty_ip = {{0}};
|
||||
const IP_Port empty_ip_port = {{{0}}};
|
||||
|
||||
IP4 get_ip4_broadcast(void)
|
||||
{
|
||||
const IP4 ip4_broadcast = { INADDR_BROADCAST };
|
||||
return ip4_broadcast;
|
||||
}
|
||||
|
||||
IP6 get_ip6_broadcast(void)
|
||||
{
|
||||
const IP6 ip6_broadcast = {
|
||||
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
|
||||
};
|
||||
return ip6_broadcast;
|
||||
}
|
||||
|
||||
IP4 get_ip4_loopback(void)
|
||||
{
|
||||
|
@ -357,7 +365,7 @@ IP4 get_ip4_loopback(void)
|
|||
IP6 get_ip6_loopback(void)
|
||||
{
|
||||
/* in6addr_loopback isn't available everywhere, so we do it ourselves. */
|
||||
IP6 loopback = empty_ip_port.ip.ip.v6;
|
||||
IP6 loopback = empty_ip.ip.v6;
|
||||
loopback.uint8[15] = 1;
|
||||
return loopback;
|
||||
}
|
||||
|
@ -1452,6 +1460,7 @@ void ipport_reset(IP_Port *ipport)
|
|||
return;
|
||||
}
|
||||
|
||||
const IP_Port empty_ip_port = {{{0}}};
|
||||
*ipport = empty_ip_port;
|
||||
}
|
||||
|
||||
|
|
|
@ -183,7 +183,7 @@ typedef union IP4 {
|
|||
} IP4;
|
||||
|
||||
IP4 get_ip4_loopback(void);
|
||||
extern const IP4 ip4_broadcast;
|
||||
IP4 get_ip4_broadcast(void);
|
||||
|
||||
typedef union IP6 {
|
||||
uint8_t uint8[16];
|
||||
|
@ -193,7 +193,7 @@ typedef union IP6 {
|
|||
} IP6;
|
||||
|
||||
IP6 get_ip6_loopback(void);
|
||||
extern const IP6 ip6_broadcast;
|
||||
IP6 get_ip6_broadcast(void);
|
||||
|
||||
typedef union IP_Union {
|
||||
IP4 v4;
|
||||
|
@ -210,8 +210,6 @@ typedef struct IP_Port {
|
|||
uint16_t port;
|
||||
} IP_Port;
|
||||
|
||||
extern const IP_Port empty_ip_port;
|
||||
|
||||
typedef struct Socket {
|
||||
int sock;
|
||||
} Socket;
|
||||
|
|
11
vcpkg.json
Normal file
11
vcpkg.json
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
|
||||
"dependencies": [
|
||||
"gtest",
|
||||
"libsodium",
|
||||
"libvpx",
|
||||
"opus",
|
||||
"pthreads",
|
||||
"winsock2"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user