1#!/usr/bin/env sh 2# This script can be used on the command line directly to configure several 3# different build environments. 4# This is called by `.travis.yml` via Travis CI. 5# Travis supplies $TRAVIS_OS_NAME. 6# http://docs.travis-ci.com/user/multi-os/ 7# Our .travis.yml also defines: 8 9# - BUILD_TYPE=release/debug 10# - LIB_TYPE=static/shared 11 12env_set=1 13if ${BUILD_TYPE+false}; then 14 echo "BUILD_TYPE not set in environment." 15 env_set=0 16fi 17if ${LIB_TYPE+false}; then 18 echo "LIB_TYPE not set in environment." 19 env_set=0 20fi 21if ${CXX+false}; then 22 echo "CXX not set in environment." 23 env_set=0 24fi 25 26 27if [ ${env_set} -eq 0 ]; then 28 echo "USAGE: CXX=$(which clang++) BUILD_TYPE=[release|debug] LIB_TYPE=[static|shared] $0" 29 echo "" 30 echo "Examples:" 31 echo " CXX=$(which clang++) BUILD_TYPE=release LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0" 32 echo " CXX=$(which clang++) BUILD_TYPE=debug LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0" 33 echo " CXX=$(which clang++) BUILD_TYPE=release LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0" 34 echo " CXX=$(which clang++) BUILD_TYPE=debug LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0" 35 36 echo " CXX=$(which g++) BUILD_TYPE=release LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0" 37 echo " CXX=$(which g++) BUILD_TYPE=debug LIB_TYPE=shared DESTDIR=/tmp/meson_json_cpp $0" 38 echo " CXX=$(which g++) BUILD_TYPE=release LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0" 39 echo " CXX=$(which g++) BUILD_TYPE=debug LIB_TYPE=static DESTDIR=/tmp/meson_json_cpp $0" 40 41 exit -1 42fi 43 44if ${DESTDIR+false}; then 45 DESTDIR="/usr/local" 46fi 47 48# -e: fail on error 49# -v: show commands 50# -x: show expanded commands 51set -vex 52 53 54env | sort 55 56which python3 57which meson 58which ninja 59echo ${CXX} 60${CXX} --version 61python3 --version 62meson --version 63ninja --version 64_COMPILER_NAME=`basename ${CXX}` 65_BUILD_DIR_NAME="build-${BUILD_TYPE}_${LIB_TYPE}_${_COMPILER_NAME}" 66meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . "${_BUILD_DIR_NAME}" 67ninja -v -j 2 -C "${_BUILD_DIR_NAME}" 68#ninja -v -j 2 -C "${_BUILD_DIR_NAME}" test 69cd "${_BUILD_DIR_NAME}" 70 meson test --no-rebuild --print-errorlogs 71 72 if [ "${DESTDIR}" != "/usr/local" ]; then 73 ninja install 74 fi 75cd - 76 77if ${CLEANUP+false}; then 78 echo "Skipping cleanup: build directory will persist." 79else 80 rm -r "${_BUILD_DIR_NAME}" 81fi 82