mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
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.
This commit is contained in:
parent
66e1bb4510
commit
b8b9789a69
|
@ -18,6 +18,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|||
#
|
||||
################################################################################
|
||||
|
||||
include(ApiDsl)
|
||||
include(CheckCCompilerFlag)
|
||||
include(ModulePackage)
|
||||
|
||||
|
@ -98,7 +99,8 @@ set(toxcore_PKGCONFIG_LIBS)
|
|||
# LAYER 1: Crypto core
|
||||
# --------------------
|
||||
add_module(toxcrypto
|
||||
toxcore/crypto_core.c)
|
||||
toxcore/crypto_core.c
|
||||
toxcore/crypto_core.h)
|
||||
target_link_modules(toxcrypto ${LIBSODIUM_LIBRARIES})
|
||||
if(WIN32)
|
||||
target_link_modules(toxcrypto ws2_32) # for htonl
|
||||
|
@ -108,8 +110,11 @@ endif()
|
|||
# -------------------------
|
||||
add_module(toxnetwork
|
||||
toxcore/logger.c
|
||||
toxcore/logger.h
|
||||
toxcore/network.c
|
||||
toxcore/util.c)
|
||||
toxcore/network.h
|
||||
toxcore/util.c
|
||||
toxcore/util.h)
|
||||
target_link_modules(toxnetwork toxcrypto)
|
||||
|
||||
if(CMAKE_THREAD_LIBS_INIT)
|
||||
|
@ -131,51 +136,71 @@ endif()
|
|||
# -------------------------------
|
||||
add_module(toxdht
|
||||
toxcore/DHT.c
|
||||
toxcore/DHT.h
|
||||
toxcore/LAN_discovery.c
|
||||
toxcore/LAN_discovery.h
|
||||
toxcore/assoc.c
|
||||
toxcore/assoc.h
|
||||
toxcore/ping.c
|
||||
toxcore/ping_array.c)
|
||||
toxcore/ping.h
|
||||
toxcore/ping_array.c
|
||||
toxcore/ping_array.h)
|
||||
target_link_modules(toxdht toxnetwork)
|
||||
|
||||
# LAYER 4: Onion routing, TCP connections, crypto connections
|
||||
# -----------------------------------------------------------
|
||||
add_module(toxnetcrypto
|
||||
toxcore/TCP_client.c
|
||||
toxcore/TCP_client.h
|
||||
toxcore/TCP_connection.c
|
||||
toxcore/TCP_connection.h
|
||||
toxcore/TCP_server.c
|
||||
toxcore/TCP_server.h
|
||||
toxcore/list.c
|
||||
toxcore/list.h
|
||||
toxcore/net_crypto.c
|
||||
toxcore/net_crypto.h
|
||||
toxcore/onion.c
|
||||
toxcore/onion.h
|
||||
toxcore/onion_announce.c
|
||||
toxcore/onion_client.c)
|
||||
toxcore/onion_announce.h
|
||||
toxcore/onion_client.c
|
||||
toxcore/onion_client.h)
|
||||
target_link_modules(toxnetcrypto toxdht)
|
||||
|
||||
# LAYER 5: Friend requests and connections
|
||||
# ----------------------------------------
|
||||
add_module(toxfriends
|
||||
toxcore/friend_connection.c
|
||||
toxcore/friend_requests.c)
|
||||
toxcore/friend_connection.h
|
||||
toxcore/friend_requests.c
|
||||
toxcore/friend_requests.h)
|
||||
target_link_modules(toxfriends toxnetcrypto)
|
||||
|
||||
# LAYER 6: Tox messenger
|
||||
# ----------------------
|
||||
add_module(toxmessenger
|
||||
toxcore/Messenger.c)
|
||||
toxcore/Messenger.c
|
||||
toxcore/Messenger.h)
|
||||
target_link_modules(toxmessenger toxfriends)
|
||||
|
||||
# LAYER 7: Group chats
|
||||
# --------------------
|
||||
add_module(toxgroup
|
||||
toxcore/group.c)
|
||||
toxcore/group.c
|
||||
toxcore/group.h)
|
||||
target_link_modules(toxgroup toxmessenger)
|
||||
|
||||
# LAYER 8: Public API
|
||||
# -------------------
|
||||
apidsl(
|
||||
toxcore/tox.api.h)
|
||||
add_module(toxcore
|
||||
toxcore/tox.c)
|
||||
toxcore/misc_tools.h
|
||||
toxcore/tox.c
|
||||
toxcore/tox.h)
|
||||
target_link_modules(toxcore toxgroup)
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Audio/Video Library
|
||||
|
@ -183,20 +208,29 @@ target_link_modules(toxcore toxgroup)
|
|||
################################################################################
|
||||
|
||||
if(BUILD_TOXAV)
|
||||
apidsl(
|
||||
toxav/toxav.api.h)
|
||||
add_module(toxav
|
||||
toxav/audio.c
|
||||
toxav/audio.h
|
||||
toxav/bwcontroller.c
|
||||
toxav/bwcontroller.h
|
||||
toxav/group.c
|
||||
toxav/group.h
|
||||
toxav/msi.c
|
||||
toxav/msi.h
|
||||
toxav/ring_buffer.c
|
||||
toxav/ring_buffer.h
|
||||
toxav/rtp.c
|
||||
toxav/rtp.h
|
||||
toxav/toxav.c
|
||||
toxav/toxav.h
|
||||
toxav/toxav_old.c
|
||||
toxav/video.c)
|
||||
toxav/video.c
|
||||
toxav/video.h)
|
||||
target_link_modules(toxav toxcore ${OPUS_LIBRARIES} ${VPX_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: ToxDNS and block encryption libraries
|
||||
|
@ -211,16 +245,20 @@ add_module(toxencryptsave
|
|||
toxencryptsave/toxencryptsave.c)
|
||||
target_link_modules(toxencryptsave toxcore)
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Automated regression tests
|
||||
#
|
||||
################################################################################
|
||||
|
||||
add_test(
|
||||
NAME format_test
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/other/astyle/format-source "${CMAKE_SOURCE_DIR}")
|
||||
if(APIDSL AND ASTYLE)
|
||||
add_test(
|
||||
NAME format_test
|
||||
COMMAND ${CMAKE_SOURCE_DIR}/other/astyle/format-source
|
||||
"${CMAKE_SOURCE_DIR}"
|
||||
"${APIDSL}"
|
||||
"${ASTYLE}")
|
||||
endif()
|
||||
|
||||
function(auto_test target)
|
||||
if(CHECK_FOUND)
|
||||
|
@ -251,7 +289,6 @@ if(BUILD_TOXAV)
|
|||
auto_test(toxav_many)
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Bootstrap daemon
|
||||
|
@ -279,7 +316,6 @@ if(LIBCONFIG_FOUND)
|
|||
target_link_modules(tox-bootstrapd toxnetcrypto ${LIBCONFIG_LIBRARIES})
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Test programs
|
||||
|
@ -329,7 +365,6 @@ if(NOT WIN32)
|
|||
target_link_modules(irc_syncbot toxcore)
|
||||
endif()
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# :: Installation and pkg-config
|
||||
|
@ -362,7 +397,6 @@ configure_file(
|
|||
@ONLY
|
||||
)
|
||||
|
||||
|
||||
install(FILES
|
||||
${CMAKE_BINARY_DIR}/toxcore.pc
|
||||
${CMAKE_BINARY_DIR}/toxdns.pc
|
||||
|
|
29
cmake/ApiDsl.cmake
Normal file
29
cmake/ApiDsl.cmake
Normal file
|
@ -0,0 +1,29 @@
|
|||
################################################################################
|
||||
#
|
||||
# :: APIDSL regeneration
|
||||
#
|
||||
################################################################################
|
||||
|
||||
find_program(APIDSL NAMES
|
||||
apidsl
|
||||
apidsl.native
|
||||
apidsl.byte
|
||||
${CMAKE_SOURCE_DIR}/../apidsl/apigen.native)
|
||||
find_program(ASTYLE NAMES
|
||||
astyle)
|
||||
|
||||
function(apidsl)
|
||||
if(APIDSL AND ASTYLE)
|
||||
foreach(in_file ${ARGN})
|
||||
get_filename_component(dirname ${in_file} DIRECTORY)
|
||||
get_filename_component(filename ${in_file} NAME_WE)
|
||||
set(out_file ${CMAKE_SOURCE_DIR}/${dirname}/${filename}.h)
|
||||
add_custom_command(
|
||||
OUTPUT ${out_file}
|
||||
COMMAND "${APIDSL}" "${CMAKE_SOURCE_DIR}/${in_file}"
|
||||
| "${ASTYLE}" --options="${CMAKE_SOURCE_DIR}/other/astyle/astylerc"
|
||||
> "${out_file}"
|
||||
DEPENDS ${in_file})
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
|
@ -13,19 +13,19 @@ If you want to do it quickly and you don't have time for anything other than cop
|
|||
|
||||
|
||||
1. Make sure that you have ``curl`` and ``>=astyle-2.03`` installed
|
||||
2. Modify [``tox.in.h``](/other/apidsl/tox.in.h)
|
||||
2. Modify [``tox.api.h``](/toxcore/tox.api.h)
|
||||
3. Run command below ↓
|
||||
|
||||
Command to run from ``toxcore`` directory (quick way, involves using curl):
|
||||
```bash
|
||||
# For tox.h:
|
||||
curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
|
||||
< other/apidsl/tox.in.h \
|
||||
< toxcore/tox.api.h \
|
||||
| astyle --options=other/astyle/astylerc \
|
||||
> toxcore/tox.h
|
||||
# For toxav.h:
|
||||
curl -X POST --data-binary @- https://apidsl.herokuapp.com/apidsl \
|
||||
< other/apidsl/toxav.in.h \
|
||||
< toxav/toxav.api.h \
|
||||
| astyle --options=other/astyle/astylerc \
|
||||
> toxav/toxav.h
|
||||
```
|
||||
|
@ -41,7 +41,7 @@ If you prefer to have more control over what is happening, there are steps below
|
|||
|
||||
1. Install [``apidsl``](https://github.com/TokTok/apidsl)
|
||||
2. Install ``astyle``, version 2.03 or later.
|
||||
3. Modify [``tox.in.h``](/other/apidsl/tox.in.h)
|
||||
3. Modify [``tox.api.h``](/toxcore/tox.api.h)
|
||||
4. Use ``apidsl`` ``??``
|
||||
5. Parse generated ``tox.h`` with astyle, minimal command for it would be:
|
||||
```bash
|
|
@ -29,4 +29,4 @@ Copy [``astylerc``](/other/astyle/astylerc) to ``toxcore/.git/hooks``
|
|||
|
||||
``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.
|
||||
|
||||
Furthermore, it is being used to format ``tox.h`` after using [``apidsl``](/other/apidsl) to generate it.
|
||||
Furthermore, it is being used to format ``tox.h`` after using ``apidsl`` to generate it.
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
set -e
|
||||
|
||||
SOURCE_DIR="$1"
|
||||
APIDSL="$2"
|
||||
ASTYLE="$3"
|
||||
|
||||
# Go to the source root.
|
||||
if [ -z "$SOURCE_DIR" ]; then
|
||||
|
@ -20,10 +22,11 @@ if ! which "$ASTYLE"; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f ../apidsl/apigen.native ]; then
|
||||
APIDSL=../apidsl/apigen.native
|
||||
else
|
||||
APIDSL=apidsl_curl
|
||||
if ! which "$APIDSL"; then
|
||||
if [ -f ../apidsl/apigen.native ]; then
|
||||
APIDSL=../apidsl/apigen.native
|
||||
else
|
||||
APIDSL=apidsl_curl
|
||||
fi
|
||||
|
||||
apidsl_curl() {
|
||||
|
@ -31,10 +34,10 @@ apidsl_curl() {
|
|||
}
|
||||
|
||||
# Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h.
|
||||
$APIDSL other/apidsl/tox.in.h > toxcore/tox.h
|
||||
$APIDSL other/apidsl/toxav.in.h > toxav/toxav.h
|
||||
$APIDSL toxcore/tox.api.h > toxcore/tox.h
|
||||
$APIDSL toxav/toxav.api.h > toxav/toxav.h
|
||||
|
||||
SOURCES=`find . -name "*.[ch]" -and -not -name "*.in.*" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
|
||||
SOURCES=`find . -name "*.[ch]" -and -not -name "*.api.h" -and -not -wholename "*crypto_pwhash*" -and -not -wholename "./super_donators/*"`
|
||||
|
||||
$ASTYLE -n --options=other/astyle/astylerc $SOURCES
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ update() {
|
|||
fi
|
||||
}
|
||||
|
||||
update "configure.ac" 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'
|
||||
update 'configure.ac' 's/AC_INIT(\[tox\], \[.*\])/AC_INIT([tox], ['$VER'])/'
|
||||
|
||||
update "other/apidsl/tox.in.h" 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
|
||||
update "other/apidsl/tox.in.h" 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
|
||||
update "other/apidsl/tox.in.h" 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'
|
||||
update 'toxcore/tox.api.h' 's/\(const VERSION_MAJOR *= \).*;/\1'$MAJOR';/'
|
||||
update 'toxcore/tox.api.h' 's/\(const VERSION_MINOR *= \).*;/\1'$MINOR';/'
|
||||
update 'toxcore/tox.api.h' 's/\(const VERSION_PATCH *= \).*;/\1'$PATCH';/'
|
||||
|
|
|
@ -37,8 +37,8 @@ extern "C" {
|
|||
|
||||
/*****************************************************************************
|
||||
* `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to *
|
||||
* `tox.in.h`, located in `other/apidsl/`. For instructions on how to *
|
||||
* generate `tox.h` from `tox.in.h` please refer to `other/apidsl/README.md` *
|
||||
* `tox.api.h`, located in `toxcore/`. For instructions on how to *
|
||||
* generate `tox.h` from `tox.api.h` please refer to `docs/apidsl.md` *
|
||||
*****************************************************************************/
|
||||
|
||||
|
|
@ -35,8 +35,8 @@ extern "C" {
|
|||
|
||||
/*******************************************************************************
|
||||
* `tox.h` SHOULD *NOT* BE EDITED MANUALLY – any changes should be made to *
|
||||
* `tox.in.h`, located in `other/apidsl/`. For instructions on how to *
|
||||
* generate `tox.h` from `tox.in.h` please refer to `other/apidsl/README.md` *
|
||||
* `tox.api.h`, located in `toxcore/`. For instructions on how to *
|
||||
* generate `tox.h` from `tox.api.h` please refer to `docs/apidsl.md` *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user