# Travis-CI Build for RfidResearchGroup/Proxmark3
language: c

#default linux build env is: xenial
compiler: gcc

os:
  - linux
  - osx

dist: bionic

osx_image: xcode11

# move some env variables to homebrew env
env:
  global:
    - HOMEBREW_TRAVIS_BRANCH=$TRAVIS_BRANCH
    - HOMEBREW_TRAVIS_COMMIT=$TRAVIS_COMMIT
  jobs:
    - TO_TEST=MAKEFILE MAKE_PARAMS='PLATFORM_EXTRAS='
    - TO_TEST=MAKEFILE MAKE_PARAMS='PLATFORM_EXTRAS=BTADDON'
    - TO_TEST=CMAKE

addons:
  apt:
    packages:
      - gcc-arm-none-eabi
      - libnewlib-dev
      - libbluetooth-dev
      - python3-dev
      - libbz2-dev
  homebrew:
    packages:
      - readline
      - qt5
      - RfidResearchGroup/proxmark3/arm-none-eabi-gcc
    taps: RfidResearchGroup/proxmark3
# update trick to fix https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/14
    update: true

before_install:
  # bug?
  # homebrew update replaced python2.7 by python3.7 but
  # python3 link failed while python@2 still present, so let's do it again:
  if [ "$TRAVIS_OS_NAME" == "osx" ]; then
    brew link --overwrite python;
  fi

install:
  if ! arm-none-eabi-gcc -v; then
    echo "arm-none-eabi-gcc [ERROR]";
    travis_terminate 1;
  fi

script:
  - if [ "$TO_TEST" = "MAKEFILE" ]; then
      make clean && make V=1 "$MAKE_PARAMS";
      make check;
    fi
  - if [ "$TO_TEST" = "CMAKE" ]; then
      mkdir -p client/build && ( cd client/build && cmake .. && make VERBOSE=1 );
      make client/check CHECKARGS="--clientbin ./client/build/proxmark3";
    fi
