##########################################################
# THE FOLLOWING LINES IS USED BY docker-build
##########################################################
requires:
  archlinux:
    - autoconf-archive
    - clang
    - gcc
    - git
    - make
    - startup-notification
    - which
    - pacman
    - cmake
    - cmake-extras
    - gtk3
    - glib2
#   - ayatana-ido
    - gobject-introspection
    - gtk-doc
    - vala

  debian:
    # Useful URL: https://salsa.debian.org/debian-ayatana-team/libayatana-indicator
    - clang
    - clang-tools
    - cppcheck
    - git
    - libtool
    - cmake
    - cmake-extras
    - at-spi2-core
    - intltool
    - gtk-doc-tools
    - libglib2.0-dev
    - libgtk2.0-dev
    - libgtk-3-dev
#   - libayatana-ido3-dev
    - gobject-introspection
    - libgirepository1.0-dev
    - libx11-dev
    - libxi-dev
    - valac
    - dbus-test-runner
    - xauth
    - xvfb

  ubuntu:
    - clang
    - clang-tools
    - git
    - libtool
    - cmake
    - cmake-extras
    - at-spi2-core
    - intltool
    - gtk-doc-tools
    - libglib2.0-dev
    - libgtk2.0-dev
    - libgtk-3-dev
#   - libayatana-ido3-dev
    - gobject-introspection
    - libgirepository1.0-dev
    - libx11-dev
    - libxi-dev
    - valac

variables:
  - 'CHECKERS="
    -enable-checker deadcode.DeadStores
    -enable-checker alpha.deadcode.UnreachableCode
    -enable-checker alpha.core.CastSize
    -enable-checker alpha.core.CastToStruct
    -enable-checker alpha.core.IdenticalExpr
    -enable-checker alpha.core.SizeofPtr
    -enable-checker alpha.security.ArrayBoundV2
    -enable-checker alpha.security.MallocOverflow
    -enable-checker alpha.security.ReturnPtrRange
    -enable-checker alpha.unix.SimpleStream
    -enable-checker alpha.unix.cstring.BufferOverlap
    -enable-checker alpha.unix.cstring.NotNullTerminated
    -enable-checker alpha.unix.cstring.OutOfBounds
    -enable-checker alpha.core.FixedAddr
    -enable-checker security.insecureAPI.strcpy"'

before_scripts:
  - cd ${START_DIR}
  - if [ ! -d ayatana-ido-build ]; then
  -     git clone --depth 1  https://github.com/AyatanaIndicators/ayatana-ido.git ayatana-ido-build
  - fi
  - cd ayatana-ido-build
  - cmake . -DCMAKE_INSTALL_PREFIX=/usr
  - make
  - make install
  - cd -
  - rm -Rf ayatana-ido-build/

build_scripts:
  - if [ ${DISTRO_NAME} == "debian" ];then
  -     export CFLAGS+=" -Wsign-compare -Wunused-parameter"
  -     cppcheck --enable=warning,style,performance,portability,information,missingInclude .
  - fi
  -
  - mkdir build-gtk3/
  - cd build-gtk3/
  - if [ ${DISTRO_NAME} == "debian" ];then
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DFLAVOUR_GTK3=ON
  - else
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DFLAVOUR_GTK3=ON
  - fi
  -
  - if [ $CPU_COUNT -gt 1 ]; then
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT
  - else
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make
  - fi
  - cd ../
  -
  - mkdir build-gtk3-no-IDO/
  - cd build-gtk3-no-IDO/
  - if [ ${DISTRO_NAME} == "debian" ];then
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DFLAVOUR_GTK3=ON -DENABLE_IDO=OFF
  - else
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DFLAVOUR_GTK3=ON -DENABLE_IDO=OFF
  - fi
  -
  - if [ $CPU_COUNT -gt 1 ]; then
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT
  - else
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make
  - fi
  - cd ../
  -
  - mkdir build-gtk2/
  - cd build-gtk2/
  - if [ ${DISTRO_NAME} == "debian" ];then
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_TESTS=ON -DFLAVOUR_GTK2=ON
  - else
  -     scan-build $CHECKERS cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_VERBOSE_MAKEFILE=ON -DFLAVOUR_GTK2=ON
  - fi
  -
  - if [ $CPU_COUNT -gt 1 ]; then
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make -j $CPU_COUNT
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make -j $CPU_COUNT
  - else
  -     if [ ${DISTRO_NAME} == "debian" ];then
  -         scan-build $CHECKERS --keep-cc --use-cc=clang --use-c++=clang++ -o html-report make
  -         make clean
  -     fi
  -     scan-build $CHECKERS --keep-cc -o html-report make
  - fi
  - cd ../
  -
  - if [ ${DISTRO_NAME} == "debian" ];then
  -     cd build-gtk3/
  -     ${XVFB_RUN} env CTEST_OUTPUT_ON_FAILURE=1 make test
  -     cd ../
  -     cd build-gtk3-no-IDO/
  -     ${XVFB_RUN} env CTEST_OUTPUT_ON_FAILURE=1 make test
  -     cd ../
  -     cd build-gtk2/
  -     ${XVFB_RUN} env CTEST_OUTPUT_ON_FAILURE=1 make test
  -     cd ../
  - fi
