machine:
  # XXX: btrfs circleCI fix, see: https://github.com/docker/docker/issues/9939 and https://github.com/Sabayon/docker-stage3-base-amd64/commit/8c1bf737113a278dd2f
  pre:
    - sudo curl -L -o /usr/bin/docker 'https://s3-external-1.amazonaws.com/circle-downloads/docker-1.9.0-circleci'
    - sudo chmod 0755 /usr/bin/docker
  services:
    - docker

dependencies:
  override:
    - docker info
    - docker pull thewtex/cross-compiler-base
    - docker pull thewtex/cross-compiler-android-arm
    - docker pull thewtex/cross-compiler-browser-asmjs
    - docker pull thewtex/cross-compiler-linux-armv5
    - docker pull thewtex/cross-compiler-linux-armv6
    - docker pull thewtex/cross-compiler-linux-armv7
    - docker pull thewtex/cross-compiler-linux-ppc64le
    - docker pull thewtex/cross-compiler-linux-x64
    - docker pull thewtex/cross-compiler-linux-x86
    - docker pull thewtex/cross-compiler-windows-x64
    - docker pull thewtex/cross-compiler-windows-x86

test:
  override:
    - make base
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-base python /usr/src/test/run.py --emulator 'sh -c'
    - make android-arm
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-android-arm python /usr/src/test/run.py
    - make browser-asmjs
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-browser-asmjs python /usr/src/test/run.py --emulator /usr/bin/node --exe-suffix ".js"
    - make linux-armv5
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-armv5 python /usr/src/test/run.py --emulator /usr/bin/qemu-arm
    - make linux-armv6
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-armv6 python /usr/src/test/run.py --emulator /usr/bin/qemu-arm
    - make linux-armv7
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-armv7 python /usr/src/test/run.py --emulator /usr/bin/qemu-arm
    - make linux-ppc64le
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-ppc64le python /usr/src/test/run.py --emulator /usr/bin/qemu-ppc64le --languages C
    - make linux-x64
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-x64 python /usr/src/test/run.py
    - make linux-x86
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-linux-x86 python /usr/src/test/run.py
    - make windows-x64:
        timeout: 3000
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-windows-x64 python /usr/src/test/run.py --emulator /usr/bin/wine --exe-suffix ".exe"
    - make windows-x86:
        timeout: 3000
    - docker run --rm -v ~/cross-compilers/test/:/usr/src/test:ro thewtex/cross-compiler-windows-x86 python /usr/src/test/run.py --emulator /usr/bin/wine --exe-suffix ".exe"
    - docker run thewtex/cross-compiler-linux-armv7 > dockcross && chmod +x dockcross && ./dockcross gcc test/C/hello.c -o hello_arm

deployment:
  hub:
    branch: master
    commands:
      - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
      - docker push thewtex/cross-compiler-base
      - docker push thewtex/cross-compiler-android-arm
      - docker push thewtex/cross-compiler-browser-asmjs
      - docker push thewtex/cross-compiler-linux-armv5
      - docker push thewtex/cross-compiler-linux-armv6
      - docker push thewtex/cross-compiler-linux-armv7
      - docker push thewtex/cross-compiler-linux-ppc64le
      - docker push thewtex/cross-compiler-linux-x64
      - docker push thewtex/cross-compiler-linux-x86
      - docker push thewtex/cross-compiler-windows-x64
      - docker push thewtex/cross-compiler-windows-x86