diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-15 22:07:49 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-16 17:36:18 +0100 |
commit | cebf64a588039c202880659a85d070126bcc68da (patch) | |
tree | e3271760a0060ab8cb3868eb548e599615fdd15a | |
parent | e43bde37eac9dc235619ee4c696796292e3e5256 (diff) |
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.
-rw-r--r-- | CMakeLists.txt | 116 | ||||
-rw-r--r-- | other/pkgconfig/toxav.pc.in | 2 | ||||
-rw-r--r-- | other/pkgconfig/toxcore.pc.in | 2 | ||||
-rw-r--r-- | other/pkgconfig/toxdns.pc.in | 2 | ||||
-rw-r--r-- | other/pkgconfig/toxencryptsave.pc.in | 2 | ||||
-rwxr-xr-x | other/travis/toxcore-script | 2 |
6 files changed, 94 insertions, 32 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b264d3f4..9b1ba642 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -9,12 +9,20 @@ set(PROJECT_VERSION "0.0.0") | |||
9 | 9 | ||
10 | ################################################################################ | 10 | ################################################################################ |
11 | # | 11 | # |
12 | # :: Dependencies and configuration. | 12 | # :: Dependencies and configuration |
13 | # | 13 | # |
14 | ################################################################################ | 14 | ################################################################################ |
15 | 15 | ||
16 | set(CMAKE_MACOSX_RPATH ON) | 16 | set(CMAKE_MACOSX_RPATH ON) |
17 | 17 | ||
18 | option(LOGGING "Enable internal library logging" OFF) | ||
19 | if(LOGGING) | ||
20 | add_definitions( | ||
21 | -DTOX_LOGGER=1 | ||
22 | -DLOGGER_LEVEL=LOG_DEBUG | ||
23 | -DLOGGER_OUTPUT_FILE="libtoxcore.log") | ||
24 | endif() | ||
25 | |||
18 | find_package(PkgConfig REQUIRED) | 26 | find_package(PkgConfig REQUIRED) |
19 | find_package(Threads REQUIRED) | 27 | find_package(Threads REQUIRED) |
20 | 28 | ||
@@ -74,40 +82,78 @@ endif() | |||
74 | 82 | ||
75 | ################################################################################ | 83 | ################################################################################ |
76 | # | 84 | # |
77 | # :: Libraries. | 85 | # :: Tox Core Library |
78 | # | 86 | # |
79 | ################################################################################ | 87 | ################################################################################ |
80 | 88 | ||
81 | add_library(toxcore ${LIBTYPE} | 89 | # LAYER 1: Crypto core |
90 | # -------------------- | ||
91 | add_library(toxcrypto ${LIBTYPE} | ||
92 | toxcore/crypto_core.c) | ||
93 | target_link_libraries(toxcrypto ${LIBSODIUM_LIBRARIES}) | ||
94 | |||
95 | # LAYER 2: Basic networking | ||
96 | # ------------------------- | ||
97 | add_library(toxnetwork ${LIBTYPE} | ||
98 | toxcore/logger.c | ||
99 | toxcore/network.c | ||
100 | toxcore/util.c) | ||
101 | target_link_libraries(toxnetwork toxcrypto) | ||
102 | |||
103 | # LAYER 3: Distributed Hash Table | ||
104 | # ------------------------------- | ||
105 | add_library(toxdht ${LIBTYPE} | ||
82 | toxcore/DHT.c | 106 | toxcore/DHT.c |
83 | toxcore/LAN_discovery.c | 107 | toxcore/LAN_discovery.c |
84 | toxcore/Messenger.c | 108 | toxcore/assoc.c |
109 | toxcore/ping.c | ||
110 | toxcore/ping_array.c) | ||
111 | target_link_libraries(toxdht toxnetwork) | ||
112 | |||
113 | # LAYER 4: Onion routing, TCP connections, crypto connections | ||
114 | # ----------------------------------------------------------- | ||
115 | add_library(toxnetcrypto ${LIBTYPE} | ||
85 | toxcore/TCP_client.c | 116 | toxcore/TCP_client.c |
86 | toxcore/TCP_connection.c | 117 | toxcore/TCP_connection.c |
87 | toxcore/TCP_server.c | 118 | toxcore/TCP_server.c |
88 | toxcore/assoc.c | ||
89 | toxcore/crypto_core.c | ||
90 | toxcore/friend_connection.c | ||
91 | toxcore/friend_requests.c | ||
92 | toxcore/group.c | ||
93 | toxcore/list.c | 119 | toxcore/list.c |
94 | toxcore/logger.c | ||
95 | toxcore/net_crypto.c | 120 | toxcore/net_crypto.c |
96 | toxcore/network.c | ||
97 | toxcore/onion.c | 121 | toxcore/onion.c |
98 | toxcore/onion_announce.c | 122 | toxcore/onion_announce.c |
99 | toxcore/onion_client.c | 123 | toxcore/onion_client.c) |
100 | toxcore/ping.c | 124 | target_link_libraries(toxnetcrypto toxdht) |
101 | toxcore/ping_array.c | ||
102 | toxcore/tox.c | ||
103 | toxcore/util.c) | ||
104 | 125 | ||
105 | target_link_libraries(toxcore ${LIBSODIUM_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) | 126 | # LAYER 5: Friend requests and connections |
127 | # ---------------------------------------- | ||
128 | add_library(toxfriends ${LIBTYPE} | ||
129 | toxcore/friend_connection.c | ||
130 | toxcore/friend_requests.c) | ||
131 | target_link_libraries(toxfriends toxnetcrypto) | ||
132 | |||
133 | # LAYER 6: Tox messenger | ||
134 | # ---------------------- | ||
135 | add_library(toxmessenger ${LIBTYPE} | ||
136 | toxcore/Messenger.c) | ||
137 | target_link_libraries(toxmessenger toxfriends) | ||
138 | |||
139 | # LAYER 7: Group chats | ||
140 | # -------------------- | ||
141 | add_library(toxgroup ${LIBTYPE} | ||
142 | toxcore/group.c) | ||
143 | target_link_libraries(toxgroup toxmessenger) | ||
144 | |||
145 | # LAYER 8: Public API | ||
146 | # ------------------- | ||
147 | add_library(toxcore ${LIBTYPE} | ||
148 | toxcore/tox.c) | ||
149 | target_link_libraries(toxcore toxgroup) | ||
150 | |||
151 | target_link_libraries(toxcore ${CMAKE_THREAD_LIBS_INIT}) | ||
106 | if(CMAKE_THREAD_LIBS_INIT) | 152 | if(CMAKE_THREAD_LIBS_INIT) |
107 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}") | 153 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-l${CMAKE_THREAD_LIBS_INIT}") |
108 | endif() | 154 | endif() |
109 | if(RT_LIBRARIES) | 155 | if(RT_LIBRARIES) |
110 | target_link_libraries(toxcore ${RT_LIBRARIES}) | 156 | target_link_libraries(toxnetwork ${RT_LIBRARIES}) |
111 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt") | 157 | set(toxcore_PKGCONFIG_LIBS ${toxcore_PKGCONFIG_LIBS} "-lrt") |
112 | endif() | 158 | endif() |
113 | 159 | ||
@@ -115,6 +161,13 @@ if(WIN32) | |||
115 | target_link_libraries(toxcore ws2_32 iphlpapi) | 161 | target_link_libraries(toxcore ws2_32 iphlpapi) |
116 | endif() | 162 | endif() |
117 | 163 | ||
164 | |||
165 | ################################################################################ | ||
166 | # | ||
167 | # :: Audio/Video Library | ||
168 | # | ||
169 | ################################################################################ | ||
170 | |||
118 | add_library(toxav ${LIBTYPE} | 171 | add_library(toxav ${LIBTYPE} |
119 | toxav/audio.c | 172 | toxav/audio.c |
120 | toxav/bwcontroller.c | 173 | toxav/bwcontroller.c |
@@ -124,25 +177,27 @@ add_library(toxav ${LIBTYPE} | |||
124 | toxav/toxav.c | 177 | toxav/toxav.c |
125 | toxav/toxav_old.c | 178 | toxav/toxav_old.c |
126 | toxav/video.c) | 179 | toxav/video.c) |
180 | target_link_libraries(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) | ||
181 | |||
127 | 182 | ||
128 | target_link_libraries(toxav toxcore) | 183 | ################################################################################ |
129 | target_link_libraries(toxav ${OPUS_LIBRARIES}) | 184 | # |
130 | target_link_libraries(toxav ${VPX_LIBRARIES}) | 185 | # :: ToxDNS and block encryption libraries |
186 | # | ||
187 | ################################################################################ | ||
131 | 188 | ||
132 | add_library(toxdns ${LIBTYPE} | 189 | add_library(toxdns ${LIBTYPE} |
133 | toxdns/toxdns.c) | 190 | toxdns/toxdns.c) |
134 | |||
135 | target_link_libraries(toxdns toxcore) | 191 | target_link_libraries(toxdns toxcore) |
136 | 192 | ||
137 | add_library(toxencryptsave ${LIBTYPE} | 193 | add_library(toxencryptsave ${LIBTYPE} |
138 | toxencryptsave/toxencryptsave.c) | 194 | toxencryptsave/toxencryptsave.c) |
139 | |||
140 | target_link_libraries(toxencryptsave toxcore) | 195 | target_link_libraries(toxencryptsave toxcore) |
141 | 196 | ||
142 | 197 | ||
143 | ################################################################################ | 198 | ################################################################################ |
144 | # | 199 | # |
145 | # :: Automated regression tests. | 200 | # :: Automated regression tests |
146 | # | 201 | # |
147 | ################################################################################ | 202 | ################################################################################ |
148 | 203 | ||
@@ -176,7 +231,7 @@ auto_test(toxav_many_test) | |||
176 | 231 | ||
177 | ################################################################################ | 232 | ################################################################################ |
178 | # | 233 | # |
179 | # :: Bootstrap daemon. | 234 | # :: Bootstrap daemon |
180 | # | 235 | # |
181 | ################################################################################ | 236 | ################################################################################ |
182 | 237 | ||
@@ -200,7 +255,7 @@ endif() | |||
200 | 255 | ||
201 | ################################################################################ | 256 | ################################################################################ |
202 | # | 257 | # |
203 | # :: Test programs. | 258 | # :: Test programs |
204 | # | 259 | # |
205 | ################################################################################ | 260 | ################################################################################ |
206 | 261 | ||
@@ -236,7 +291,7 @@ endif() | |||
236 | 291 | ||
237 | ################################################################################ | 292 | ################################################################################ |
238 | # | 293 | # |
239 | # :: Installation and pkg-config. | 294 | # :: Installation and pkg-config |
240 | # | 295 | # |
241 | ################################################################################ | 296 | ################################################################################ |
242 | 297 | ||
@@ -274,8 +329,15 @@ install(FILES | |||
274 | install(TARGETS | 329 | install(TARGETS |
275 | toxav | 330 | toxav |
276 | toxcore | 331 | toxcore |
332 | toxcrypto | ||
333 | toxdht | ||
277 | toxdns | 334 | toxdns |
278 | toxencryptsave | 335 | toxencryptsave |
336 | toxfriends | ||
337 | toxgroup | ||
338 | toxmessenger | ||
339 | toxnetcrypto | ||
340 | toxnetwork | ||
279 | DESTINATION "lib") | 341 | DESTINATION "lib") |
280 | install(FILES | 342 | install(FILES |
281 | toxav/toxav.h | 343 | toxav/toxav.h |
diff --git a/other/pkgconfig/toxav.pc.in b/other/pkgconfig/toxav.pc.in index bb480d72..6b56500b 100644 --- a/other/pkgconfig/toxav.pc.in +++ b/other/pkgconfig/toxav.pc.in | |||
@@ -6,5 +6,5 @@ Name: toxav | |||
6 | Description: Tox A/V library | 6 | Description: Tox A/V library |
7 | Requires: opus toxcore vpx | 7 | Requires: opus toxcore vpx |
8 | Version: @PROJECT_VERSION@ | 8 | Version: @PROJECT_VERSION@ |
9 | Libs: -L${libdir} -ltoxav @toxav_PKGCONFIG_LIBS@ | 9 | Libs: -L${libdir} @toxav_PKGCONFIG_LIBS@ -ltoxav |
10 | Cflags: -I${includedir} | 10 | Cflags: -I${includedir} |
diff --git a/other/pkgconfig/toxcore.pc.in b/other/pkgconfig/toxcore.pc.in index 09556494..c77cb5be 100644 --- a/other/pkgconfig/toxcore.pc.in +++ b/other/pkgconfig/toxcore.pc.in | |||
@@ -6,5 +6,5 @@ Name: toxcore | |||
6 | Description: Tox protocol library | 6 | Description: Tox protocol library |
7 | Requires: libsodium | 7 | Requires: libsodium |
8 | Version: @PROJECT_VERSION@ | 8 | Version: @PROJECT_VERSION@ |
9 | Libs: -L${libdir} -ltoxcore @toxcore_PKGCONFIG_LIBS@ | 9 | Libs: -L${libdir} @toxcore_PKGCONFIG_LIBS@ -ltoxcrypto -ltoxnetwork -ltoxdht -ltoxnetcrypto -ltoxfriends -ltoxmessenger -ltoxgroup -ltoxcore |
10 | Cflags: -I${includedir} | 10 | Cflags: -I${includedir} |
diff --git a/other/pkgconfig/toxdns.pc.in b/other/pkgconfig/toxdns.pc.in index 92f3ad40..0f69130c 100644 --- a/other/pkgconfig/toxdns.pc.in +++ b/other/pkgconfig/toxdns.pc.in | |||
@@ -6,5 +6,5 @@ Name: toxdns | |||
6 | Description: Tox DNS3 library | 6 | Description: Tox DNS3 library |
7 | Requires: toxcore | 7 | Requires: toxcore |
8 | Version: @PROJECT_VERSION@ | 8 | Version: @PROJECT_VERSION@ |
9 | Libs: -L${libdir} -ltoxdns @toxdns_PKGCONFIG_LIBS@ | 9 | Libs: -L${libdir} @toxdns_PKGCONFIG_LIBS@ -ltoxdns |
10 | Cflags: -I${includedir} | 10 | Cflags: -I${includedir} |
diff --git a/other/pkgconfig/toxencryptsave.pc.in b/other/pkgconfig/toxencryptsave.pc.in index 30f47b36..bd717f53 100644 --- a/other/pkgconfig/toxencryptsave.pc.in +++ b/other/pkgconfig/toxencryptsave.pc.in | |||
@@ -6,5 +6,5 @@ Name: toxencryptsave | |||
6 | Description: Tox block encryption library | 6 | Description: Tox block encryption library |
7 | Requires: toxcore | 7 | Requires: toxcore |
8 | Version: @PROJECT_VERSION@ | 8 | Version: @PROJECT_VERSION@ |
9 | Libs: -L${libdir} -ltoxencryptsave @toxencryptsave_PKGCONFIG_LIBS@ | 9 | Libs: -L${libdir} @toxencryptsave_PKGCONFIG_LIBS@ -ltoxencryptsave |
10 | Cflags: -I${includedir} | 10 | Cflags: -I${includedir} |
diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index ed9377fe..20ad6d8e 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script | |||
@@ -12,7 +12,7 @@ git diff --exit-code | |||
12 | 12 | ||
13 | # Build toxcore and run tests. | 13 | # Build toxcore and run tests. |
14 | export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1" | 14 | export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1" |
15 | RUN $CMAKE -B$BUILD_DIR -H. -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX | 15 | RUN $CMAKE -B$BUILD_DIR -H. -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX -DLOGGING=ON |
16 | 16 | ||
17 | export CTEST_OUTPUT_ON_FAILURE=1 | 17 | export CTEST_OUTPUT_ON_FAILURE=1 |
18 | 18 | ||