问题
I have a medium size github repository for which I configured Travis-CI/Coverity tools. About a month ago my setup had worked just fine: Travis compiled and built my application, and then performed the Coverity scan and I could see the results on my Coverity page.
However, lately, the Coverity analysis stopped working. I looked through the Travis log files and compared to the old logs when the builds were successful and that's what I found:
At the end of the log, the failed version contains the next warning:
[WARNING] No files were emitted. This may be due to a problem with your configuration or because no files were actually compiled by your build command.
Please make sure you have configured the compilers actually used in the compilation.
For more details, please look at: /home/travis/build/name/repo-name/build/cov-int/build-log.txt
Extracting SCM data for 0 files...
...
So, the Travis builds are passing, but nothing is generated for the Coverity. I checked my Travis config file and it is identical to the commits when the Coverity builds were successful.
For the sake of experiment, I cloned my project repository, rolled back to the version when the builds were successful and set up Travis/Coverity for them. And guess what? Same warning! So, the identical setup that worked in the past (about 35 days ago), does not work anymore. Therefore, I make conclusion, something had changed on the part of Travis since it does not generate certain files.
I was wondering if anyone encountered this issue? and what it could be about? Are there some Travis settings I need to change?
Some additional info: I use CMake to build my project, and it has two dependencies: Qt and OpenSceneGraph (which I have to install for Travis).
This is the approximate script of my .travis.yml
on my coverity_scan
branch:
language: cpp
os: linux
compiler: gcc
sudo: required
dist: trusty
addons:
apt:
packages:
- cmake
- g++-4.8
coverity_scan:
project:
name: "name/project"
description: "Build submitted via Travis CI"
notification_email: email@domain.com
build_command: "make -j2 VERBOSE=1"
branch_pattern: coverity_scan
env:
global:
- PROJECT_SOURCE=${TRAVIS_BUILD_DIR}/src/
- PROJECT_BUILD=${TRAVIS_BUILD_DIR}/build/
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "...secure..."
before_install:
# download Qt
# ...
# download OpenSceneGraph
# ...
# imitate x server
- export DISPLAY=:99.0
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16
- sleep 3
install:
# install Qt
- sudo apt-get --yes install qt55base qt55imageformats qt55svg
# compiler
- export CXX="g++-4.8"
- export CC="gcc-4.8"
# install OpenSceneGraph
# ...
before_script:
# Qt location
# ...
# OpenSceneGraph variables
# ...
# create build folder
- mkdir $PROJECT_BUILD
- cd $PROJECT_BUILD
# cmake command
- cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/qt54/lib/cmake -DProject_BUILD_TEST=ON -DProject_VERSION=0.0.0 $PROJECT_SOURCE
script:
- if [[ "${COVERITY_SCAN_BRANCH}" == 1 ]];
then
echo "Don't build on coverty_scan branch.";
exit 0;
fi
# compile everything, if not coverity branch
- make -j2
# run unit tests
# ...
回答1:
After some research and looking through existing examples, I finally made it work. To fix the warning, and, therefore, to make sure files are emitted for the analysis, it is necessary to explicitly specify the compiler binary (updated according to the comment) . In my .travis.yml
I had to add a build_command_prepend
before the build_command
of the coverity_scan
add-on. An example of the final look for that block is as below:
# ...
coverity_scan:
project:
name: "name/project"
description: "Build submitted via Travis CI"
notification_email: name@domain.com
# ! have to specify the binary (updated, thanks to Caleb)
build_command_prepend: "cov-configure --comptype gcc --compiler gcc-4.8 --template"
build_command: "make VERBOSE=1"
branch_pattern: coverity_scan
# ...
来源:https://stackoverflow.com/questions/38902793/travisci-coverity-warning-no-files-were-emitted