From c7c25760346a7526600f20b72c00bae0644b61ba Mon Sep 17 00:00:00 2001
From: Giovanni Bussi <giovanni.bussi@gmail.com>
Date: Sun, 28 Feb 2016 10:32:12 +0100
Subject: [PATCH] Multi-OS support in travis

I modified extensively the travis file to allow multi-os support
and to use more recent UBUNTU:
- I upgraded most of the tests to UBUNTU trusty (with gcc 4.8)
- For a couple of tests I switch to UBUNTU precise (with gcc 4.6)
  to be sure we keep compatibility with older compilers
- I removed clang tests from UBUNTU and added OSX tests (both serial and MPI)

Since UBUNTU trusty comes with doxygen 1.8.6, I install doxygen 1.8.7
from source. Notice that this was solved in UBUNTU precise by using
an external ppa database. I prefer install from source here
since in this way we can easily upgrade doxygen to use latest features.

[makedoc]
---
 .travis.yml             | 71 ++++++++++++++++++++++++++++-------------
 .travis/install.doxygen |  7 ----
 2 files changed, 48 insertions(+), 30 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 6a06339ff..aef80d697 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,23 +1,47 @@
 language: cpp
-env:
+matrix:
+  include:
 # list of configurations to be attempted:
 # MPI + doc
 # this is the "master" one, it is going to update the manual if log contains [makedoc]
-  - PLUMED_CC=mpicc PLUMED_CXX=mpic++ MAKEDOC=yes ALMOST=yes
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ MAKEDOC=yes ALMOST=yes
 # the following are with debug flags
-# I think clang does not support debug-glibcxx, so I skip it here
-  - PLUMED_CC=gcc   PLUMED_CXX=g++    CONFIG_FLAGS="--enable-debug --enable-debug-glibcxx"
-  - PLUMED_CC=mpicc PLUMED_CXX=mpic++ CONFIG_FLAGS="--enable-debug --enable-debug-glibcxx"
-# then I try serial compilers
-  - PLUMED_CC=clang PLUMED_CXX=clang++
-  - PLUMED_CC=gcc   PLUMED_CXX=g++
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=gcc   PLUMED_CXX=g++    CONFIG_FLAGS="--enable-debug --enable-debug-glibcxx"
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++ CONFIG_FLAGS="--enable-debug --enable-debug-glibcxx"
 # then check with different optimization flags
-  - PLUMED_CC=clang PLUMED_CXX=clang++ PLUMED_CXXFLAGS=-O3 LAPACK=yes
-  - PLUMED_CC=gcc   PLUMED_CXX=g++     PLUMED_CXXFLAGS=-O3 LAPACK=yes
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=gcc   PLUMED_CXX=g++     PLUMED_CXXFLAGS=-O3 LAPACK=yes
+# then I try serial compiler on UBUNTU precise
+  - os: linux
+    dist: precise
+    sudo: required
+    env: PLUMED_CC=gcc   PLUMED_CXX=g++
 # test using external blas with internal lapack
-  - PLUMED_CC=mpicc PLUMED_CXX=mpic++  PLUMED_CXXFLAGS=-O3 LAPACK=yes CONFIG_FLAGS="--disable-external-lapack"
+  - os: linux
+    dist: trusty
+    sudo: required
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++  PLUMED_CXXFLAGS=-O3 LAPACK=yes CONFIG_FLAGS="--disable-external-lapack"
+# osx serial
+  - os: osx
+    env: PLUMED_CC=clang PLUMED_CXX=clang++ PLUMED_CXXFLAGS=-O3
+# osx parallel
+  - os: osx
+    env: PLUMED_CC=mpicc PLUMED_CXX=mpic++  PLUMED_CXXFLAGS=-O3
 # cppcheck
-  - CPPCHECK=yes
+  - os: linux
+    sudo: required
+    env: CPPCHECK=yes
 # Possible additional variables:
 #   VALGRIND=yes to make valgrind tests, only when log contains string [valgrind]
 install:
