language: c

cache: apt

os:
  - linux
  - osx

compiler:
  - gcc
  - clang

matrix:
  exclude:
    # /usr/bin/gcc on OS X is clang, so it's not meaningful to build against both.
    - os: osx
      compiler: gcc

addons:
  apt:
    packages:
      - libbluetooth-dev
      - libusb-1.0-0-dev

before_script:
  - pushd /tmp
#  - wget https://launchpad.net/gcc-arm-embedded/5.0/5-2015-q4-major/+download/gcc-arm-none-eabi-5_2-2015q4-20151219-linux.tar.bz2 -O /tmp/gcc-arm.tar.bz2
#  - tar -xvf /tmp/gcc-arm.tar.bz2
#  - export PATH=/tmp/gcc-arm-none-eabi-5_2-2015q4/bin:$PATH
  - mkdir libbtbb-install
  - wget https://github.com/greatscottgadgets/libbtbb/archive/master.zip -O /tmp/libbtbb-master.zip
  - unzip libbtbb-master.zip
  - mkdir libbtbb-master/build
  - pushd libbtbb-master/build
  - cmake -DCMAKE_INSTALL_PREFIX:PATH=/tmp/libbtbb-install ..
  - make
  - make install
  - popd
  - popd
  - export CFLAGS="-g -Wall -Wextra -Werror -Wno-zero-length-array"

before_install:
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libusb; fi

script:
  - mkdir host/build
  - pushd host/build
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then DYLIB_SUFFIX=dylib; else DYLIB_SUFFIX=so; fi
  - cmake -DLIBBTBB_INCLUDE_DIR=/tmp/libbtbb-install/include -DLIBBTBB_LIBRARIES=/tmp/libbtbb-install/lib/libbtbb.$DYLIB_SUFFIX ..
  - make
#  - popd
#  - pushd firmware
#  - CROSS_COMPILE="/tmp/gcc-arm-none-eabi-5_2-2015q4/bin/arm-none-eabi-" DFU_TOOL="../../host/build/ubertooth-tools/src/ubertooth-dfu" make
