language: c
matrix:
  include:
    - os: linux
      name: "linux"
      dist: xenial
      sudo: required
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - gcc-5
            - g++-5
            - make
            - libglfw3
            - libglfw3-dev
            - libfreetype6-dev
            - libssl-dev
    - os: windows
      name: "windows_gcc"
      language: bash
      filter_secrets: false
    - os: windows
      name: "windows_msvc"
      language: bash
      filter_secrets: false
    - os: osx
      name: "osx"
      osx_image: xcode10.3
      addons:
        homebrew:
          packages:
            - freetype
            - glfw
            - openssl
script:
  - |
    if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
      sudo unlink /usr/bin/gcc && sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc
    fi
  - |
    if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
      export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/opt/openssl/lib/
    fi
  - |
    if [[ "${TRAVIS_OS_NAME}" == "windows" ]]; then
      ### troubleshooting and diagnostics: show ALL environment variables in the instance
      #set
      set -e
      git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries  thirdparty/freetype/
      
      if [[ "${TRAVIS_JOB_NAME}" == "windows_gcc" ]]; then
        echo "Building V with GCC"
        export VFLAGS="-os windows"
        ./make.bat -gcc
      fi
      if [[ "${TRAVIS_JOB_NAME}" == "windows_msvc" ]]; then
        echo "Building V with MSVC"
        export VFLAGS="-os msvc"
        ./make.bat -msvc
      fi
      
      ### running just repl_test.v produces failing results earlier and is easier to read
      echo "Running only the repl tests directly..."
      ./v.exe ./compiler/tests/repl/repl_test.v
      echo "Running ALL tests..."
      ./v.exe test v
      set +e
    fi
  - |
    if [[ "${TRAVIS_OS_NAME}" != "windows" ]]; then
      make
      ./v -o v compiler
      ./v test v
    fi
  - |
    if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
      git clone https://github.com/vlang/vid
      cd vid && ../v -debug -o vid .
    fi