@@ -32,25 +56,26 @@ install:
   - ./.travis/check.log makedoc  || MAKEDOC=no
   - ./.travis/check.log valgrind || VALGRIND=no
   - ./.travis/check.log almost   || ALMOST=no
+# update packages
+  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update > /dev/null ; fi
+  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get update -qq ; fi
 # install some package - these are fast, we install them anyway
-  - sudo apt-get update -qq
-  - sudo apt-get install -y libmatheval-dev
+  - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libmatheval-dev ; fi
   - if test "$PLUMED_CXX" ; then ./.travis/install.xdrfile ; fi
 # cppcheck:
   - if test "$CPPCHECK" == yes ; then  ./.travis/install.cppcheck 1.69  ; fi
 # installation of these packages takes a lot of time
 # we do it only when needed
-  - if test "$PLUMED_CXX" == "mpic++" ; then sudo apt-get install -y libopenmpi1.5-dev openmpi1.5-bin ; fi
+  - if test "$PLUMED_CXX" == "mpic++" -a "$TRAVIS_OS_NAME" == "linux" ; then sudo apt-get install -y libopenmpi-dev openmpi-bin ; fi
+  - if test "$PLUMED_CXX" == "mpic++" -a "$TRAVIS_OS_NAME" == "osx" ;   then brew install openmpi ; fi
   - if test "$MAKEDOC" == yes ; then sudo apt-get install -y graphviz            ; fi
-# doxygen from its repository (apt-get gets an old version)
-#  - test "$MAKEDOC" == yes && ./.travis/install.doxygen                   || true
-# it seems that here we can get precompiled doxygen and latex
-  - if test "$MAKEDOC" == yes ; then sudo apt-add-repository -y ppa:libreoffice/ppa ; fi
-  - if test "$MAKEDOC" == yes ; then sudo apt-get update -qq                     ; fi
-  - if test "$MAKEDOC" == yes ; then sudo apt-get install -y doxygen doxygen-latex ; fi
+# install doxygen-latex
+  - if test "$MAKEDOC" == yes ; then sudo apt-get install -y doxygen-latex ; fi
+# then replace doxygen with the desided version
+  - if test "$MAKEDOC" == yes ; then ./.travis/install.doxygen Release_1_8_7 ; fi
   - if test "$VALGRIND" == yes ; then sudo apt-get install -y valgrind           ; fi
-  - if test "$LAPACK" == yes ; then sudo apt-get install libatlas-base-dev      ; fi
-  - if test "$ALMOST" == yes ; then sudo apt-get install libatlas-base-dev      ; fi
+  - if test "$LAPACK" == yes ; then sudo apt-get -y install libatlas-base-dev      ; fi
+  - if test "$ALMOST" == yes ; then sudo apt-get -y install libatlas-base-dev      ; fi
   - if test "$ALMOST" == yes ; then ./.travis/install.almost                     ; fi
   - if test "$ALMOST" == yes ; then ENALMOST="--enable-almost"                 ; fi
   - if test "$ALMOST" == yes ; then PLUMED_CPPFLAGS="-I$HOME/opt/include -I$HOME/opt/include/almost"  ; fi
diff --git a/.travis/install.doxygen b/.travis/install.doxygen
index 17e154c82..79b0ab2d8 100755
--- a/.travis/install.doxygen
+++ b/.travis/install.doxygen
@@ -3,13 +3,6 @@
 set -e
 set -x
 
-sudo apt-get install -y texlive            
-sudo apt-get install -y texlive-fonts-extra
-sudo apt-get install -y latex-xcolor       
-sudo apt-get install -y texlive-extra-utils
-sudo apt-get install -y texlive-font-utils 
-sudo apt-get install -y texlive-full       
-
 git clone https://github.com/doxygen/doxygen.git
 
 cd doxygen
-- 
GitLab