#
# https://ci.appveyor.com/tools/encrypt
#

version: "{build}"

image:
  - Ubuntu2004
  - Visual Studio 2019

branches:
  only: 
    - master

for:
  -
    matrix:
      only: 
        - image: Ubuntu2004

    artifacts:
      - path: '**\REDasm*.AppImage'
        name: REDasm

    install:
      - sh: sudo apt-get update
      - sh: sudo apt-get install -y build-essential gcc-10 g++-10 qt5-default 
      - sh: sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
      - sh: git submodule update --init --recursive

    build_script:
      - sh: mkdir build
      - sh: cd build
      - sh: cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
      - sh: make -j4
        # Prepare AppImage
      - sh: make install DESTDIR=$PWD/AppDir
      - sh: wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
      - sh: wget https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage
      - sh: chmod +x linuxdeploy*.AppImage
        # Copy Icon and .desktop to AppImage folder
      - sh: mkdir -p AppDir/usr/share/applications
      - sh: mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
      - sh: cp ../REDasm.desktop AppDir/usr/share/applications/
      - sh: cp ../res/logo.png AppDir/usr/share/icons/hicolor/256x256/apps/redasm.png
        # Generate AppImage
      - sh: LD_LIBRARY_PATH=$PWD/AppDir/usr/lib/x86_64-linux-gnu ./linuxdeploy-x86_64.AppImage --appdir=AppDir --plugin qt --output appimage
      - sh: mv REDasm-*.AppImage REDasm_Linux_AMD64_`date +%Y%m%d`.AppImage

  -
    matrix:
      only: 
        - image: Visual Studio 2019

    artifacts:
      - path: '**\*.zip'
        name: REDasm

    install:
      - git submodule update --init --recursive
      - set QTCREATOR=C:\Qt\Tools\QtCreator\bin
      - set QTDIR=C:\Qt\5.15.2\msvc2019_64\bin
      - set PYTHONDIR=C:\Python37-x64
      - set PATH=%QTDIR%;%QTCREATOR%;%PYTHONDIR%;%PATH%
      - call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"

    build_script:
      - mkdir build
      - cd build
      - cmake ..
      - cmake --build . -j4 --config Release
      - cmake --build . --target REDasmDeploy
