summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-21 10:51:58 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-10-02 23:54:03 +0100
commitb8b9789a6975266433904b0ab4d381a9f3317986 (patch)
tree22a472dcc207a712fc7bb8abf44c54dd211431bc
parent66e1bb4510f69e3361ff95ebeaae42ee51a70675 (diff)
Rebuild apidsl'd headers in cmake.
- Moved apidsl headers next to their generated versions. In the future, perhaps all (or most) headers will be apidsl-generated, so the sources should stay together. - Try to find apidsl/apigen binary and astyle binary and use it for the format test. Don't run the format test if these can't be found.
-rw-r--r--CMakeLists.txt72
-rw-r--r--cmake/ApiDsl.cmake29
-rw-r--r--docs/apidsl.md (renamed from other/apidsl/README.md)8
-rw-r--r--other/astyle/README.md2
-rwxr-xr-xother/astyle/format-source17
-rwxr-xr-xother/version-sync8
-rw-r--r--toxav/toxav.api.h (renamed from other/apidsl/toxav.in.h)0
-rw-r--r--toxcore/tox.api.h (renamed from other/apidsl/tox.in.h)4
-rw-r--r--toxcore/tox.h4
9 files changed, 105 insertions, 39 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3c930f16..9e46741e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,6 +18,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
18# 18#
19################################################################################ 19################################################################################
20 20
21include(ApiDsl)
21include(CheckCCompilerFlag) 22include(CheckCCompilerFlag)
22include(ModulePackage) 23include(ModulePackage)
23 24
@@ -98,7 +99,8 @@ set(toxcore_PKGCONFIG_LIBS)
98# LAYER 1: Crypto core 99# LAYER 1: Crypto core
99# -------------------- 100# --------------------
100add_module(toxcrypto 101add_module(toxcrypto
101 toxcore/crypto_core.c) 102 toxcore/crypto_core.c
103 toxcore/crypto_core.h)
102target_link_modules(toxcrypto ${LIBSODIUM_LIBRARIES}) 104target_link_modules(toxcrypto ${LIBSODIUM_LIBRARIES})
103if(WIN32) 105if(WIN32)
104 target_link_modules(toxcrypto ws2_32) # for htonl 106 target_link_modules(toxcrypto ws2_32) # for htonl
@@ -108,8 +110,11 @@ endif()
108# ------------------------- 110# -------------------------
109add_module(toxnetwork 111add_module(toxnetwork
110 toxcore/logger.c 112 toxcore/logger.c
113 toxcore/logger.h
111 toxcore/network.c 114 toxcore/network.c
112 toxcore/util.c) 115 toxcore/network.h
116 toxcore/util.c
117 toxcore/util.h)
113target_link_modules(toxnetwork toxcrypto) 118target_link_modules(toxnetwork toxcrypto)
114 119
115if(CMAKE_THREAD_LIBS_INIT) 120if(CMAKE_THREAD_LIBS_INIT)
@@ -131,51 +136,71 @@ endif()
131# ------------------------------- 136# -------------------------------
132add_module(toxdht 137add_module(toxdht
133 toxcore/DHT.c 138 toxcore/DHT.c
139 toxcore/DHT.h
134 toxcore/LAN_discovery.c 140 toxcore/LAN_discovery.c
141 toxcore/LAN_discovery.h
135 toxcore/assoc.c 142 toxcore/assoc.c
143 toxcore/assoc.h
136 toxcore/ping.c 144 toxcore/ping.c
137 toxcore/ping_array.c) 145 toxcore/ping.h
146 toxcore/ping_array.c
147 toxcore/ping_array.h)
138target_link_modules(toxdht toxnetwork) 148target_link_modules(toxdht toxnetwork)
139 149
140# LAYER 4: Onion routing, TCP connections, crypto connections 150# LAYER 4: Onion routing, TCP connections, crypto connections
141# ----------------------------------------------------------- 151# -----------------------------------------------------------
142add_module(toxnetcrypto 152add_module(toxnetcrypto
143 toxcore/TCP_client.c 153 toxcore/TCP_client.c
154 toxcore/TCP_client.h
144 toxcore/TCP_connection.c 155 toxcore/TCP_connection.c
156 toxcore/TCP_connection.h
145 toxcore/TCP_server.c 157 toxcore/TCP_server.c
158 toxcore/TCP_server.h
146 toxcore/list.c 159 toxcore/list.c
160 toxcore/list.h
147 toxcore/net_crypto.c 161 toxcore/net_crypto.c
162 toxcore/net_crypto.h
148 toxcore/onion.c 163 toxcore/onion.c
164 toxcore/onion.h
149 toxcore/onion_announce.c 165 toxcore/onion_announce.c
150 toxcore/onion_client.c) 166 toxcore/onion_announce.h
167 toxcore/onion_client.c
168 toxcore/onion_client.h)
151target_link_modules(toxnetcrypto toxdht) 169target_link_modules(toxnetcrypto toxdht)
152 170
153# LAYER 5: Friend requests and connections 171# LAYER 5: Friend requests and connections
154# ---------------------------------------- 172# ----------------------------------------
155add_module(toxfriends 173add_module(toxfriends
156 toxcore/friend_connection.c 174 toxcore/friend_connection.c
157 toxcore/friend_requests.c) 175 toxcore/friend_connection.h
176 toxcore/friend_requests.c
177 toxcore/friend_requests.h)
158target_link_modules(toxfriends toxnetcrypto) 178target_link_modules(toxfriends toxnetcrypto)
159 179
160# LAYER 6: Tox messenger 180# LAYER 6: Tox messenger
161# ---------------------- 181# ----------------------
162add_module(toxmessenger 182add_module(toxmessenger
163 toxcore/Messenger.c) 183 toxcore/Messenger.c
184 toxcore/Messenger.h)
164target_link_modules(toxmessenger toxfriends) 185target_link_modules(toxmessenger toxfriends)
165 186
166# LAYER 7: Group chats 187# LAYER 7: Group chats
167# -------------------- 188# --------------------
168add_module(toxgroup 189add_module(toxgroup
169 toxcore/group.c) 190 toxcore/group.c
191 toxcore/group.h)
170target_link_modules(toxgroup toxmessenger) 192target_link_modules(toxgroup toxmessenger)
171 193
172# LAYER 8: Public API 194# LAYER 8: Public API
173# ------------------- 195# -------------------
196apidsl(
197 toxcore/tox.api.h)
174add_module(toxcore 198add_module(toxcore
175 toxcore/tox.c) 199 toxcore/misc_tools.h
200 toxcore/tox.c
201 toxcore/tox.h)
176target_link_modules(toxcore toxgroup) 202target_link_modules(toxcore toxgroup)
177 203
178
179################################################################################ 204################################################################################
180# 205#
181# :: Audio/Video Library 206# :: Audio/Video Library
@@ -183,20 +208,29 @@ target_link_modules(toxcore toxgroup)
183################################################################################ 208################################################################################
184 209
185if(BUILD_TOXAV) 210if(BUILD_TOXAV)
211 apidsl(
212 toxav/toxav.api.h)
186 add_module(toxav 213 add_module(toxav
187 toxav/audio.c 214 toxav/audio.c
215 toxav/audio.h
188 toxav/bwcontroller.c 216 toxav/bwcontroller.c
217 toxav/bwcontroller.h
189 toxav/group.c 218 toxav/group.c
219 toxav/group.h
190 toxav/msi.c 220 toxav/msi.c
221 toxav/msi.h
191 toxav/ring_buffer.c 222 toxav/ring_buffer.c
223 toxav/ring_buffer.h
192 toxav/rtp.c 224 toxav/rtp.c
225 toxav/rtp.h
193 toxav/toxav.c 226 toxav/toxav.c
227 toxav/toxav.h
194 toxav/toxav_old.c 228 toxav/toxav_old.c
195 toxav/video.c) 229 toxav/video.c
230 toxav/video.h)
196 target_link_modules(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES}) 231 target_link_modules(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
197endif() 232endif()
198 233
199
200################################################################################ 234################################################################################
201# 235#
202# :: ToxDNS and block encryption libraries 236# :: ToxDNS and block encryption libraries
@@ -211,16 +245,20 @@ add_module(toxencryptsave
211 toxencryptsave/toxencryptsave.c) 245 toxencryptsave/toxencryptsave.c)
212target_link_modules(toxencryptsave toxcore) 246target_link_modules(toxencryptsave toxcore)
213 247
214
215################################################################################ 248################################################################################
216# 249#
217# :: Automated regression tests 250# :: Automated regression tests
218# 251#
219################################################################################ 252################################################################################
220 253
221add_test( 254if(APIDSL AND ASTYLE)
222 NAME format_test 255 add_test(
223 COMMAND ${CMAKE_SOURCE_DIR}/other/astyle/format-source "${CMAKE_SOURCE_DIR}") 256 NAME format_test
257 COMMAND ${CMAKE_SOURCE_DIR}/other/astyle/format-source
258 "${CMAKE_SOURCE_DIR}"
259 "${APIDSL}"
260 "${ASTYLE}")
261endif()
224 262
225function(auto_test target) 263function(auto_test target)
226 if(CHECK_FOUND) 264 if(CHECK_FOUND)
@@ -251,7 +289,6 @@ if(BUILD_TOXAV)
251 auto_test(toxav_many) 289 auto_test(toxav_many)
252endif() 290endif()
253 291
254
255################################################################################ 292################################################################################
256# 293#
257# :: Bootstrap daemon 294# :: Bootstrap daemon
@@ -279,7 +316,6 @@ if(LIBCONFIG_FOUND)
279 target_link_modules(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES}) 316 target_link_modules(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES})
280endif() 317endif()
281 318
282
283################################################################################ 319################################################################################
284# 320#
285# :: Test programs 321# :: Test programs
@@ -329,7 +365,6 @@ if(NOT WIN32)
329 target_link_modules(irc_syncbot toxcore) 365 target_link_modules(irc_syncbot toxcore)
330endif() 366endif()
331 367
332
333################################################################################ 368################################################################################
334# 369#
335# :: Installation and pkg-config 370# :: Installation and pkg-config
@@ -362,7 +397,6 @@ configure_file(
362 @ONLY 397 @ONLY
363) 398)
364 399
365
366install(FILES 400install(FILES
367 ${CMAKE_BINARY_DIR}/toxcore.pc 401 ${CMAKE_BINARY_DIR}/toxcore.pc
368 ${CMAKE_BINARY_DIR}/toxdns.pc 402 ${CMAKE_BINARY_DIR}/toxdns.pc
diff --git a/cmake/ApiDsl.cmake b/cmake/ApiDsl.cmake
new file mode 100644
index 00000000..777714ab
--- /dev/null
+++ b/cmake/ApiDsl.cmake
@@ -0,0 +1,29 @@
1################################################################################
2#
3# :: APIDSL regeneration
4#
5################################################################################
6
7find_program(APIDSL NAMES
8 apidsl
9 apidsl.native
10 apidsl.byte
11 ${CMAKE_SOURCE_DIR}/../apidsl/apigen.native)
12find_program(ASTYLE NAMES
13 astyle)
14
15function(apidsl)
16 if(APIDSL AND ASTYLE)
17 foreach(in_file ${ARGN})
18 get_filename_component(dirname ${in_file} DIRECTORY)
19 get_filename_component(filename ${in_file} NAME_WE)
20 set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h)
21 add_custom_command(
22 OUTPUT ${out_file}
23 COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}"
24 | "${ASTYLE}" --options="${CMAKE_SOURCE_DIR}/other/astyle/astylerc"
25 > "${out_file}"
26 DEPENDS ${in_file})
27 endforeach()
28 endif()
29endfunction()
diff --git a/other/apidsl/README.md b/docs/apidsl.md
index 00f92c85..96ff5d0d 100644
--- a/other/apidsl/README.md
+++ b/docs/apidsl.md
@@ -13,19 +13,19 @@ If you want to do it quickly and you don't have time for anything other than cop
13 13
14 14
151. Make sure that you have ``curl`` and ``>=astyle-2.03`` installed 151. Make sure that you have ``curl`` and ``>=astyle-2.03`` installed
162. Modify [``tox.in.h``](/other/apidsl/tox.in.h) 162. Modify [``tox.api.h``](/toxcore/tox.api.h)
173. Run command below ↓ 173. Run command below ↓
18 18
19Command to run from ``toxcore`` directory (quick way, involves using curl): 19Command to run from ``toxcore`` directory (quick way, involves using curl):
20```bash 20```bash
21# For tox.h: 21# For tox.h:
22curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \ 22curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
23 < other/apidsl/tox.in.h \ 23 < toxcore/tox.api.h \
24 | astyle --options=other/astyle/astylerc \ 24 | astyle --options=other/astyle/astylerc \
25 > toxcore/tox.h 25 > toxcore/tox.h
26# For toxav.h: 26# For toxav.h:
27curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \ 27curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
28 < other/apidsl/toxav.in.h \ 28 < toxav/toxav.api.h \
29 | astyle --options=other/astyle/astylerc \ 29 | astyle --options=other/astyle/astylerc \
30 > toxav/toxav.h 30 > toxav/toxav.h
31``` 31```
@@ -41,7 +41,7 @@ If you prefer to have more control over what is happening, there are steps below
41 41
421. Install [``apidsl``](https://github.com/TokTok/apidsl) 421. Install [``apidsl``](https://github.com/TokTok/apidsl)
432. Install ``astyle``, version 2.03 or later. 432. Install ``astyle``, version 2.03 or later.
443. Modify [``tox.in.h``](/other/apidsl/tox.in.h) 443. Modify [``tox.api.h``](/toxcore/tox.api.h)
454. Use ``apidsl`` ``??`` 454. Use ``apidsl`` ``??``
465. Parse generated ``tox.h`` with astyle, minimal command for it would be: 465. Parse generated ``tox.h`` with astyle, minimal command for it would be:
47```bash 47```bash
diff --git a/other/astyle/README.md b/other/astyle/README.md
index f68edf68..9ce34b8e 100644
--- a/other/astyle/README.md
+++ b/other/astyle/README.md
@@ -29,4 +29,4 @@ Copy [``astylerc``](/other/astyle/astylerc) to ``toxcore/.git/hooks``
29 29
30``astylerc`` - this file can be used in the pre-commit hook to try its best at making the code conform to the coding style of toxcore. 30``astylerc`` - this file can be used in the pre-commit hook to try its best at making the code conform to the coding style of toxcore.
31 31
32Furthermore, it is being used to format ``tox.h`` after using [``apidsl``](/other/apidsl) to generate it. \ No newline at end of file 32Furthermore, it is being used to format ``tox.h`` after using ``apidsl`` to generate it.
diff --git a/other/astyle/format-source b/other/astyle/format-source
index 47a4a420..624864ab 100755
--- a/other/astyle/format-source
+++ b/other/astyle/format-source
@@ -3,6 +3,8 @@
3set -e 3set -e
4 4
5SOURCE_DIR="$1" 5SOURCE_DIR="$1"
6APIDSL="$2"
7ASTYLE="$3"
6 8
7# Go to the source root. 9# Go to the source root.
8if [ -z "$SOURCE_DIR" ]; then 10if [ -z "$SOURCE_DIR" ]; then
@@ -20,10 +22,11 @@ if ! which "$ASTYLE"; then
20 exit 1 22 exit 1
21fi 23fi
22 24
23if [ -f ../apidsl/apigen.native ]; then 25if ! which "$APIDSL"; then
24 APIDSL=../apidsl/apigen.native 26 if [ -f ../apidsl/apigen.native ]; then
25else 27 APIDSL=../apidsl/apigen.native
26 APIDSL=apidsl_curl 28 else
29 APIDSL=apidsl_curl
27fi 30fi
28 31
29apidsl_curl() { 32apidsl_curl() {
@@ -31,10 +34,10 @@ apidsl_curl() {
31} 34}
32 35
33# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. 36# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h.
34$APIDSL other/apidsl/tox.in.h > toxcore/tox.h 37$APIDSL toxcore/tox.api.h > toxcore/tox.h
35$APIDSL other/apidsl/toxav.in.h > toxav/toxav.h 38$APIDSL toxav/toxav.api.h > toxav/toxav.h
36 39
37SOURCES=`find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"` 40SOURCES=`find . -name "*.[ch]" -and -not -name "*.api.h" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
38 41
39$ASTYLE -n --options=other/astyle/astylerc $SOURCES 42$ASTYLE -n --options=other/astyle/astylerc $SOURCES
40 43
diff --git a/other/version-sync b/other/version-sync
index 642e8177..3fb1aa80 100755
--- a/other/version-sync
+++ b/other/version-sync
@@ -21,8 +21,8 @@ update() {
21 fi 21 fi
22} 22}
23 23
24update "configure.ac" 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/' 24update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'
25 25
26update "other/apidsl/tox.in.h" 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/' 26update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
27update "other/apidsl/tox.in.h" 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/' 27update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
28update "other/apidsl/tox.in.h" 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/' 28update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'
diff --git a/other/apidsl/toxav.in.h b/toxav/toxav.api.h
index 6e3e9c17..6e3e9c17 100644
--- a/other/apidsl/toxav.in.h
+++ b/toxav/toxav.api.h
diff --git a/other/apidsl/tox.in.h b/toxcore/tox.api.h
index 3cad8f4b..aeac79d7 100644
--- a/other/apidsl/tox.in.h
+++ b/toxcore/tox.api.h
@@ -37,8 +37,8 @@ extern "C" {
37 37
38/***************************************************************************** 38/*****************************************************************************
39 * `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to * 39 * `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to *
40 * `tox.in.h`, located in `other/apidsl/`. For instructions on how to * 40 * `tox.api.h`, located in `toxcore/`. For instructions on how to *
41 * generate `tox.h` from `tox.in.h` please refer to `other/apidsl/README.md` * 41 * generate `tox.h` from `tox.api.h` please refer to `docs/apidsl.md` *
42 *****************************************************************************/ 42 *****************************************************************************/
43 43
44 44
diff --git a/toxcore/tox.h b/toxcore/tox.h
index 7b778611..c98aed38 100644
--- a/toxcore/tox.h
+++ b/toxcore/tox.h
@@ -35,8 +35,8 @@ extern "C" {
35 35
36/******************************************************************************* 36/*******************************************************************************
37 * `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to * 37 * `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to *
38 * `tox.in.h`, located in `other/apidsl/`. For instructions on how to * 38 * `tox.api.h`, located in `toxcore/`. For instructions on how to *
39 * generate `tox.h` from `tox.in.h` please refer to `other/apidsl/README.md` * 39 * generate `tox.h` from `tox.api.h` please refer to `docs/apidsl.md` *
40 ******************************************************************************/ 40 ******************************************************************************/
41 41
42 42