From cdf516b5ac664a5aaac49de911a280e3eede5616 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Fri, 8 Apr 2016 00:42:11 +0100 Subject: [PATCH] CI with Travis and loads of portability fixes --- .gitignore | 3 ++ .travis.yml | 81 +++++++++++++++++++++++++++++++++-- ci-scripts/install-deps.sh | 10 +++++ ci-scripts/install-hdf5.sh | 17 ++++++++ ci-scripts/install-latan.sh | 20 +++++++++ ci-scripts/install-latcore.sh | 19 ++++++++ ci-scripts/install-minuit.sh | 17 ++++++++ ci-scripts/install-nlopt.sh | 17 ++++++++ configure.ac | 20 ++++++--- lib/Makefile.am | 22 ++++++++-- 10 files changed, 214 insertions(+), 12 deletions(-) create mode 100755 ci-scripts/install-deps.sh create mode 100755 ci-scripts/install-hdf5.sh create mode 100755 ci-scripts/install-latan.sh create mode 100755 ci-scripts/install-latcore.sh create mode 100755 ci-scripts/install-minuit.sh create mode 100755 ci-scripts/install-nlopt.sh diff --git a/.gitignore b/.gitignore index 938842d..21fc367 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,6 @@ lib/*Parser.hpp # Eigen headers lib/Eigen/* lib/eigen_files.mk + +# CI builds +ci-scripts/local/* diff --git a/.travis.yml b/.travis.yml index 4cfb585..328221c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,80 @@ language: cpp -compiler: - - clang - - gcc +cache: + directories: + - ci-scripts/local -install: ./bootstrap.sh +matrix: + include: + - os: osx + osx_image: xcode7.2 + compiler: clang + - os: osx + osx_image: xcode7.2 + compiler: gcc + env: VERSION=-5 + - compiler: gcc + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + - libgsl0-dev + - flex + - bison + env: VERSION=-4.9 + - compiler: gcc + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + - libgsl0-dev + - flex + - bison + env: VERSION=-5 + - compiler: clang + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.6 + packages: + - clang-3.6 + - libgsl0-dev + - flex + - bison + env: VERSION=-3.6 + - compiler: clang + addons: + apt: + sources: + - ubuntu-toolchain-r-test + - llvm-toolchain-precise-3.7 + packages: + - clang-3.7 + - libgsl0-dev + - flex + - bison + env: VERSION=-3.7 + +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install gsl; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install bison flex; export PATH="/usr/local/opt/flex/bin:/usr/local/opt/bison/bin:$PATH"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CC" == "gcc" ]]; then brew install gcc5; fi + +install: + - export LATDIR=`pwd` + - export CC=$CC$VERSION + - export CXX=$CXX$VERSION + - cd ci-scripts + - ./install-deps.sh + - cd .. + - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export LD_LIBRARY_PATH=${LATDIR}/ci-scripts/local/lib:$LD_LIBRARY_PATH; fi + +script: + - cd ci-scripts + - ./install-latan.sh `pwd`/local $TRAVIS_OS_NAME diff --git a/ci-scripts/install-deps.sh b/ci-scripts/install-deps.sh new file mode 100755 index 0000000..6af31a5 --- /dev/null +++ b/ci-scripts/install-deps.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -ex +mkdir -p local/build +for d in nlopt minuit hdf5; do + if [ ! -e local/.built.${d} ]; then + ./install-${d}.sh + fi +done +./install-latcore.sh diff --git a/ci-scripts/install-hdf5.sh b/ci-scripts/install-hdf5.sh new file mode 100755 index 0000000..e37c36f --- /dev/null +++ b/ci-scripts/install-hdf5.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +NAME='hdf5-1.8.16' + +set -ex +INITDIR=`pwd` +cd local/build +wget http://www.hdfgroup.org/ftp/HDF5/current/src/${NAME}.tar.gz +tar -xzvf ${NAME}.tar.gz +mkdir ${NAME}/build +cd ${NAME}/build +../configure --prefix=${INITDIR}/local --enable-cxx +make -j4 +make install +cd ${INITDIR}/local +touch .built.hdf5 +cd ${INITDIR} diff --git a/ci-scripts/install-latan.sh b/ci-scripts/install-latan.sh new file mode 100755 index 0000000..3272181 --- /dev/null +++ b/ci-scripts/install-latan.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +if (( $# != 2 )); then + echo "usage: `basename $0` {osx|linux}" 1>&2 + exit 1 +fi +LATAN_PREFIX=$1 +OS=$2 + +set -ex +PREFIX=`pwd`/local +./install-deps.sh +cd .. +./bootstrap.sh +mkdir -p build +cd build +if [[ "$OS" == "osx" ]]; then EXTRA_FLAGS='--with-gsl=/usr/local'; fi +../configure --prefix=$LATAN_PREFIX --with-minuit=$PREFIX --with-nlopt=$PREFIX --with-latcore=$PREFIX --with-hdf5=$PREFIX $EXTRA_FLAGS +make -j4 +make install diff --git a/ci-scripts/install-latcore.sh b/ci-scripts/install-latcore.sh new file mode 100755 index 0000000..c4b7319 --- /dev/null +++ b/ci-scripts/install-latcore.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -ex +INITDIR=`pwd` +cd local/build +if [ -d LatCore ]; then + cd LatCore + git pull origin master +else + git clone https://github.com/aportelli/LatCore.git + mkdir LatCore/build + cd LatCore + ./bootstrap.sh +fi +cd build +../configure --prefix=${INITDIR}/local +make -j4 +make install +cd ${INITDIR} diff --git a/ci-scripts/install-minuit.sh b/ci-scripts/install-minuit.sh new file mode 100755 index 0000000..5599df4 --- /dev/null +++ b/ci-scripts/install-minuit.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +NAME='Minuit2-5.34.14' + +set -ex +INITDIR=`pwd` +cd local/build +wget http://www.cern.ch/mathlibs/sw/5_34_14/Minuit2/${NAME}.tar.gz +tar -xzvf ${NAME}.tar.gz +mkdir -p ${NAME}/build +cd ${NAME}/build +../configure --prefix=${INITDIR}/local --disable-openmp +make -j4 +make install +cd ${INITDIR}/local +touch .built.minuit +cd ${INITDIR} diff --git a/ci-scripts/install-nlopt.sh b/ci-scripts/install-nlopt.sh new file mode 100755 index 0000000..450c824 --- /dev/null +++ b/ci-scripts/install-nlopt.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +NAME='nlopt-2.4.2' + +set -ex +INITDIR=`pwd` +cd local/build +wget http://ab-initio.mit.edu/nlopt/${NAME}.tar.gz +tar -xzvf ${NAME}.tar.gz +mkdir -p ${NAME}/build +cd ${NAME}/build +../configure --prefix=${INITDIR}/local --with-cxx --without-guile --without-python --without-octave --without-matlab --with-pic +make -j4 +make install +cd ${INITDIR}/local +touch .built.nlopt +cd ${INITDIR} diff --git a/configure.ac b/configure.ac index 7ef3264..b4d1893 100644 --- a/configure.ac +++ b/configure.ac @@ -8,10 +8,11 @@ AC_CONFIG_SRCDIR([lib/Global.cpp]) AC_CONFIG_SRCDIR([utils/sample_read.cpp]) AC_CONFIG_SRCDIR([examples/exMathInterpreter.cpp]) AC_CONFIG_MACRO_DIR([.buildutils/m4]) -AM_INIT_AUTOMAKE([-Wall -Werror foreign]) +AM_INIT_AUTOMAKE([1.11 -Wall -Werror foreign]) AM_SILENT_RULES([yes]) AC_CONFIG_HEADERS([config.h]) - +AM_CONDITIONAL([HAVE_AM_MINOR_LE_11], + [test `automake --version | grep automake | awk -F '.' '{print $2}'` -le 11]) # Checks for programs AC_PROG_CXX AC_PROG_AWK @@ -93,10 +94,8 @@ AC_CHECK_LIB([hdf5_cpp],[H5Fopen], [1], [Define to 1 if you have the `HDF5' library (-lhdf5_cpp).])] [have_hdf5=true] - [LIBS="$LIBS -lhdf5_cpp"],[],[-lhdf5]) + [LIBS="$LIBS -lhdf5_cpp -lhdf5"],[],[-lhdf5]) AM_CONDITIONAL([HAVE_HDF5], [test x$have_hdf5 = xtrue]) -AC_CHECK_LIB([LatCore],[_ZN7LatCore12testFunctionEv],[], - [AC_MSG_ERROR([LatCore library not found])]) SAVED_LDFLAGS=$LDFLAGS LDFLAGS="$LDFLAGS -lMinuit2" AC_MSG_CHECKING([for ROOT::Minuit2::BasicMinimumError in -lMinuit2]); @@ -113,6 +112,17 @@ AC_LINK_IFELSE( [AC_MSG_RESULT([no])]) AM_CONDITIONAL([HAVE_MINUIT], [test x$have_minuit = xtrue]) LDFLAGS=$SAVED_LDFLAGS +SAVED_LDFLAGS=$LDFLAGS +LDFLAGS="$LDFLAGS -lLatCore" +AC_MSG_CHECKING([for LatCore::XmlReader in -lLatCore]); +AC_LINK_IFELSE( + [AC_LANG_PROGRAM([#include ], + [LatCore::XmlReader dummy()])], + [LIBS="$LIBS -lLatCore"] + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no])] + [AC_MSG_ERROR([LatCore library not found])]) +LDFLAGS=$SAVED_LDFLAGS # Checks for header files. AC_HEADER_STDC diff --git a/lib/Makefile.am b/lib/Makefile.am index e03ff09..5f8af1e 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -10,14 +10,12 @@ endif AM_LFLAGS = -olex.yy.c AM_YFLAGS = -d -BUILT_SOURCES = AsciiParser.hpp MathParser.hpp - lib_LTLIBRARIES = libLatAnalyze.la noinst_LTLIBRARIES = libLexers.la libLexers_la_SOURCES = AsciiLexer.lpp MathLexer.lpp if CXX_GNU - libLexers_la_CXXFLAGS = $(COM_CXXFLAGS) -Wno-unused-function + libLexers_la_CXXFLAGS = $(COM_CXXFLAGS) -Wno-unused-parameter -Wno-unused-function -Wno-deprecated-register else libLexers_la_CXXFLAGS = $(COM_CXXFLAGS) endif @@ -97,4 +95,22 @@ endif libLatAnalyze_la_CXXFLAGS = $(COM_CXXFLAGS) libLatAnalyze_la_LIBADD = libLexers.la +if HAVE_AM_MINOR_LE_11 +AsciiParser.hpp: AsciiParser.ypp + $(AM_V_YACC) $(YACC) -o AsciiParser.cpp --defines=AsciiParser.hpp $< + +MathParser.hpp: MathParser.ypp + $(AM_V_YACC) $(YACC) -o MathParser.cpp --defines=MathParser.hpp $< +endif + +BUILT_SOURCES = AsciiParser.hpp MathParser.hpp + +CLEANFILES = \ + MathLexer.cpp \ + AsciiLexer.cpp \ + AsciiParser.cpp\ + AsciiParser.hpp\ + MathParser.cpp \ + MathParser.hpp + ACLOCAL_AMFLAGS = -I .buildutils/m4