Skip to content

Commit

Permalink
Add a test.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Sep 23, 2016
1 parent ee4067b commit 0073fef
Show file tree
Hide file tree
Showing 13 changed files with 272 additions and 193 deletions.
31 changes: 13 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,20 @@ language: cpp
matrix:
include:
- os: linux
env: ENV=linux
- os: linux
env: ENV=windows ARCH=i686 LIBTYPE=shared
services:
- docker
- os: osx
env: ENV=osx

install:
- .travis/install-$ENV
- . .travis/env-$ENV.sh
- git clone --depth=1 https://github.com/TokTok/toxcore
- RUN $CMAKE -Btoxcore/_build -Htoxcore -DLOGGING=ON -DDEBUG=ON -DCMAKE_INSTALL_PREFIX:PATH=$CURDIR/libs
- RUN $MAKE -C toxcore/_build -j$NPROC -k install
env: JOB=deploy ENV=linux
# - os: linux
# env: JOB=deploy ENV=windows ARCH=i686 LIBTYPE=shared
# services:
# - docker
# - os: linux
# env: JOB=deploy ENV=windows ARCH=x86_64 LIBTYPE=shared
# services:
# - docker
# - os: osx
# env: JOB=deploy ENV=osx

script:
- RUN $CMAKE -B_build -H. -DCMAKE_INSTALL_PREFIX:PATH=$CURDIR/_install
- RUN $MAKE -C _build -j$NPROC -k install
- .travis/git-deploy
install: .travis/phase $JOB $ENV install
script: .travis/phase $JOB $ENV script

branches:
only:
Expand Down
6 changes: 6 additions & 0 deletions .travis/deploy-install
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

git clone --depth=1 https://github.com/TokTok/toxcore

RUN $CMAKE -Btoxcore/$BUILD_DIR -Htoxcore -DASSOC_DHT=ON -DDEBUG=ON -DSTRICT_ABI=ON -DCMAKE_INSTALL_PREFIX:PATH=$CURDIR/libs
RUN $MAKE -C toxcore/$BUILD_DIR -j$NPROC -k install
6 changes: 6 additions & 0 deletions .travis/deploy-script
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

RUN $CMAKE -B$BUILD_DIR -H. -DCMAKE_INSTALL_PREFIX:PATH=$CURDIR/_install
RUN $MAKE -C $BUILD_DIR -j$NPROC -k install

$THIS_DIR/git-deploy
6 changes: 6 additions & 0 deletions .travis/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

export CFLAGS="-O3"
export CXXFLAGS="-O3"

BUILD_DIR=_build
3 changes: 2 additions & 1 deletion .travis/git-deploy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh

set -e
# Don't display the commands executed.
set -e +x

if [ -z "$GIT_TOKEN" ]; then
exit 0
Expand Down
File renamed without changes.
File renamed without changes.
24 changes: 24 additions & 0 deletions .travis/phase
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -eux

JOB="$1"
ENV="$2"
PHASE="$3"

THIS_DIR=`dirname \`which $0\``

. "$THIS_DIR/env.sh"
. "$THIS_DIR/env-$ENV.sh"

try_source() {
SCRIPT="$THIS_DIR/$1"
if [ -f "$SCRIPT" ]; then
. "$SCRIPT"
fi
}

try_source "$PHASE"
try_source "$ENV-$PHASE"
try_source "$JOB-$PHASE"
try_source "$JOB-$ENV-$PHASE"
2 changes: 0 additions & 2 deletions .travis/install-windows → .travis/windows-install
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/bin/sh

set -eux

DOCKER_IMAGE=toktoknet/windows-qt5:latest.$ARCH-shared

docker pull $DOCKER_IMAGE
Expand Down
227 changes: 59 additions & 168 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
################################################################################
#
# :: CMake configuration
#
################################################################################

cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
Expand Down Expand Up @@ -29,6 +36,7 @@ set(CMAKE_OSX_SYSROOT
${CMAKE_OSX_SYSROOT}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}.sdk)

project(qtox)
include(CTest)

# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)
Expand All @@ -40,89 +48,13 @@ set(CMAKE_CXX_FLAGS -std=c++11)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR})

# This should go into subdirectories later.
find_package(PkgConfig REQUIRED)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5LinguistTools REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Sql REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5Widgets REQUIRED)
find_package(Qt5Xml REQUIRED)

set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
include(Qt5CorePatches)

pkg_search_module(APPINDICATOR appindicator-0.1)
pkg_search_module(GDK_PIXBUF gdk-pixbuf-2.0)
pkg_search_module(GLIB glib-2.0)
pkg_search_module(GTK gtk+-2.0)

pkg_search_module(LIBAVCODEC REQUIRED libavcodec)
pkg_search_module(LIBAVDEVICE REQUIRED libavdevice)
pkg_search_module(LIBAVFORMAT REQUIRED libavformat)
pkg_search_module(LIBAVUTIL REQUIRED libavutil)
pkg_search_module(LIBQRENCODE REQUIRED libqrencode)
pkg_search_module(LIBSODIUM REQUIRED libsodium)
pkg_search_module(LIBSWSCALE REQUIRED libswscale)
pkg_search_module(OPENAL openal) # Actually required, but might be an OSX framework.
pkg_search_module(SQLCIPHER REQUIRED sqlcipher)
pkg_search_module(TOXAV REQUIRED toxav)
pkg_search_module(TOXCORE REQUIRED toxcore)
pkg_search_module(TOXENCRYPTSAVE REQUIRED toxencryptsave)
pkg_search_module(VPX REQUIRED vpx)

