language: cpp

git:
  depth: false

jobs:
    include:
      - if: branch = master AND tag IS present
        services: docker
        name: "Linux Python 3.5"
        script:
          - >
            docker run --name lief_35
            -e PYTHON_BINARY=/opt/python/cp35-cp35m/bin/python3.5
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux.sh
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
            docker run \
              -v $TRAVIS_BUILD_DIR:/src \
              -e TRAVIS="true" \
              -e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
              -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
              -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
              -e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
              -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
              -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
              --rm \
              liefproject/deploy python3 /src/.github/deploy.py;
            fi


      - if: branch = master AND tag IS present
        services: docker
        name: "Linux Python 3.6"
        script:
          - >
            docker run --name lief_36
            -e PYTHON_BINARY=/opt/python/cp36-cp36m/bin/python3.6
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux.sh
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
            docker run \
              -v $TRAVIS_BUILD_DIR:/src \
              -e TRAVIS="true" \
              -e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
              -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
              -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
              -e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
              -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
              -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
              --rm \
              liefproject/deploy python3 /src/.github/deploy.py;
            fi

      - services: docker
        name: "Linux Python 3.7 | SDK | Doc Trigger"
        script:
          - >
            docker run --name lief_37
            -e PYTHON_BINARY=/opt/python/cp37-cp37m/bin/python3.7
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux.sh
          - >
            docker run --name lief_sdk
            -e PYTHON_BINARY=$PYTHON_BINARY
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux-sdk.sh
          - >
            sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
            sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
            docker run \
              -v $TRAVIS_BUILD_DIR:/src \
              -e TRAVIS="true" \
              -e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
              -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
              -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
              -e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
              -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
              -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
              --rm \
              liefproject/deploy python3 /src/.github/deploy.py;
            fi
        after_success:
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]];
            then
            docker run --rm
            -e CIRCLE_CI_TOKEN=$CIRCLE_CI_TOKEN
            liefproject/manylinux1_x86_64
            bash -c "curl --request POST --url https://circleci.com/api/v2/project/gh/lief-project/doc/pipeline --header 'Circle-Token: ${CIRCLE_CI_TOKEN}' --header 'content-type: application/json'";
            fi

      - services: docker
        name: "Linux Python 3.8"
        script:
          - >
            docker run --name lief_38
            -e PYTHON_BINARY=/opt/python/cp38-cp38/bin/python3.8
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux.sh
          - >
            sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
            sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
            docker run \
              -v $TRAVIS_BUILD_DIR:/src \
              -e TRAVIS="true" \
              -e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
              -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
              -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
              -e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
              -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
              -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
              --rm \
              liefproject/deploy python3 /src/.github/deploy.py;
            fi
      - services: docker
        name: "Linux Python 3.9"
        script:
          - >
            docker run --name lief_39
            -e PYTHON_BINARY=/opt/python/cp39-cp39/bin/python3.9
            -e CCACHE_DIR=/ccache
            -v $HOME/.ccache:/ccache
            -v $TRAVIS_BUILD_DIR:/src
            liefproject/manylinux1_x86_64
            bash /src/scripts/docker/travis-linux.sh
          - >
            sudo chmod -R 777 $TRAVIS_BUILD_DIR/build &&
            sudo chown -R 1000:1000 $TRAVIS_BUILD_DIR/build
          - >
            if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
            docker run \
              -v $TRAVIS_BUILD_DIR:/src \
              -e TRAVIS="true" \
              -e TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
              -e TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \
              -e TRAVIS_BRANCH=$TRAVIS_BRANCH \
              -e TRAVIS_BUILD_DIR=$TRAVIS_BUILD_DIR \
              -e LIEF_AUTOMATIC_BUILDS_KEY=$LIEF_AUTOMATIC_BUILDS_KEY \
              -e LIEF_AUTOMATIC_BUILDS_IV=$LIEF_AUTOMATIC_BUILDS_IV \
              --rm \
              liefproject/deploy python3 /src/.github/deploy.py;
            fi

      ## macOS 10.14.6 - xcode 11 - Python 3.5
      #- if: branch = master AND tag IS present AND type = push
      #  os: osx
      #  osx_image: xcode11
      #  compiler: clang
      #  script:
      #    - pyenv install --skip-existing 3.5.0
      #    - >
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
      #      $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
      #  after_success:
      #    - >
      #      if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
      #      cd $TRAVIS_BUILD_DIR &&
      #      bash ./.github/deploy.sh;
      #      fi

      ## macOS 10.14.6 - xcode 11 - Python 3.6
      #- if: branch = master AND tag IS present AND type = push
      #  os: osx
      #  osx_image: xcode11
      #  compiler: clang
      #  script:
      #    - pyenv install --skip-existing 3.6.0
      #    - >
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.6.0/bin/python3.6 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
      #      $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
      #  after_success:
      #    - >
      #      if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.6.0/bin/python3.6 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
      #      cd $TRAVIS_BUILD_DIR &&
      #      bash ./.github/deploy.sh;
      #      fi


      ## macOS 10.14.6 - xcode 11 - Python 3.7
      #- os: osx
      #  osx_image: xcode11
      #  compiler: clang
      #  script:
      #    - pyenv install --skip-existing 3.7.0
      #    - >
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.7.0/bin/python3.7 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
      #      $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
      #  after_success:
      #    - >
      #      if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.7.0/bin/python3.7 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
      #      cd $TRAVIS_BUILD_DIR &&
      #      bash ./.github/deploy.sh;
      #      fi

      # macOS 10.14.6 - xcode 11 - Python 3.8
      #- os: osx
      #  osx_image: xcode11
      #  compiler: clang
      #  name: "OSX Python 3.8"
      #  script:
      #    - pyenv install --skip-existing 3.8.0
      #    - >
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.8.0/bin/python3.8 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
      #      $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
      #  after_success:
      #    - >
      #      if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.8.0/bin/python3.8 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
      #      cd $TRAVIS_BUILD_DIR &&
      #      bash ./.github/deploy.sh;
      #      fi

      ## macOS 10.14.6 - xcode 11 - Python 3.9
      #- os: osx
      #  osx_image: xcode11
      #  compiler: clang
      #  name: "OSX Python 3.9 | SDK"
      #  script:
      #    - pyenv install --skip-existing 3.9.0
      #    - >
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools wheel &&
      #      $PYTHON_BINARY ./setup.py --ninja --lief-test build bdist_wheel
      #    - bash scripts/osx/package_sdk.sh
      #  after_success:
      #    - >
      #      if [[ "$TRAVIS_EVENT_TYPE" != "pull_request" ]]; then
      #      export PYTHON_BINARY=$(pyenv root)/versions/3.9.0/bin/python3.9 &&
      #      sudo $PYTHON_BINARY -m pip install --upgrade pip setuptools requests mako wheel &&
      #      cd $TRAVIS_BUILD_DIR &&
      #      bash ./.github/deploy.sh;
      #      fi


