language: c

notifications:
  email: false

matrix:
  include:
    - os: linux
      dist: bionic
      sudo: required
      env:
        - SDL2_LIB=BUNDLED
        - SDL2_MIXER_LIB=BUNDLED
        - FLUIDSYNTH_LIB=BUNDLED
        - BITS=64
      addons:
        apt:
          packages:
            - cmake-data cmake libglu1-mesa-dev libgl1-mesa-dev # libfluidsynth-dev libsdl2-dev libsdl2-mixer-dev
      compiler: gcc
    - os: linux
      dist: trusty
      sudo: required
      env:
        - SDL2_LIB=BUNDLED
        - SDL2_MIXER_LIB=BUNDLED
        - FLUIDSYNTH_LIB=BUNDLED
        - CMAKE_LIBRARY_PATH=/usr/lib/i386-linux-gnu
        - BITS=32
      before_script:
        - cp ./CMakeLists.32bit.txt ./CMakeLists.txt
      addons:
        apt:
          packages:
            - cmake-data cmake libx32gcc-4.8-dev libc6-dev-i386 gcc-multilib g++-multilib libglu1-mesa-dev:i386 libgl1-mesa-dev:i386
      compiler: gcc
    - os: osx
      compiler: clang
      env:
        - SDL2_LIB=BUNDLED
        - SDL2_MIXER_LIB=BUNDLED
        - FLUIDSYNTH_LIB=OFF # Bundled lib failed to compile
        - BITS=64
    - os: osx
      compiler: gcc
      env:
        - SDL2_LIB=BUNDLED
        - SDL2_MIXER_LIB=BUNDLED
        - FLUIDSYNTH_LIB=OFF # Bundled lib failed to compile
        - BITS=64

script:
  - chmod a+rx ./osx-linux/*.sh
  - sudo TRAVIS=$TRAVIS ./osx-linux/install_${BITS}bit_sdl.sh
  - cmake -DENABLE_SDL2=${SDL2_LIB} -DENABLE_SOUND=${SDL2_MIXER_LIB} -DENABLE_FLUIDSYNTH=${FLUIDSYNTH_LIB} .
  - make -j2 systemshock

before_deploy:
  - mkdir -p shockolate
  - cp systemshock shockolate
  - cp osx-linux/install_${BITS}bit_sdl.sh shockolate/install_sdl.sh
  - cp osx-linux/readme_osx_linux.md shockolate
  - cp osx-linux/run_$TRAVIS_OS_NAME.sh shockolate/run.sh
  - cp -r shaders shockolate/
  - cp -r res shockolate/
  - export PACKAGE_NAME="shockolate-$TRAVIS_OS_NAME-${BITS}bit.tgz"
  - tar zcfv $PACKAGE_NAME shockolate
  - rm -r shockolate
  - mkdir -p shockolate-source
  - cp -r systemshock/* shockolate-source/
  - tar zcvf shockolate-source-$TRAVIS_TAG.tar.gz shockolate-source
  - rm -r shockolate-source

deploy:
  provider: releases
  skip_cleanup: true
  overwrite: true
  api_key:
    secure: "M8fgLU06LQHZS7cf98dHi8bl0BPsyvQHHDWqBaiWqnOoC4XET4fYibFf9B9Ba64RYw5DqPCGbf2onYcDrrUq0cZBwbJsJoVmajKOsWiPzddAtJrk2/nle0MWtjt6OdwbHtg0dNs36QmQ7oRxrEmQaodMmnQW0PKCZOhMmT2zdU73r9ZJ0g4kkkmAAHgfLWYPkfSb9gMj0bn5BLwwGPXv9+NeDFxVG4DY4qjEqQES9tjabVSbVNHretkFCLr0rCpGDQnEZHCP3Wt5c6MoSRunZbRg0X+IwiI1xCEchw2VQFBQiKZ3D4nJIyrZ96iijUQRnnKz5aoMZXQJZQEsnTaZLM+ZbYnK6iA5KWorILdh1odFhNfUJsvWEmEGlrrIQ9qzcAJaIFFch0HRY1S8+gGOy9tEoIpr0VWNZLg8lJvkiQgQmARrt9O+4wIzXZmQnNQcU/N3nWakI68CND4UWk4xAfA6k/Mq2IWyVu477lYxEN+FcqT7EbpowovOOn7e1rutwKDUtb3jWBHZBESF5TCL/hdwdOGNITaV+ENTHbHbWvK6J+3+sCK62xG0/pqzJk3+j7R9zoDvz+htwse/hhk/F3Sa+MpaJQVqtKVD4nBlY/E7+qd3yCyXQm916V+04evjoKOqXXnOOe5d+a87OquLJ6UaynjRsq6lJY2kZ2/Irmc="
  file: "$PACKAGE_NAME"
  on:
    tags: true
    repo: Interrupt/systemshock