# XScreenSaver support.
find_library(XSS_LIBRARIES NAMES Xss)
# Qt5 Platform support library needs to be statically linked on Windows/Mingw.
find_library(QT5PLATFORMSUPPORT NAMES Qt5PlatformSupport)

find_library(AVFOUNDATION_LIBRARIES NAMES AVFoundation PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
find_library(COREMEDIA_LIBRARIES NAMES CoreMedia PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
find_library(COREGRAPHICS_LIBRARIES NAMES CoreGraphics PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
find_library(FOUNDATION_LIBRARIES NAMES Foundation PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
find_library(IOKIT_LIBRARIES NAMES IOKit PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)
find_library(OPENAL_LIBRARIES NAMES OpenAL PATHS ${CMAKE_OSX_SYSROOT}/System/Library PATH_SUFFIXES Frameworks NO_DEFAULT_PATH)

if(NOT OPENAL_LIBRARIES)
message(FATAL_ERROR "OpenAL library or framework not found")
else()
set(OPENAL_FOUND TRUE)
endif()

# TODO(iphydf): fold the pkg_search_module call into this function.
function(pkg_use_module mod)
if(${mod}_FOUND)
link_directories(${${mod}_LIBRARY_DIRS})
include_directories(${${mod}_INCLUDE_DIRS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${mod}_CFLAGS_OTHER}")
endif()
endfunction()
include(Dependencies)

pkg_use_module(APPINDICATOR)
pkg_use_module(GDK_PIXBUF)
pkg_use_module(GLIB)
pkg_use_module(GTK)

pkg_use_module(LIBAVCODEC)
pkg_use_module(LIBAVDEVICE)
pkg_use_module(LIBAVFORMAT)
pkg_use_module(LIBAVUTIL)
pkg_use_module(LIBQRENCODE)
pkg_use_module(LIBSODIUM)
pkg_use_module(LIBSWSCALE)
pkg_use_module(OPENAL)
pkg_use_module(SQLCIPHER)
pkg_use_module(TOXAV)
pkg_use_module(TOXCORE)
pkg_use_module(TOXENCRYPTSAVE)
pkg_use_module(VPX)

if(MINGW)
link_directories(${QT_PREFIX_PATH}/plugins/platforms)
endif()
################################################################################
#
# :: qTox main library sources
#
################################################################################

qt5_wrap_ui(${PROJECT_NAME}_FORMS
src/chatlog/content/filetransferwidget.ui
Expand Down Expand Up @@ -258,7 +190,6 @@ set(${PROJECT_NAME}_SOURCES
src/grouplist.h
src/ipc.cpp
src/ipc.h
src/main.cpp
src/net/autoupdate.cpp
src/net/autoupdate.h
src/net/avatarbroadcaster.cpp
Expand Down Expand Up @@ -455,18 +386,6 @@ set(${PROJECT_NAME}_SOURCES
src/widget/widget.cpp
src/widget/widget.h)

if(AVFOUNDATION_LIBRARIES)
set(${PROJECT_NAME}_SOURCES ${${PROJECT_NAME}_SOURCES}
src/platform/camera/avfoundation.mm
src/platform/camera/avfoundation.h)
endif()


if(APPINDICATOR_FOUND)
set(${PROJECT_NAME}_DEFINES ${${PROJECT_NAME}_DEFINES}
-DENABLE_SYSTRAY_UNITY_BACKEND=1)
endif()

if(GDK_PIXBUF_FOUND AND GLIB_FOUND AND GTK_FOUND)
set(${PROJECT_NAME}_SOURCES ${${PROJECT_NAME}_SOURCES}
src/platform/statusnotifier/closures.c
Expand All @@ -476,93 +395,65 @@ if(GDK_PIXBUF_FOUND AND GLIB_FOUND AND GTK_FOUND)
src/platform/statusnotifier/interfaces.h
src/platform/statusnotifier/statusnotifier.c
src/platform/statusnotifier/statusnotifier.h)
add_definitions(-DENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND=1)
endif()

set(${PROJECT_NAME}_DEFINES ${${PROJECT_NAME}_DEFINES}
-DENABLE_SYSTRAY_STATUSNOTIFIER_BACKEND=1)
if(AVFOUNDATION_FOUND)
set(${PROJECT_NAME}_SOURCES ${${PROJECT_NAME}_SOURCES}
src/platform/camera/avfoundation.mm
src/platform/camera/avfoundation.h)
endif()

if(APPINDICATOR_FOUND)
add_definitions(-DENABLE_SYSTRAY_UNITY_BACKEND=1)
endif()

if(GTK_FOUND)
set(${PROJECT_NAME}_DEFINES ${${PROJECT_NAME}_DEFINES}
-DENABLE_SYSTRAY_GTK_BACKEND=1)
add_definitions(-DENABLE_SYSTRAY_GTK_BACKEND=1)
endif()

add_executable(${PROJECT_NAME}
WIN32
MACOSX_BUNDLE
add_library(${PROJECT_NAME}_static
STATIC
${${PROJECT_NAME}_FORMS}
${${PROJECT_NAME}_RESOURCES}
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_QM_FILES})
target_link_libraries(${PROJECT_NAME}_static
${ALL_LIBRARIES})

target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt5::Gui)
target_link_libraries(${PROJECT_NAME} Qt5::Network)
target_link_libraries(${PROJECT_NAME} Qt5::OpenGL)
target_link_libraries(${PROJECT_NAME} Qt5::Sql)
target_link_libraries(${PROJECT_NAME} Qt5::Svg)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_link_libraries(${PROJECT_NAME} Qt5::Xml)

if(XSS_LIBRARIES)
target_link_libraries(${PROJECT_NAME} ${XSS_LIBRARIES})
endif()

function(pkg_link_module target module)
if(${module}_FOUND)
target_include_directories(${target} PUBLIC ${${module}_INCLUDE_DIRS})
target_compile_options(${target} PUBLIC ${${module}_CFLAGS_OTHER})
target_link_libraries(${target} ${${module}_LIBRARIES})
endif()
add_executable(${PROJECT_NAME}
WIN32
MACOSX_BUNDLE
src/main.cpp)
target_link_libraries(${PROJECT_NAME}
${PROJECT_NAME}_static
${ALL_LIBRARIES})

################################################################################
#
# :: Tests
#
################################################################################

function(auto_test subsystem module)
add_executable(${module}_test
test/${subsystem}/${module}_test.cpp)
target_link_libraries(${module}_test
${PROJECT_NAME}_static
${ALL_LIBRARIES}
Qt5::Test)
add_test(
NAME test_${module}
COMMAND ${module}_test)
endfunction()

pkg_link_module(${PROJECT_NAME} APPINDICATOR)
pkg_link_module(${PROJECT_NAME} GDK_PIXBUF)
pkg_link_module(${PROJECT_NAME} GLIB)
pkg_link_module(${PROJECT_NAME} GTK)
pkg_link_module(${PROJECT_NAME} LIBAVCODEC)
pkg_link_module(${PROJECT_NAME} LIBAVDEVICE)
pkg_link_module(${PROJECT_NAME} LIBAVFORMAT)
pkg_link_module(${PROJECT_NAME} LIBAVUTIL)
pkg_link_module(${PROJECT_NAME} LIBQRENCODE)
pkg_link_module(${PROJECT_NAME} LIBSODIUM)
pkg_link_module(${PROJECT_NAME} LIBSWSCALE)
pkg_link_module(${PROJECT_NAME} OPENAL)
pkg_link_module(${PROJECT_NAME} SQLCIPHER)
pkg_link_module(${PROJECT_NAME} TOXAV)
pkg_link_module(${PROJECT_NAME} TOXCORE)
pkg_link_module(${PROJECT_NAME} TOXENCRYPTSAVE)
pkg_link_module(${PROJECT_NAME} VPX)

if(AVFOUNDATION_LIBRARIES AND
COREMEDIA_LIBRARIES AND
COREGRAPHICS_LIBRARIES AND
FOUNDATION_LIBRARIES AND
IOKIT_LIBRARIES AND
OPENAL_LIBRARIES)
target_link_libraries(${PROJECT_NAME} ${AVFOUNDATION_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${COREGRAPHICS_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${COREMEDIA_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${FOUNDATION_LIBRARIES})
target_link_libraries(${PROJECT_NAME} ${IOKIT_LIBRARIES})
endif()

target_compile_options(${PROJECT_NAME} PRIVATE -DQTOX_PLATFORM_EXT=1)

target_compile_options(${PROJECT_NAME} PRIVATE ${qtox_DEFINES})
auto_test(core core)

target_compile_options(${PROJECT_NAME} PRIVATE -DGIT_COMMIT="N/A")
target_compile_options(${PROJECT_NAME} PRIVATE -DGIT_DESCRIBE="N/A")
target_compile_options(${PROJECT_NAME} PRIVATE -DGIT_VERSION="N/A")
target_compile_options(${PROJECT_NAME} PRIVATE -DTIMESTAMP="N/A")

if(MINGW)
target_link_libraries(${PROJECT_NAME} ssl)
target_link_libraries(${PROJECT_NAME} crypto)
target_link_libraries(${PROJECT_NAME} pcre16)
target_link_libraries(${PROJECT_NAME} qwindows)
target_link_libraries(${PROJECT_NAME} ${QT5PLATFORMSUPPORT})
target_link_libraries(${PROJECT_NAME} strmiids)
endif()
################################################################################
#
# :: Installation
#
################################################################################

if(APPLE)
set(MACOSX_BUNDLE_SHORT_VERSION_STRING 1.4.1)
Expand Down

0 comments on commit 0073fef

Please sign in to comment.