#branches:
#  only:
#  - master

notifications:
  email:
    on_success: never
    on_failure: always

cache:
  - ccache: true
  - directories:
    - $HOME/.pyenv
    - $HOME/.ccache

env:
  global:
    - USE_CCACHE=1
    - CCACHE_COMPRESS=1
    - CCACHE_MAXSIZE=10.0G
    - CCACHE_CPP2=1

addons:
  homebrew:
    packages:
    - pyenv
    - ccache
    - ninja
    update: true

before_install:
  - ccache --set-config=max_size=10.0G
  - ccache --zero-stats --version
  - ccache --set-config=compiler_check=content
  - ccache -p
  - if [ "$TRAVIS_OS_NAME" == "linux" ]; then docker pull liefproject/manylinux1_x86_64:latest; fi
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PREFIX="/usr/local"; fi
  #- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then export PYTHON_CONFIGURE_OPTS="--enable-shared --enable-unicode=ucs2"; fi
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then pyenv root; fi
  - if [ "$TRAVIS_OS_NAME" == "osx" ]; then pyenv install --list  ;fi

after_script:
  - ccache --show-stats

#deploy:
#  provider: releases
#  token:
#    - secure: LTJMZp9kJ9/tmv73YGktP3Bdhh3moettDNooiRlQfUEgUemRlp9K+ybbufN0ya0Md0bouOJ/7nWqFToWl1G5/kcRr4MjV/P2c+iH8W7mvWcFupLGdwm1+aqpin3hiGsdYz0a1TK37y6DANspFwHILjq1SPf5L8kGEHnYSIfyUFHaETbv7GHL+4gf1XG/55KVuyFa3vZ2BPa3sIXr4bRypdNsqssFOZ7qeoJawtcI3TbjmLqx+sOGR2aiG+9lX+/vcYVGECHOE4KdV5BbTFitDLkJ0toAQrgN4XuB6XMXEnijU0RGtpkvsUAYJUuYaNcV2ea4bwLPCKz0IJvzTw3gtyB/pioP4OUx0xY2csuNuGfppZ0Fb+BWhPx9wOg209lrPjtoWszK8vo4PywKlEUviNG+3hEYx9x382IbtbXvIxp+c2iYdRicudFIdjjSZt7fy1MwBvHhWoBRl1hVw5fpFvRIC6Q1/B6MV55Jc3LVYCs+QHPAXq2KJ1KWK/Q7mmlriG3O+dvswcE1l0/AmeqKuXLsgUMuzScYa4fMFvXL3l/B8bKw205ynMzKvbb61P3sGrJJ+AFDEoHDk8yNtSaTowoUveu75DbL1s1p02QjYeVt7AJS8AsqUm7QPcUU5iXW1gSgt50jD/46/uvK7NZCFj2LzkiVzM5JIbiUANx8pKA=
#  file_glob: true
#  file:
#    - ${TRAVIS_BUILD_DIR}/dist/*.whl
#    - ${TRAVIS_BUILD_DIR}/build/*.tar.gz
#  on:
#    tags: true
