diff --git a/package/archlinux/PKGBUILD-coverage b/package/archlinux/PKGBUILD-coverage new file mode 100644 index 0000000..7769413 --- /dev/null +++ b/package/archlinux/PKGBUILD-coverage @@ -0,0 +1,62 @@ +# Author: mosra +pkgname=magnum-bindings +pkgver=dev +pkgrel=1 +pkgdesc="C++11/C++14 graphics middleware for games and data visualization — bindings" +arch=('i686' 'x86_64') +url="https://magnum.graphics" +license=('MIT') +depends=('corrade' 'magnum' 'python') +makedepends=('cmake' 'ninja' 'pybind11' 'lcov' 'gcc6') +provides=('magnum-bindings-git') + +_rootdir=$startdir/../../ + +build() { + mkdir -p "$_rootdir/build-coverage" + cd "$_rootdir/build-coverage" + + # Disable optimization (saves A LOT of compilation time) + newcxxflags=$(echo $CXXFLAGS | sed s/-O.//g | sed s/-D_FORTIFY_SOURCE=.//g) + export CXXFLAGS="$newcxxflags" + + cmake .. \ + -DCMAKE_CXX_COMPILER=g++-6 \ + -DCMAKE_CXX_FLAGS="--coverage" \ + -DCMAKE_BUILD_TYPE=Debug \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DWITH_PYTHON=ON \ + -G Ninja + ninja +} + +check() { + # Python coverage + cd "$_rootdir/src/python/corrade" + CMAKE_BINARY_DIR="$_rootdir/build-coverage" coverage run -m unittest -v || true + cp .coverage ../.coverage.corrade + + cd "$_rootdir/src/python/magnum" + CMAKE_BINARY_DIR="$_rootdir/build-coverage" coverage run -m unittest -v || true + cp .coverage ../.coverage.magnum + + cd .. + coverage combine + coverage html + + # C++ coverage + cd "$_rootdir/build-coverage" + + rm -rf coverage + mkdir coverage + # Keep in sync with package/ci/travis-desktop.sh, please + lcov --gcov-tool="gcov-6" --directory . --capture --output-file coverage.info + lcov --gcov-tool="gcov-6" --extract coverage.info "*/src/python/*" --output-file coverage.info + genhtml --output-directory ./coverage coverage.info +} + +package() { + echo -e "Open \n file://${_rootdir}build-coverage/coverage/index.html\n file://${_rootdir}src/python/htmlcov/index.html\nto see the results." && false +} + +# kate: hl bash diff --git a/src/python/corrade/test/__init__.py b/src/python/corrade/test/__init__.py index af32f8e..8be36c8 100644 --- a/src/python/corrade/test/__init__.py +++ b/src/python/corrade/test/__init__.py @@ -27,5 +27,4 @@ import os import sys # TODO: do this differently / more robustly -sys.path = [os.path.join(os.path.dirname(__file__), '../../../../build/src/python')] + sys.path - +sys.path = [os.path.join(os.path.dirname(__file__), os.environ.get('CMAKE_BINARY_DIR', '../../../../build'), 'src/python')] + sys.path diff --git a/src/python/magnum/test/__init__.py b/src/python/magnum/test/__init__.py index ce852ed..2128587 100644 --- a/src/python/magnum/test/__init__.py +++ b/src/python/magnum/test/__init__.py @@ -28,7 +28,7 @@ import sys import unittest # TODO: do this differently / more robustly -sys.path = [os.path.join(os.path.dirname(__file__), '../../../../build/src/python')] + sys.path +sys.path = [os.path.join(os.path.dirname(__file__), os.environ.get('CMAKE_BINARY_DIR', '../../../../build'), 'src/python')] + sys.path from magnum import * from magnum import platform