mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
Split toxcore into layers.
This allows us to more clearly define interfaces between modules, and have the linker help us ensure that module boundaries are respected. The onion/tcp/net_crypto layer is a bit too large. This is due to a cyclic dependency (onion -> net_crypto -> TCP -> onion). We may or may not want to break that cycle in the future to allow the onion library to exist on its own without net_crypto.
This commit is contained in:
parent
e43bde37ea
commit
cebf64a588
116
CMakeLists.txt
116
CMakeLists.txt
|
@ -9,12 +9,20 @@ set(PROJECT_VERSION "0.0.0")
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Dependencies and configuration.
|
# :: Dependencies and configuration
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
set(CMAKE_MACOSX_RPATH ON)
|
set(CMAKE_MACOSX_RPATH ON)
|
||||||
|
|
||||||
|
option(LOGGING "Enable internal library logging" OFF)
|
||||||
|
if(LOGGING)
|
||||||
|
add_definitions(
|
||||||
|
-DTOX_LOGGER=1
|
||||||
|
-DLOGGER_LEVEL=LOG_DEBUG
|
||||||
|
-DLOGGER_OUTPUT_FILE="libtoxcore.log")
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(PkgConfig REQUIRED)
|
find_package(PkgConfig REQUIRED)
|
||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
@ -74,40 +82,78 @@ endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Libraries.
|
# :: Tox Core Library
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_library(toxcore ${LIBTYPE}
|
# LAYER 1: Crypto core
|
||||||
|
# --------------------
|
||||||
|
add_library(toxcrypto ${LIBTYPE}
|
||||||
|
toxcore/crypto_core.c)
|
||||||
|
target_link_libraries(toxcrypto ${LIBSODIUM_LIBRARIES})
|
||||||
|
|
||||||
|
# LAYER 2: Basic networking
|
||||||
|
# -------------------------
|
||||||
|
add_library(toxnetwork ${LIBTYPE}
|
||||||
|
toxcore/logger.c
|
||||||
|
toxcore/network.c
|
||||||
|
toxcore/util.c)
|
||||||
|
target_link_libraries(toxnetwork toxcrypto)
|
||||||
|
|
||||||
|
# LAYER 3: Distributed Hash Table
|
||||||
|
# -------------------------------
|
||||||
|
add_library(toxdht ${LIBTYPE}
|
||||||
toxcore/DHT.c
|
toxcore/DHT.c
|
||||||
toxcore/LAN_discovery.c
|
toxcore/LAN_discovery.c
|
||||||
toxcore/Messenger.c
|
toxcore/assoc.c
|
||||||
|
toxcore/ping.c
|
||||||
|
toxcore/ping_array.c)
|
||||||
|
target_link_libraries(toxdht toxnetwork)
|
||||||
|
|
||||||
|
# LAYER 4: Onion routing, TCP connections, crypto connections
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
add_library(toxnetcrypto ${LIBTYPE}
|
||||||
toxcore/TCP_client.c
|
toxcore/TCP_client.c
|
||||||
toxcore/TCP_connection.c
|
toxcore/TCP_connection.c
|
||||||
toxcore/TCP_server.c
|
toxcore/TCP_server.c
|
||||||
toxcore/assoc.c
|
|
||||||
toxcore/crypto_core.c
|
|
||||||
toxcore/friend_connection.c
|
|
||||||
toxcore/friend_requests.c
|
|
||||||
toxcore/group.c
|
|
||||||
toxcore/list.c
|
toxcore/list.c
|
||||||
toxcore/logger.c
|
|
||||||
toxcore/net_crypto.c
|
toxcore/net_crypto.c
|
||||||
toxcore/network.c
|
|
||||||
toxcore/onion.c
|
toxcore/onion.c
|
||||||
toxcore/onion_announce.c
|
toxcore/onion_announce.c
|
||||||
toxcore/onion_client.c
|
toxcore/onion_client.c)
|
||||||
toxcore/ping.c
|
target_link_libraries(toxnetcrypto toxdht)
|
||||||
toxcore/ping_array.c
|
|
||||||
toxcore/tox.c
|
|
||||||
toxcore/util.c)
|
|
||||||
|
|
||||||
target_link_libraries(toxcore ${LIBSODIUM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
|
# LAYER 5: Friend requests and connections
|
||||||
|
# ----------------------------------------
|
||||||
|
add_library(toxfriends ${LIBTYPE}
|
||||||
|
toxcore/friend_connection.c
|
||||||
|
toxcore/friend_requests.c)
|
||||||
|
target_link_libraries(toxfriends toxnetcrypto)
|
||||||
|
|
||||||
|
# LAYER 6: Tox messenger
|
||||||
|
# ----------------------
|
||||||
|
add_library(toxmessenger ${LIBTYPE}
|
||||||
|
toxcore/Messenger.c)
|
||||||
|
target_link_libraries(toxmessenger toxfriends)
|
||||||
|
|
||||||
|
# LAYER 7: Group chats
|
||||||
|
# --------------------
|
||||||
|
add_library(toxgroup ${LIBTYPE}
|
||||||
|
toxcore/group.c)
|
||||||
|
target_link_libraries(toxgroup toxmessenger)
|
||||||
|
|
||||||
|
# LAYER 8: Public API
|
||||||
|
# -------------------
|
||||||
|
add_library(toxcore ${LIBTYPE}
|
||||||
|
toxcore/tox.c)
|
||||||
|
target_link_libraries(toxcore toxgroup)
|
||||||
|
|
||||||
|
target_link_libraries(toxcore ${CMAKE_THREAD_LIBS_INIT})
|
||||||
if(CMAKE_THREAD_LIBS_INIT)
|
if(CMAKE_THREAD_LIBS_INIT)
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}")
|
||||||
endif()
|
endif()
|
||||||
if(RT_LIBRARIES)
|
if(RT_LIBRARIES)
|
||||||
target_link_libraries(toxcore ${RT_LIBRARIES})
|
target_link_libraries(toxnetwork ${RT_LIBRARIES})
|
||||||
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt")
|
set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -115,6 +161,13 @@ if(WIN32)
|
||||||
target_link_libraries(toxcore ws2_32 iphlpapi)
|
target_link_libraries(toxcore ws2_32 iphlpapi)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
#
|
||||||
|
# :: Audio/Video Library
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
add_library(toxav ${LIBTYPE}
|
add_library(toxav ${LIBTYPE}
|
||||||
toxav/audio.c
|
toxav/audio.c
|
||||||
toxav/bwcontroller.c
|
toxav/bwcontroller.c
|
||||||
|
@ -124,25 +177,27 @@ add_library(toxav ${LIBTYPE}
|
||||||
toxav/toxav.c
|
toxav/toxav.c
|
||||||
toxav/toxav_old.c
|
toxav/toxav_old.c
|
||||||
toxav/video.c)
|
toxav/video.c)
|
||||||
|
target_link_libraries(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||||
|
|
||||||
target_link_libraries(toxav toxcore)
|
|
||||||
target_link_libraries(toxav ${OPUS_LIBRARIES})
|
################################################################################
|
||||||
target_link_libraries(toxav ${VPX_LIBRARIES})
|
#
|
||||||
|
# :: ToxDNS and block encryption libraries
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
add_library(toxdns ${LIBTYPE}
|
add_library(toxdns ${LIBTYPE}
|
||||||
toxdns/toxdns.c)
|
toxdns/toxdns.c)
|
||||||
|
|
||||||
target_link_libraries(toxdns toxcore)
|
target_link_libraries(toxdns toxcore)
|
||||||
|
|
||||||
add_library(toxencryptsave ${LIBTYPE}
|
add_library(toxencryptsave ${LIBTYPE}
|
||||||
toxencryptsave/toxencryptsave.c)
|
toxencryptsave/toxencryptsave.c)
|
||||||
|
|
||||||
target_link_libraries(toxencryptsave toxcore)
|
target_link_libraries(toxencryptsave toxcore)
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Automated regression tests.
|
# :: Automated regression tests
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -176,7 +231,7 @@ auto_test(toxav_many_test)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Bootstrap daemon.
|
# :: Bootstrap daemon
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -200,7 +255,7 @@ endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Test programs.
|
# :: Test programs
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -236,7 +291,7 @@ endif()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
#
|
#
|
||||||
# :: Installation and pkg-config.
|
# :: Installation and pkg-config
|
||||||
#
|
#
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -274,8 +329,15 @@ install(FILES
|
||||||
install(TARGETS
|
install(TARGETS
|
||||||
toxav
|
toxav
|
||||||
toxcore
|
toxcore
|
||||||
|
toxcrypto
|
||||||
|
toxdht
|
||||||
toxdns
|
toxdns
|
||||||
toxencryptsave
|
toxencryptsave
|
||||||
|
toxfriends
|
||||||
|
toxgroup
|
||||||
|
toxmessenger
|
||||||
|
toxnetcrypto
|
||||||
|
toxnetwork
|
||||||
DESTINATION "lib")
|
DESTINATION "lib")
|
||||||
install(FILES
|
install(FILES
|
||||||
toxav/toxav.h
|
toxav/toxav.h
|
||||||
|
|
|
@ -6,5 +6,5 @@ Name: toxav
|
||||||
Description: Tox A/V library
|
Description: Tox A/V library
|
||||||
Requires: opus toxcore vpx
|
Requires: opus toxcore vpx
|
||||||
Version: @PROJECT_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
Libs: -L${libdir} -ltoxav @toxav_PKGCONFIG_LIBS@
|
Libs: -L${libdir} @toxav_PKGCONFIG_LIBS@ -ltoxav
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -6,5 +6,5 @@ Name: toxcore
|
||||||
Description: Tox protocol library
|
Description: Tox protocol library
|
||||||
Requires: libsodium
|
Requires: libsodium
|
||||||
Version: @PROJECT_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
Libs: -L${libdir} -ltoxcore @toxcore_PKGCONFIG_LIBS@
|
Libs: -L${libdir} @toxcore_PKGCONFIG_LIBS@ -ltoxcrypto -ltoxnetwork -ltoxdht -ltoxnetcrypto -ltoxfriends -ltoxmessenger -ltoxgroup -ltoxcore
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -6,5 +6,5 @@ Name: toxdns
|
||||||
Description: Tox DNS3 library
|
Description: Tox DNS3 library
|
||||||
Requires: toxcore
|
Requires: toxcore
|
||||||
Version: @PROJECT_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
Libs: -L${libdir} -ltoxdns @toxdns_PKGCONFIG_LIBS@
|
Libs: -L${libdir} @toxdns_PKGCONFIG_LIBS@ -ltoxdns
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -6,5 +6,5 @@ Name: toxencryptsave
|
||||||
Description: Tox block encryption library
|
Description: Tox block encryption library
|
||||||
Requires: toxcore
|
Requires: toxcore
|
||||||
Version: @PROJECT_VERSION@
|
Version: @PROJECT_VERSION@
|
||||||
Libs: -L${libdir} -ltoxencryptsave @toxencryptsave_PKGCONFIG_LIBS@
|
Libs: -L${libdir} @toxencryptsave_PKGCONFIG_LIBS@ -ltoxencryptsave
|
||||||
Cflags: -I${includedir}
|
Cflags: -I${includedir}
|
||||||
|
|
|
@ -12,7 +12,7 @@ git diff --exit-code
|
||||||
|
|
||||||
# Build toxcore and run tests.
|
# Build toxcore and run tests.
|
||||||
export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1"
|
export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1"
|
||||||
RUN $CMAKE -B$BUILD_DIR -H. -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX
|
RUN $CMAKE -B$BUILD_DIR -H. -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DLOGGING=ON
|
||||||
|
|
||||||
export CTEST_OUTPUT_ON_FAILURE=1
|
export CTEST_OUTPUT_ON_FAILURE=1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user