From a6c86c79f11f363b88fecd5b1fa60a757698b64d Mon Sep 17 00:00:00 2001
From: Kim Kulling <kim.kulling@googlemail.com>
Date: Wed, 16 Nov 2016 11:39:44 +0100
Subject: [PATCH] Travis: enable coverall support.

---
 .coveralls.yml      |  2 ++
 .travis.yml         | 21 +++++++++++++++++++++
 CMakeLists.txt      |  6 ++++++
 code/CMakeLists.txt | 11 +++++++++++
 4 files changed, 40 insertions(+)
 create mode 100644 .coveralls.yml

diff --git a/.coveralls.yml b/.coveralls.yml
new file mode 100644
index 000000000..f69c0ba34
--- /dev/null
+++ b/.coveralls.yml
@@ -0,0 +1,2 @@
+service_name: travis-pro
+repo_token: GZXuNlublKFy7HAewHAZLk5ZwgipTFAOA
diff --git a/.travis.yml b/.travis.yml
index 8e6a7a0f5..df6e8428e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,6 +3,14 @@ before_install:
   - sudo apt-get install cmake python3
   - if [ $LINUX ]; then sudo apt-get install -qq freeglut3-dev libxmu-dev libxi-dev ; fi
   - echo -e "#ifndef A_R_H_INC\n#define A_R_H_INC\n#define GitVersion ${TRAVIS_JOB_ID}\n#define GitBranch \"${TRAVIS_BRANCH}\"\n#endif // A_R_H_INC" > revision.h
+  # install latest LCOV (1.9 was failing)
+  - cd ${TRAVIS_BUILD_DIR}
+  - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz
+  - tar xf lcov_1.11.orig.tar.gz
+  - sudo make -C lcov-1.11/ install
+  - gem install coveralls-lcov
+  - lcov --version
+  - g++ --version
 
 branches:
   only:
@@ -27,5 +35,18 @@ compiler:
 install:
   - if [ $ANDROID ]; then wget -c http://dl.google.com/android/ndk/android-ndk-${PV}-${PLATF}.tar.bz2 && tar xf android-ndk-${PV}-${PLATF}.tar.bz2 ; fi
 
+before_script:
+  - cd ${TRAVIS_BUILD_DIR}
+  # init coverage to 0 (optional)
+  - lcov --directory . --zerocounters
+
 script:
   - . ./.travis.sh
+
+after_success:
+  - cd ${TRAVIS_BUILD_DIR}
+  - lcov --directory . --capture --output-file coverage.info
+  - lcov --remove coverage.info 'contrib/*' '/usr/*' --output-file coverage.info
+  - lcov --list coverage.info
+  - coveralls-lcov --repo-token ${COVERALLS_TOKEN} coverage.info
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c84f9a12a..d352b95e6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -173,6 +173,12 @@ ELSEIF( CMAKE_COMPILER_IS_MINGW )
 	SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -Wall -Wno-long-long -pedantic -std=c++11" )
 ENDIF()
 
+if (COVERALLS)
+    include(Coveralls)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage")
+endif()
+
 INCLUDE (FindPkgConfig)
 INCLUDE_DIRECTORIES( include )
 
diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt
index 3f0b69670..0f2af7379 100644
--- a/code/CMakeLists.txt
+++ b/code/CMakeLists.txt
@@ -928,3 +928,14 @@ if(MSVC AND ASSIMP_INSTALL_PDB)
     CONFIGURATIONS RelWithDebInfo
   )
 endif ()
+
+if (COVERALLS)
+    set(COVERAGE_SRCS ${assimp_src} )
+
+    # Create the coveralls target.
+    coveralls_setup(
+        "${COVERAGE_SRCS}" # The source files.
+        ON                 # If we should upload.
+        "${PROJECT_SOURCE_DIR}/cmake/") # (Optional) Alternate project cmake module path.
+endif()
+
-- 
GitLab