language: cpp
compiler: gcc
sudo: require
dist: trusty

before_install:
  - sudo add-apt-repository ppa:beineri/opt-qt58-trusty -y
  - sudo apt-get update -qq
    
install: 
  - sudo apt-get -y install qt58base qt58tools qt58translations libudev-dev
  - source /opt/qt*/bin/qt*-env.sh
  - # Precompiled KF5
  - wget -c "https://github.com/chigraph/precompiled-kf5-linux/releases/download/precompiled/kf5-gcc6-linux64-release.tar.xz"
  - tar xf kf5-gcc6-linux64-release.tar.xz
  - sudo cp -Rf root/kf5-release/* /opt/qt58/
  - # extra-cmake-modules KDE project; https://superuser.com/questions/850029/could-not-find-a-configuration-file-for-package-ecm-that-is-compatible-with-re/912259#912259
  - git clone git://anongit.kde.org/extra-cmake-modules
  - cd extra-cmake-modules
  - mkdir build && cd build    
  - cmake ..
  - make && sudo make install
  - cd ../..

script:
  - cmake . -DCMAKE_INSTALL_PREFIX=/usr
  - make -j4
  - make DESTDIR=appdir install ; find appdir/
  - cp res/icon-rosa.svg appdir/drive-removable-media.svg

after_success:
  - wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" 
  - chmod a+x linuxdeployqt*.AppImage
  - unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
  - export LD_LIBRARY_PATH=/opt/qt58/lib/x86_64-linux-gnu/
  - ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -bundle-non-qt-libs
  - ./linuxdeployqt*.AppImage ./appdir/usr/share/applications/*.desktop -appimage
  - find ./appdir -executable -type f -exec ldd {} \; | grep " => /usr" | cut -d " " -f 2-3 | sort | uniq
  - curl --upload-file ./ISO*.AppImage https://transfer.sh/ISO_Image_Writer-git.$(git rev-parse --short HEAD)-x86_64.AppImage
