# DFU testing travis.yml script
#
# Lukasz Majewski <lukma@denx.de>
#
# Based on:
# Copyright Roger Meier <r.meier@siemens.com>
#
# SPDX-License-Identifier:	GPL-2.0+

# build U-Boot DFU on Travis CI - https://travis-ci.org/

sudo: required
dist: trusty

language: c

addons:
  apt:
    packages:
    - cppcheck
    - sloccount
    - sparse
    - bc
    - build-essential
    - libsdl1.2-dev
    - python
    - python-virtualenv
    - swig
    - libpython-dev
    - gcc-powerpc-linux-gnu
    - iasl
    - grub-efi-ia32-bin
    - rpm2cpio
    - wget
    - device-tree-compiler

install:
 # install latest device tree compiler
 #- git clone --depth=1 git://git.kernel.org/pub/scm/utils/dtc/dtc.git /tmp/dtc
 #- make -j4 -C /tmp/dtc
 # Clone uboot-test-hooks
 - git clone --depth=1 git://github.com/swarren/uboot-test-hooks.git /tmp/uboot-test-hooks
 - ln -s travis-ci /tmp/uboot-test-hooks/bin/`hostname`
 - ln -s travis-ci /tmp/uboot-test-hooks/py/`hostname`
 # prepare buildman environment
 - export BUILDMAN_ROOT="root:"
 - export BUILDMAN_ARM="arm:"
 - echo -e "[toolchain]\n${BUILDMAN_ROOT} /\n" > ~/.buildman
 - echo -e "${BUILDMAN_ARM} /opt/eldk-5.4/armv5te/sysroots/i686-eldk-linux/usr/bin/armv5te-linux-gnueabi/\n" >> ~/.buildman
 - export BUILDMAN_ALIAS_ARM="arm:"
 - echo -e "\n\n[toolchain-alias]\n" >> ~/.buildman
 - echo -e "${BUILDMAN_ALIAS_ARM} armv5te\n" >> ~/.buildman
 - cat ~/.buildman
 - virtualenv /tmp/venv
 - . /tmp/venv/bin/activate
 - pip install pytest
 - grub-mkimage -o ~/grub_x86.efi -O i386-efi normal  echo lsefimmap lsefi lsefisystab efinet tftp minicmd
 - mkdir ~/grub2-arm
 - ( cd ~/grub2-arm; wget -O - http://download.opensuse.org/ports/armv7hl/distribution/leap/42.2/repo/oss/suse/armv7hl/grub2-arm-efi-2.02~beta2-87.1.armv7hl.rpm | rpm2cpio | cpio -di )

env:
  global:
    - PATH=/tmp/dtc:/tmp/qemu-install/bin:/tmp/uboot-test-hooks/bin:$PATH
    - PYTHONPATH=/tmp/uboot-test-hooks/py/travis-ci
    - BUILD_DIR=build
    - HOSTCC="cc"
    - HOSTCXX="c++"

before_script:
  # install toolchains based on TOOLCHAIN} variable
  - if [[ "${TOOLCHAIN}" == *arm* ]]; then wget ftp://ftp.denx.de/pub/eldk/5.4/targets/armv5te/eldk-eglibc-i686-arm-toolchain-gmae-5.4.sh ; fi
  - if [[ "${TOOLCHAIN}" == *arm* ]]; then sh eldk-eglibc-i686-arm-toolchain-gmae-5.4.sh -y ; fi

script:
 # Comments must be outside the command strings below, or the Travis parser
 # will get confused.
 #
 # Exit code 129 means warnings only.
 - if [[ "${BUILDMAN}" != "" ]]; then
     tools/buildman/buildman ${BUILDMAN};
   fi

matrix:
  include:
  # we need to build by vendor due to 50min time limit for builds
  # each env setting here is a dedicated build
    - env:
        - BUILDMAN="siemens"
          TOOLCHAIN="arm"
    - env:
        - BUILDMAN="ti"
          TOOLCHAIN="arm"
    - env:
        - BUILDMAN="rockchip"
          TOOLCHAIN="arm"
    - env:
        - BUILDMAN="trats2 odroid-xu3"
          TOOLCHAIN="arm"

