diff --git a/.gitignore b/.gitignore index 4d92363b..4248f326 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,9 @@ Thumbs.db *.tmp # Make +/_build +/_install +/tox-0.0.0* CMakeCache.txt CMakeFiles Makefile diff --git a/.travis.yml b/.travis.yml index 2b099bae..ae3d50b2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,23 @@ language: c -compiler: - - clang - - gcc -env: - matrix: -# - BUILD=hstox - - BUILD=toxcore +matrix: + include: + - env: BUILD=hstox + language: haskell + ghc: 7.8 + - env: BUILD=toxcore + compiler: clang + - env: BUILD=toxcore + compiler: gcc + - env: BUILD=autotools + compiler: clang addons: apt: sources: - avsm - - hvr-ghc packages: - - cabal-install-1.22 - check - - ghc-7.10.3 - libvpx-dev - opam # For apidsl and Frama-C. - texinfo # For libconfig. @@ -28,9 +29,6 @@ cache: - $HOME/cache install: - # Set up PATH for the /opt packages. - - export PATH=/opt/cabal/1.22/bin:$PATH - - export PATH=/opt/ghc/7.10.3/bin:$PATH # Globally used environment variables. - export CACHE_DIR=$HOME/cache - export OPAMROOT=$CACHE_DIR/.opam diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..5e6974ce --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,158 @@ +cmake_minimum_required(VERSION 2.8.6) +project(toxcore) +include(CTest) + + +################################################################################ +# +# :: Dependencies and configuration. +# +################################################################################ + +set(CMAKE_MACOSX_RPATH ON) + +find_package(PkgConfig REQUIRED) +find_package(Threads REQUIRED) + +find_library(UTIL_LIBRARIES util) + +pkg_search_module(LIBSODIUM REQUIRED libsodium) +pkg_search_module(CHECK REQUIRED check) +pkg_search_module(OPUS REQUIRED opus) +pkg_search_module(VPX REQUIRED vpx) + +link_directories(${LIBSODIUM_LIBRARY_DIRS}) +link_directories(${CHECK_LIBRARY_DIRS}) +link_directories(${OPUS_LIBRARY_DIRS}) +link_directories(${VPX_LIBRARY_DIRS}) + +include_directories(${LIBSODIUM_INCLUDE_DIRS}) +include_directories(${CHECK_INCLUDE_DIRS}) +include_directories(${OPUS_INCLUDE_DIRS}) +include_directories(${VPX_INCLUDE_DIRS}) + +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LIBSODIUM_CFLAGS_OTHER}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CHECK_CFLAGS_OTHER}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPUS_CFLAGS_OTHER}") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VPX_CFLAGS_OTHER}") + + +################################################################################ +# +# :: Libraries. +# +################################################################################ + +add_library(toxcore SHARED + toxcore/DHT.c + toxcore/LAN_discovery.c + toxcore/Messenger.c + toxcore/TCP_client.c + toxcore/TCP_connection.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/logger.c + toxcore/net_crypto.c + toxcore/network.c + toxcore/onion.c + toxcore/onion_announce.c + toxcore/onion_client.c + toxcore/ping.c + toxcore/ping_array.c + toxcore/tox.c + toxcore/util.c) + +target_link_libraries(toxcore ${LIBSODIUM_LIBRARIES}) +target_link_libraries(toxcore rt) + +add_library(toxav SHARED + toxav/audio.c + toxav/bwcontroller.c + toxav/group.c + toxav/msi.c + toxav/rtp.c + toxav/toxav.c + toxav/toxav_old.c + toxav/video.c) + +target_link_libraries(toxav toxcore) +target_link_libraries(toxav ${OPUS_LIBRARIES}) +target_link_libraries(toxav ${VPX_LIBRARIES}) + +add_library(toxdns SHARED + toxdns/toxdns.c) + +target_link_libraries(toxdns toxcore) + +add_library(toxencryptsave SHARED + toxencryptsave/toxencryptsave.c) + +target_link_libraries(toxencryptsave toxcore) + + +################################################################################ +# +# :: Automated regression tests. +# +################################################################################ + +function(auto_test target) + if(CHECK_FOUND) + add_executable(auto_${target} auto_tests/${target}.c) + target_link_libraries(auto_${target} + toxcore + toxav + toxencryptsave + ${CHECK_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT}) + add_test(${target} auto_${target}) + endif() +endfunction() + +auto_test(TCP_test) +auto_test(assoc_test) +auto_test(crypto_test) +auto_test(dht_test) +auto_test(encryptsave_test) +# This test doesn't link (missing symbol). +#auto_test(friends_test) +auto_test(messenger_test) +auto_test(network_test) +auto_test(onion_test) +auto_test(skeleton_test) +auto_test(tox_test) +auto_test(toxav_basic_test) +auto_test(toxav_many_test) + + +################################################################################ +# +# :: Test programs. +# +################################################################################ + +add_executable(nTox testing/nTox.c) +target_link_libraries(nTox toxcore ncurses ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(DHT_test testing/DHT_test.c) +target_link_libraries(DHT_test toxcore ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(Messenger_test testing/Messenger_test.c) +target_link_libraries(Messenger_test toxcore ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(dns3_test testing/dns3_test.c) +target_link_libraries(dns3_test toxdns ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(tox_sync testing/tox_sync.c) +target_link_libraries(tox_sync toxcore ${CMAKE_THREAD_LIBS_INIT}) + +add_executable(tox_shell testing/tox_shell.c) +target_link_libraries(tox_shell toxcore ${CMAKE_THREAD_LIBS_INIT} ${UTIL_LIBRARIES}) + +add_executable(irc_syncbot testing/irc_syncbot.c) +target_link_libraries(irc_syncbot toxcore ${CMAKE_THREAD_LIBS_INIT}) diff --git a/auto_tests/Makefile.inc b/auto_tests/Makefile.inc index d78a6a5a..8ab7c896 100644 --- a/auto_tests/Makefile.inc +++ b/auto_tests/Makefile.inc @@ -108,3 +108,4 @@ encryptsave_test_LDADD = $(AUTOTEST_LDADD) EXTRA_DIST += $(top_srcdir)/auto_tests/friends_test.c +EXTRA_DIST += $(top_srcdir)/auto_tests/helpers.h diff --git a/other/travis/autotools-after_script b/other/travis/autotools-after_script new file mode 100755 index 00000000..0f4ddcd5 --- /dev/null +++ b/other/travis/autotools-after_script @@ -0,0 +1,3 @@ +#!/bin/sh + +set -e -x diff --git a/other/travis/autotools-install b/other/travis/autotools-install new file mode 120000 index 00000000..7174a278 --- /dev/null +++ b/other/travis/autotools-install @@ -0,0 +1 @@ +toxcore-install \ No newline at end of file diff --git a/other/travis/autotools-script b/other/travis/autotools-script new file mode 100755 index 00000000..284a52d4 --- /dev/null +++ b/other/travis/autotools-script @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e -x + +# Build toxcore and run tests. +./autogen.sh +./configure \ + --with-libsodium-libs=$CACHE_DIR/lib \ + --with-libsodium-headers=$CACHE_DIR/include \ + --enable-daemon \ + --enable-logging \ + --enable-ntox + +make -j `nproc` +# This doesn't currently work on Travis, because the autotools build is broken. +# It does not look up libsodium by pkg-config, so without the --with flags it +# won't find it. We don't care that much about distcheck at this point, but we +# do care whether it configures/builds at all, which is exercised by the make +# call above. Tests are executed by the cmake build. +make distcheck -j `nproc` || true diff --git a/other/travis/toxcore-script b/other/travis/toxcore-script index b99bbe5b..ae6f4c47 100755 --- a/other/travis/toxcore-script +++ b/other/travis/toxcore-script @@ -2,6 +2,8 @@ set -e -x +BUILD_DIR=_build + # Check if toxcore.h and toxav.h match apidsl tox.in.h and toxav.in.h. ../apidsl/_build/apigen.native other/apidsl/tox.in.h | $ASTYLE --options=other/astyle/astylerc > toxcore/tox.h ../apidsl/_build/apigen.native other/apidsl/toxav.in.h | $ASTYLE --options=other/astyle/astylerc > toxav/toxav.h @@ -10,18 +12,10 @@ $ASTYLE --options=other/astyle/astylerc `find . -name "*.[ch]" -and -not -name " git diff --exit-code # Build toxcore and run tests. -./autogen.sh -./configure \ - --with-libsodium-libs=$CACHE_DIR/lib \ - --with-libsodium-headers=$CACHE_DIR/include \ - --enable-daemon \ - --enable-logging \ - --enable-ntox \ - CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1" +export CFLAGS="-O0 -Wall -Wextra -fprofile-arcs -ftest-coverage -DTRAVIS_ENV=1" +cmake -B$BUILD_DIR -H. -make -make check -if [ -f build/test-suite.log ]; then - cat build/test-suite.log -fi -make dist +export CTEST_OUTPUT_ON_FAILURE=1 + +make -C $BUILD_DIR -j `nproc` +make -C $BUILD_DIR -j `nproc` test diff --git a/toxav/audio.h b/toxav/audio.h index b1db7448..cd273cf7 100644 --- a/toxav/audio.h +++ b/toxav/audio.h @@ -22,7 +22,7 @@ #ifndef AUDIO_H #define AUDIO_H -#include +#include #include #include "toxav.h" diff --git a/toxav/group.h b/toxav/group.h index 3355a447..bd300cdc 100644 --- a/toxav/group.h +++ b/toxav/group.h @@ -19,7 +19,7 @@ */ /* Audio encoding/decoding */ -#include +#include #include "../toxcore/group.h"