diff --git a/.travis.yml b/.travis.yml index 683f530f2..00e117bf2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,9 +13,18 @@ addons: - gcc-4.8 - g++-4.8 - gfortran-4.8 + - liblapack-dev + - libgmp3-dev + - libsuitesparse-dev + - libeigen3-dev before_script: - export CXX="g++-4.8" CC="gcc-4.8" FC="gfortran-4.8" - cd .. + - opm-common/travis/build-prereqs.sh + - opm-common/travis/clone-opm.sh opm-common + + +script: opm-common/travis/build-and-test.sh opm-common + -script: opm-common/travis/build-and-test-opm-common.sh diff --git a/travis/build-and-test.sh b/travis/build-and-test.sh new file mode 100755 index 000000000..f4268411b --- /dev/null +++ b/travis/build-and-test.sh @@ -0,0 +1,86 @@ +#!/bin/bash +set -e + +build_order=(opm-common opm-parser opm-material opm-core opm-output opm-grid opm-simulators opm-upscaling) + +# This shell script should be started with the name of a module as +# only only command line argument. It will start by building all +# upstream modules, then it will build and test the module of interest +# and all downstream modules. +# +# Before invoking this script all the modules should have been cloned +# in sibling directories, so that this script will see this directory +# structure: +# +# opm-common/ +# opm-parser/ +# opm-material/ +# opm-output/ +# opm-core/ +# opm-grid/ +# opm-simulators/ +# opm-upscaling/ +# +# +# This can typically be achived by using the 'clone-opm.sh' script. + + + +function upstream_build { + project=${1} + echo "Building: ${project}" + mkdir -p ${project}/build + pushd ${project}/build > /dev/null + cmake ../ -DENABLE_PYTHON=ON -DBUILD_TESTING=OFF -DSILENCE_EXTERNAL_WARNINGS=True + make + popd > /dev/null +} + + +function downstream_build_and_test { + project=${1} + echo "Building and testing: ${project}" + mkdir -p ${project}/build + pushd ${project}/build > /dev/null + # The build commands cmake, make and ctest must be given as + # separate commands and not chained with &&. If chaining with && + # is used the 'set -e' does not exit on first error. + cmake ../ -DENABLE_PYTHON=ON -DBUILD_TESTING=ON -DSILENCE_EXTERNAL_WARNINGS=True + make + ctest --output-on-failure + popd > /dev/null +} + + +for i in "${!build_order[@]}"; do + if [[ "${build_order[$i]}" = "$1" ]]; then + project_index=$i + fi +done + +if [[ -z ${project_index} ]]; then + echo "${0}: Project: ${1} not recognized." + exit 1 +fi + + + +build_index=0 + + +while [ $build_index -lt ${project_index} ]; +do + project=${build_order[$build_index]} + upstream_build ${project} + build_index=$((build_index + 1)) +done + + + +while [ $build_index -lt ${#build_order[@]} ] +do + project=${build_order[$build_index]} + downstream_build_and_test ${project} + build_index=$((build_index + 1)) +done + diff --git a/travis/build-prereqs.sh b/travis/build-prereqs.sh new file mode 100755 index 000000000..08d857b99 --- /dev/null +++ b/travis/build-prereqs.sh @@ -0,0 +1,71 @@ +#!/bin/bash +set -e + +# This script should build all the OPM dependencies which are installed from source. + + +# The build_dune function should take the module name as the first +# argument. By default the script will clone the source from: +# +# https://github.com/dune-project/${project}.git +# +# But you can optionally supply a git url as second argument, i.e. +# +# build_dune dune-alugrid https://gitlab.dune-project.org/extensions/dune-alugrid.git +# +# to build the dune-alugrid module which is not found at github. + +function build_dune { + project=$1 + if [[ $# -eq 1 ]]; then + url=https://github.com/dune-project/${project}.git + else + url=$2 + fi + pushd . > /dev/null + git clone ${url} + cd ${project} + git checkout tags/v2.3.1 + mkdir build + cd build + cmake ../ + make + popd > /dev/null +} + + + +function build_superlu { + pushd . > /dev/null + git clone https://github.com/starseeker/SuperLU.git + cd SuperLU + mkdir build + cd build + cmake -D CMAKE_INSTALL_PREFIX=.. -D SUPERLU_BUILD_EXAMPLES=OFF -D SUPERLU_ENABLE_TESTING=OFF ../ + make install + popd > /dev/null +} + + + +function build_ert { + git clone https://github.com/Ensembles/ert.git + mkdir -p ert/build + pushd ert/build > /dev/null + cmake ../devel && make + popd > /dev/null +} + + +################################################################# + +build_superlu +build_ert + +build_dune dune-common +build_dune dune-istl +build_dune dune-geometry +build_dune dune-grid + + + diff --git a/travis/clone-opm.sh b/travis/clone-opm.sh new file mode 100755 index 000000000..85d47f2a5 --- /dev/null +++ b/travis/clone-opm.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +set -e + +project_list=(opm-data opm-common opm-parser opm-material opm-core opm-output opm-grid opm-simulators opm-upscaling ewoms) + +# Will clone all the projects *except* the one project given as commandline argument; that +# has typically been checked out by travis already. + +function clone_project { + url=https://github.com/OPM/${1}.git + git clone $url +} + + +for project in "${project_list[@]}"; do + if [ "$project" != $1 ]; then + clone_project $project + fi +done + + +